<template>
	<view class="ordermanagement">
		<view class="ordermanagement-header">
			<view class="ordermanagement-header-text">
				订单管理
			</view>
			<view class="ordermanagement-list">
				<view class="ordermanagement-list-yi">
					<view class="ordermanagement-list-yi-top">
						{{num.orderPayment==undefined?0:num.orderPayment}}
					</view>
					<view class="ordermanagement-list-yi-bottom">
						已支付订单数
					</view>
				</view>
				<view class="ordermanagement-list-yi">
					<view class="ordermanagement-list-yi-top">
						{{num.payPrice==undefined?0:num.payPrice}}
					</view>
					<view class="ordermanagement-list-yi-bottom">
						实际支付金额
					</view>
				</view>
				<view class="ordermanagement-list-yi">
					<view class="ordermanagement-list-yi-top">
						{{num.refundPrice==undefined?0:num.refundPrice}}
					</view>
					<view class="ordermanagement-list-yi-bottom">
						已退款金额
					</view>
				</view>
			</view>
		</view>
		<view class="ordermanagement-ding">
			<view class="ordermanagement-ding-text">
				我的订单
			</view>
			<view class="ordermanagement-ding-nei">
				<view class="ordermanagement-yisdf" v-for="(item,index) in dingdan" :key="index" @click="jiru(item.status,index)">
					<view class="ordermanagement-img">
						<image :src="item.img" mode="widthFix"></image>
						<view class="ordermanagement-img-biao" v-if="item.num==0?false:true">
							{{item.num}}
						</view>
					</view>
					<view class="">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<!-- 		<view class="ordermanagement-dingsss">
			<view class="ordermanagement-ding-text">
				售后管理
			</view>
			<view class="ordermanagement-ding-nei">
				<view class="ordermanagement-yisdf" v-for="(item,index) in dingdansss" :key="dingdan">
					<view class="ordermanagement-img">
						<image :src="item.img" mode="widthFix"></image>
					</view>
					<view class="">
						{{item.name}}
					</view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import {
		getOrderStstusAmount
	} from '@/commit/order.js'
	export default {
		data() {
			return {
				num: [], //正向订单状态数
				mer_id: 264,
				dingdan: [{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154736170.png',
						name: '待付款',
					},
					{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154723185.png',
						name: '待发货',
					},
					{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154804269.png',
						name: '待收货',
					},
					{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154750259.png',
						name: '待评价',
					}
					// ,
					// {
					// 	img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154847886.png',
					// 	name: '已退款'
					// }
				],
				dingdansss: [{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154904247.png',
						name: '待审核'
					},
					{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154932244.png',
						name: '未通过'
					},
					{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154949118.png',
						name: '已通过'
					},
					{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154918922.png',
						name: '待收货'
					},
					{
						img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812155008586.png',
						name: '已完成'
					}
				]
			}
		},
		onLoad() {
			
		},
		onShow() {
			uni.showLoading({
				title: '加载中',
			});
			let selectmerchant = uni.getStorageSync('selectmerchant')
			this.mer_id = selectmerchant.merId
			this.getOrderStstusAmount()
			
			
			
			
		},
		methods: {
			// 正向订单状态数
			getOrderStstusAmount() {
				getOrderStstusAmount({
					mer_id: this.mer_id
				}).then(res => {
					if (res.data.status == 200) {
						this.num = res.data.data
						this.dingdan = [{
								img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154736170.png',
								name: '待付款',
								num: this.num.orderPrepPayment,
								status:5
							},
							{
								img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154723185.png',
								name: '待发货',
								num: this.num.orderForDelivery,
								status:0
							},
							{
								img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154804269.png',
								name: '待收货',
								num: this.num.orderForReceived,
								status:1
							},
							{
								img: 'https://cdn.bjtdba.com/vod/image/2022-08-12/20220812154750259.png',
								name: '待评价',
								num: this.num.orderForSpeech,
								status:2
							}
						]
						uni.hideLoading();
					}
				}, fail => {
					console.log(fail)
				})
			},
			jiru(e,i) {
				
				
				let authorization = uni.getStorageSync('authorization')
				let userinfo = uni.getStorageSync('userinfo')
				let selectmerchant = uni.getStorageSync('selectmerchant')
				let uid = userinfo.uid
				if (authorization && uid) {
					if (selectmerchant.merId >= 0 && selectmerchant.status == -1) {
						uni.redirectTo({
							url: "/openmerchant/guide/index" //有或者没有商户 没有金额支付and激活码支付
						});
						return
					} else if (selectmerchant.merId > 0 && (selectmerchant.status == 1 || selectmerchant.status == 5)) {
						uni.redirectTo({
							url: "../../shop/commodity/order?status="+e + "&index="+ i
						})
						return
					} else if (selectmerchant.merId >= 0 && (selectmerchant.status == 3 || selectmerchant.status == 4)) {
						uni.redirectTo({
							url: '/openmerchant/shopentry/process?mer_id=' + selectmerchant.merId //已开通商户未填写资料
						});
						return
					} else if (selectmerchant.merId > 0 && selectmerchant.status == 0) {
						uni.redirectTo({
							url: '/openmerchant/shopentry/processaudit?submitCode=' + 3 //已开通商户待审核
						});
						return
					} else if (selectmerchant.merId > 0 && selectmerchant.status == 2) {
						uni.redirectTo({
							url: '/openmerchant/shopentry/processaudit?submitCode=' + 2 //已开通商户审核拒绝
						});
						return
					}
				
				} else {
					uni.navigateTo({
						url: "/pages/user/login/index?type=1"
					});
					return
				}
				
				
			}
		}
	}
</script>
<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.ordermanagement {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;

		.ordermanagement-header {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 100%;
			height: 328rpx;
			background: linear-gradient(180deg, rgba(31, 124, 255, 0.2200) 0%, rgba(255, 255, 255, 0.1500) 100%);
			position: relative;
			display: flex;
			justify-content: center;

			.ordermanagement-header-text {
				position: absolute;
				font-size: 46rpx;
				font-weight: 500;
				color: #333333;
				top: 202rpx;
				left: 64rpx;
			}

			.ordermanagement-list {
				position: absolute;
				top: 298rpx;
				width: 686rpx;
				height: 150rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				display: flex;
				justify-content: space-around;
				align-items: center;

				.ordermanagement-list-yi {
					height: 70rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: center;

					.ordermanagement-list-yi-top {
						font-size: 36rpx;
						font-weight: bold;
						color: #333333;
					}

					.ordermanagement-list-yi-bottom {
						font-size: 26rpx;
						font-weight: 400;
						color: #333333;
					}
				}
			}
		}

		.ordermanagement-ding {
			width: 686rpx;
			height: 216rpx;
			margin: 156rpx 0 32rpx 0;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: flex-start;

			.ordermanagement-ding-text {
				font-size: 30rpx;
				font-weight: 600;
				color: #333333;
			}

			.ordermanagement-ding-nei {
				width: 100%;
				height: 160rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				display: flex;
				justify-content: space-around;
				align-items: center;

				.ordermanagement-yisdf {
					height: 96rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: center;
					font-size: 24rpx;
					font-weight: 400;
					color: #5F6060;

					.ordermanagement-img {
						width: 48rpx;
						height: 48rpx;
						position: relative;

						image {
							width: 100%;
							height: 100%;
						}

						.ordermanagement-img-biao {
							position: absolute;
							left: 40rpx;
							bottom: 31rpx;
							width: 30rpx;
							height: 30rpx;
							border-radius: 50%;
							background: #FE0032;
							font-size: 20rpx;
							font-weight: 400;
							color: #FFFFFF;
							display: flex;
							justify-content: center;
							align-items: center;
						}
					}
				}
			}
		}

		.ordermanagement-dingsss {
			width: 686rpx;
			height: 216rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: flex-start;

			.ordermanagement-ding-text {
				font-size: 30rpx;
				font-weight: 600;
				color: #333333;
			}

			.ordermanagement-ding-nei {
				width: 100%;
				height: 160rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				display: flex;
				justify-content: space-around;
				align-items: center;

				.ordermanagement-yisdf {
					height: 96rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: center;
					font-size: 24rpx;
					font-weight: 400;
					color: #5F6060;

					.ordermanagement-img {
						width: 48rpx;
						height: 48rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}
				}
			}
		}
	}
</style>
