<template>
	<!-- 个人中心 订单信息 -->
	<view class="container doc-layer userOrder">
	  <view class='layer-all'>
	    <view class="order-top">我的订单
	      <navigator url='/pages/order/order?type=-1'>查看全部</navigator>
	    </view>
	    <view class="order-list">
	      <navigator url='/pages/order/order?type=0' class="list-item">
	        <icon class='fkIcon'>
	        </icon>
		    <text class="oCount">{{count.waitPayOrder == 0?'':count.waitPayOrder}}</text>
	        <text class="name" bindload="getOrderData">待付款</text>
	      </navigator>
	      <navigator url='/pages/order/order?type=1' class="list-item">
	        <icon class='syIcon'>
	        </icon>
				<text class="oCount">{{count.waitUseOrder == 0?'':count.waitUseOrder}}</text>
	        <text class="name">待使用</text>
	      </navigator>
	      <navigator url='/pages/order/order?type=2' class="list-item">
	        <icon class='pjIcon'>
	        </icon>
	          <text class="oCount">{{count.waitCommentOrder == 0?'':count.waitCommentOrder}}</text>
	        <text class="name">待评价</text>
	      </navigator>
	      <navigator url='/pages/order/order?type=3' class="list-item">
	        <icon class='tkIcon'>
	        </icon>
	          <text class="oCount">{{count.cancelOrder == 0?'':count.cancelOrder}}</text>
	        <text class="name">退款订单</text>
	      </navigator>
	    </view>
	  </view>
	</view>
</template>

<script>
	var that;
	import aes from "@/common/aes.js";
	export default {
		data() {
			that = this;
			return {
				count:{},
				back:false
			}
		},
		onLoad(options) {
			uni.removeStorageSync("user_token")
			uni.removeStorageSync("unionid")
			// var back = options.back;
			// if(back != undefined && back != null && back != ""){
				// this.back = true;
				// that.getUserInfo(openid);
			// }else{
				// var openid = "ouO7m5Y-MLmHE0HQIlH7W9gbS30k";
				// if(uni.getStorageSync("user_token") == undefined || uni.getStorageSync("user_token") == null || uni.getStorageSync("user_token") == ""){
					// that.getUserInfo(openid);
				// }else{
					// that.getOrderCount();
				// }
			// }
		},
		methods: {
			getUser: function(){
				
				window.location.href="http://5ahmiy.natappfree.cc/weixin/get";
			},
			getUserInfo: function(openid){
				var method = "getLogin";
				var sendData = {
					"api_token":that.$md5.hexMD5("API"+method+"lvyou"),
					"mobile":"13931993592",
					"pwd":"fengjishu"
				}
				var data = {
					"data":JSON.stringify(sendData),
					"url": this.$config.getLogin
				}
				that.$Request.post(this.$config.getAittoData,data).then(res => {
					if(res.code == 0){
						uni.setStorageSync("user_token",aes.aesMinEncrypt(res.data.user_token));
						uni.setStorageSync("user_info",res.data.userInfo);
						if(this.back){
							uni.navigateBack({})
							return
						}
						that.getOrderCount();
					}else{
						uni.showToast({
							icon: "none",
							title: res.msg
						})
					}
				})
			},
			getOrderCount: function(){
				var method = "getUserOrderCount";
				var sendData = {
					"api_token":that.$md5.hexMD5("API"+method+"lvyou"),
					"user_token":aes.aesDecrypt(uni.getStorageSync("user_token")),
					"mid":uni.getStorageSync("user_info").mid
				}
				var data = {
					"data":JSON.stringify(sendData),
					"url": this.$config.getUserOrderCount
				}
				that.$Request.post(this.$config.getAittoData,data).then(res => {
					if(res.code == 0){
						that.count = res.data;
					}else{
						uni.showToast({
							icon: "none",
							title: res.msg
						})
					}
				})
			}
		}
	}
</script>

<style>
/* pages/user/index.wxss*/
.doc-layer .layer-all{padding:10rpx; border-radius:10rpx; box-shadow:0 0 10px #e1e1e1; background:#fff; }
/* 个人中心 订单信息 */
.userOrder{margin-top: 20rpx;}
.userOrder .order-top{position:relative; margin:10rpx 0 0 0; padding:0 40rpx 20rpx 20rpx; border-bottom:1px solid #ededed; font-size:32rpx; }
.userOrder .order-top::after{content:""; position:absolute; top:50%; right:0rpx; width:50rpx; height:50rpx; margin-top:-40rpx; background:url(https://www.aitto.net/phone/public/images/2019spot/icon-after.png) no-repeat; background-size:50rpx; }
.userOrder .order-top navigator{float:right; display:block; color:#666; font-size:24rpx; line-height:40rpx; }
.userOrder .order-list{display:flex; flex-wrap:wrap; }
.userOrder .order-list .list-item{width:25%; margin:10rpx 0; text-align:center; }
.userOrder .order-list .list-item icon{position:relative; display:inline-block; width:60rpx; height:60rpx; }
.userOrder .order-list .list-item icon text{display:block; position:absolute; top:-10rpx; right:-10rpx; width:36rpx; height:36rpx; padding:0; border-radius:36rpx; background:#ff6f6f; color:#fff; font-size:22rpx; text-align:center; line-height:36rpx; }
.userOrder .order-list .list-item .name{display:block; color:#666; font-size:28rpx; text-align:center; }
.userOrder .order-list .list-item .fkIcon{background:url(https://www.aitto.net/phone/public/images/2019spot/icon-dfk.png) no-repeat; background-size:60rpx; }
.userOrder .order-list .list-item .syIcon{background:url(https://www.aitto.net/phone/public/images/2019spot/icon-dsy.png) no-repeat; background-size:60rpx; }
.userOrder .order-list .list-item .pjIcon{background:url(https://www.aitto.net/phone/public/images/2019spot/icon-dpj.png) no-repeat; background-size:60rpx; }
.userOrder .order-list .list-item .tkIcon{background:url(https://www.aitto.net/phone/public/images/2019spot/icon-tk.png) no-repeat; background-size:60rpx; }
.oCount{ width:36rpx; height:36rpx; padding:0; border-radius:36rpx; background:#ff6f6f; color:#fff; font-size:22rpx;}
</style>
