<template>
	<view class="app">
		<view class="content">
			<view class="CommodityOrder" @tap="goorder">商品订单
				<image class="picture" src="../../static/huijiantou.png" mode=""></image>
			</view>
			<view class="center" v-if="list">
				<view class="OrderStatus" @tap="gopaid('WAIT_PAY')">
					<image src="/static/Tobepaid.png" mode=""></image>
					<span>待付款</span>
					<view class="orderCount" v-if="list.waitPayCount>0&&list.waitPayCount<100">
						{{list.waitPayCount}}
					</view>
					<view class="orderCount" v-if="list.waitPayCount>=100">
						99+
					</view>
				</view>
				<view class="OrderStatus" @tap="goreceive('WAIT_RECEIVED_GOODS')">
					<image src="/static/received.png" mode=""></image>
					<span>待收货</span>
					<view class="orderCount" v-if="list.waitReceivedGoodsCount>0&&list.waitReceivedGoodsCount<100">
						{{list.waitReceivedGoodsCount}}
					</view>
					<view class="orderCount" v-if="list.waitReceivedGoodsCount>=100">
						99+
					</view>
				</view>
				<view class="OrderStatus" @tap="gocompleted('RECEIVED_GOODS')">
					<image src="/static/evaluated.png" mode=""></image>
					<span>待评价</span>
					<view class="orderCount" v-if="list.receivedGoodsCount>0&&list.receivedGoodsCount<100">
						{{list.receivedGoodsCount}}
					</view>
					<view class="orderCount" v-if="list.receivedGoodsCount>=100">
						99+
					</view>
				</view>
				<view class="OrderStatus" @tap="goEVALUATED('EVALUATED')">
					<image src="/static/finished.png" mode=""></image>
					<span>已完成</span>
					<!-- <view class="orderCount" v-if="list.evaluatedCount>0&&list.evaluatedCount<100">
						{{list.evaluatedCount}}
					</view>
					<view class="orderCount" v-if="list.evaluatedCount>=100">
						99+
					</view> -->
				</view>
			</view>
		</view>
		<view class="service" @tap="gonursestation">
			<view class="serviceorder">护理站服务订单</view>
			<view class="pictures">
				<image src="../../static/huijiantou.png" mode=""></image>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		orderCount
	} from '@/api/order/index.js'
	export default {
		data() {
			return {
				list: null,
			}
		},
		onShow() {
			let that = this
			const value = uni.getStorageSync('patientId');
			if (value) {
				orderCount(value).then(res => {
					this.list = res.data
				})
			} else {
				that.$refs.uToast.show({
					title: '请登录',
					type: 'error',
					duration: '1000',
					url: '/pages/login/login'
				})
			}
		},
		methods: {
			//护理站服务订单
			gonursestation() {
				uni.navigateTo({
					url: '/pages/Nursingstationserviceorder/Nursingstationserviceorder'
				})
			},
			//待收货
			goreceive(item) {
				uni.navigateTo({
					url: `/pages/CommodityOrder/CommodityOrder?orderStatus=${item}`
				})
			},
			//全部订单
			goorder() {
				uni.navigateTo({
					url: '/pages/CommodityOrder/CommodityOrder'
				})
			},
			//已完成
			goEVALUATED(item) {
				uni.navigateTo({
					url: `/pages/CommodityOrder/CommodityOrder?orderStatus=${item}`
				})
			},
			//待评价
			gocompleted(item) {
				uni.navigateTo({
					url: `/pages/CommodityOrder/CommodityOrder?orderStatus=${item}`
				})
			},
			//待付款
			gopaid(item) {
				uni.navigateTo({
					url: `/pages/CommodityOrder/CommodityOrder?orderStatus=${item}`
				})
			},
		},
	}
</script>

<style lang="scss">
	.app {
		background-color: #F4F5F7;
		width: 100%;
		color: #000000;
		padding: 3%;
		font-size: 36rpx;

		span {
			display: block;
		}

		.service {
			width: 99%;
			height: 105rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
			border-radius: 20rpx;
			margin-top: 3%;

			.pictures {
				display: inline-block;
				margin-left: 48%;

				image {
					width: 18rpx;
					height: 27rpx;
				}
			}

			.serviceorder {
				line-height: 100rpx;
				margin-left: 5%;
				display: inline-block;
			}
		}

		.content {
			width: 99%;
			height: 344rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
			border-radius: 20rpx;

			.center {
				display: flex;
				justify-content: space-around;

				image {
					width: 100rpx;
					height: 80rpx;
					margin-left: 50%;
					transform: translateX(-50%);
				}

				.OrderStatus {
					padding-top: 50rpx;
					position: relative;

					.orderCount {
						background-color: red;
						color: #FFFFFF;
						border-radius: 50%;
						text-align: center;
						// padding: 0 5rpx ;
						line-height: 40rpx;
						width: 40rpx;
						height: 40rpx;
						font-size: 20rpx;
						// display: inline-block;
						position: absolute;
						top: 30rpx;
						right: -20rpx;
					}
				}
			}

			.picture {
				margin-left: 70%;
				width: 18rpx;
				height: 27rpx;
			}

			.CommodityOrder {
				display: inline-block;
				width: 90%;
				height: 110rpx;
				line-height: 100rpx;
				margin-left: 5%;
				border-bottom: 1rpx solid #D8D4D4;
			}
		}
	}
</style>
