<template>
	<view class="content">
		<view class="topBj">
			<view class="noToken" @click="goUserCenter">
				<view class="headInfo" v-if="!token">
					<image src="../../static/ic_50@2x.png" mode="" class="noTokenImg"></image>
					<view class="loginText">登录</view>
				</view>
				<view class="headInfo" v-if="token">
					<image :src="userInfo.image" mode="" class="noTokenImg"></image>
					<view class="loginText">{{userInfo.nickname}}</view>
				</view>
				<view class="changeToShop" style="font-size: 40rpx;font-weight: 600;color: #fff;" @click="goAdmin" v-if="userInfo.is_admin==1">
					<image src="../../static/qiehuan.png" mode="" style="width: 48rpx;height: 48rpx;"></image>
					<view class="changeInfo">切换商家</view>
				</view>
			</view>
		</view>

		<view class="orderBox">
			<view class="topBox">
				<view class="allText">
					全部订单
				</view>
				<view class="lookALL" @click="allOrder(0)">
					查看全部订单
					<image src="../../static/ic_21_1@2x.png" mode=""></image>
				</view>
			</view>
			<view class="orderListBpox">
				<view class="orderItem" @click="allOrder(1)">
					<image src="../../static/ic_oder02@2x.png" mode=""></image>
					<view class="">
						待付款
					</view>
					<view class="orderNum" v-if="orderNum.nopay!=0">
						{{orderNum.nopay}}
					</view>
				</view>
				<view class="orderItem" @click="allOrder(2)">
					<image src="../../static/ic_30@2x.png" mode=""></image>
					<view class="">
						待发货
					</view>
					<view class="orderNum" v-if="orderNum.nosend!=0">
						{{orderNum.nosend}}
					</view>
				</view>
				<view class="orderItem" @click="allOrder(3)">
					<image src="../../static/ic_oder03@2x.png" mode=""></image>
					<view class="">
						待收货
					</view>
					<view class="orderNum" v-if="orderNum.noget!=0">
						{{orderNum.noget}}
					</view>
				</view>
				<view class="orderItem" @click="allOrder(4)">
					<image src="../../static/ic_oder04@2x.png" mode=""></image>
					<view class="">
						待评价
					</view>
					<view class="orderNum" v-if="orderNum.nocomment!=0">
						{{orderNum.nocomment}}
					</view>
				</view>
				<view class="orderItem" @click="allOrder(5)">
					<image src="../../static/ic_oder02@2x.png" mode=""></image>
					<view class="">
						已完成
					</view>
					<view class="orderNum" v-if="orderNum.aftersale!=0">
						{{orderNum.aftersale}}
					</view>
				</view>
			</view>
			<view class="myFuwu">
				<view class="fuwutext">
					我的服务
				</view>
				<view class="fuwuItem" @click="myAddress">
					<image src="../../static/ic_31@2x.png" mode=""></image><text>我的地址</text>
				</view>
				<view class="fuwuItem" @click="myEvaluate">
					<image src="../../static/ic_32@2x.png" mode=""></image><text>我的评价</text>
				</view>
				<view class="fuwuItem" @click="collect">
					<image src="../../static/ic_23@2x.png" mode=""></image><text>我的收藏</text>
				</view>
				<view class="fuwuItem">
					<image src="../../static/ic_34@2x.png" mode=""></image><text>我的客服</text>
				</view>
				<view class="fuwuItem" @click="agreeInfo">
					<image src="../../static/ic_35@2x.png" mode=""></image><text>商家信息</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token: false,
				userInfo:'',   //用户信息
				userData: '',
				show: false,
				sum: 966,
				fensi: 0,
				jf: 0,
				guanzhu: 0,
				shoucang: 0,
				phoneNumber: '',
				messageNum: 0, //留言个数
				isIphoneX: false,
				orderNum:'',   //订单数量
			}
		},
		onShow() {
			if(uni.getStorageSync('token')){
				this.token=true
				this.userInfo=uni.getStorageSync('userInfo')
			}
			this.getOrderNum()
		},
		created() {

		},
		methods: {
			goUserCenter() {
				uni.navigateTo({
					url: '/pages/me/user-center'
				})
			},
			//切换商家身份
			goAdmin() {
				uni.redirectTo({
					url: '/pages/admin-order/all-order'
				})
			},
			//全部订单
			allOrder(index) {
				uni.navigateTo({
					url: '/pages/order/order-list?index='+index
				})
			},
			//获取订单数量
			getOrderNum(){
				request.get('/api/order/statusNum',{}).then(res=>{
					this.orderNum=res.data
				}).catch(err=>{
					
				})
			},
			//我的地址
			myAddress() {
				uni.navigateTo({
					url: '/pages/me/my-address'
				})
			},
			//我的评价
			myEvaluate() {
				uni.navigateTo({
					url: '/pages/me/my-evaluate'
				})
			},
			//我的收藏
			collect() {
				uni.navigateTo({
					url: '/pages/me/my-collect'
				})
			},
			//商家信息
			agreeInfo() {
				uni.navigateTo({
					url: '/pages/me/agree-info'
				})
			}
		}
	}
</script>

<style>
	/* @import url("/common/uni.css"); */
	@import url("/common/me.css");
</style>