<template>
	<view class="box">
		<view class="topBox">
			<view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
			<view class="nav" :style="{top: iStatusBarHeight + 'px'}">
				<view>我的</view>
			</view>
		</view>



		<view class="customerMes">
			<image :src="headImg" mode="" style="width: 120rpx;height: 120rpx;border-radius: 60rpx;"></image>
			<view class="mes">
				<view class="nick">
					<view class="nickName" v-if="userInfo.nickName">{{userInfo.nickName}}</view>
					<view class="grade" v-if="numList.levelName">{{numList.levelName}}</view>
				</view>
				<view class="phone">{{userInfo.mobilePhone}}</view>
			</view>
		</view>

		<view class="headerBox">
			<view class="quan" @click="gonavigateTo('../index/discountCard')">
				<view class="numStr">{{numList.count?numList.count:0}}</view>
				<view class="nameStr">优惠券</view>
			</view>
			<view class="quan">
				<view class="numStr">{{numList.totalIntegral?numList.totalIntegral:0}}</view>
				<view class="nameStr">积分</view>
			</view>
			<view class="quan" @click="gonavigateTo('../index/vipCard')">
				<view class="numStr">{{numList.cardNum?numList.cardNum:0}}</view>
				<view class="nameStr">会员卡</view>
			</view>

		</view>


		<!-- 我的订单 -->
		<view class="orderBox">

			<view class="orderTitle">我的订单</view>

			<view class="orderLIneBox">
				<view class="orderLine" @click="goorder(1)">
					<view class="orderImgBox">
						<view class="orderNum" v-show="numList.waitPurchaseSize>0">{{numList.waitPurchaseSize}}</view>
						<image src="../../static/img/icon_daifukuan.png" mode="" class="orderLineImg"></image>
					</view>
					<view class="orderLineTxt">待付款</view>
				</view>
				<view class="orderLine" @click="goorder(2)">
					<view class="orderImgBox">
						<view class="orderNum" v-show="numList.waitServiceSize>0">{{numList.waitServiceSize}}</view>
						<image src="../../static/img/icon_daifuwu.png" mode="" class="orderLineImg"></image>
					</view>
					<view class="orderLineTxt">待服务</view>
				</view>
				<view class="orderLine" @click="goorder(3)">
					<view class="orderImgBox">
						<view class="orderNum" v-show="numList.hasOverSize>0">{{numList.hasOverSize}}</view>
						<image src="../../static/img/icon_yiwancheng.png" mode="" class="orderLineImg"></image>
					</view>
					<view class="orderLineTxt">已完成</view>
				</view>

				<view class="orderLine" @click="goorder(0)">
					<view class="orderImgBox">
						<view class="orderNum" v-show="numList.allSize>0">{{numList.allSize}}</view>
						<image src="../../static/img/icon_allorder.png" mode="" class="orderLineImg"></image>
					</view>
					<view class="orderLineTxt">全部</view>
				</view>

			</view>
		</view>

		<!-- 店铺信息 -->
		<view class="shopBox">

			<view class="shopCont">
				<view class="shopName">{{numList.shopInfo.shopName}}</view>
				<view class="shopRightBox">
					<image src="../../static/img/icon_ditu.png" mode="" class="shopRightImg"
						style="margin-right: 67rpx;" @click="map"></image>
					<image src="../../static/img/icon_phone.png" mode="" class="shopRightImg" @click="call"></image>
				</view>

			</view>
			<view class="shopTime" v-if="numList.shopInfo.startTime && numList.shopInfo.endTime">{{numList.shopInfo.startTime}}-{{numList.shopInfo.endTime}}</view>
			<view class="address">
				<view class="Address">{{numList.shopInfo.provinceName}}{{numList.shopInfo.cityName}}{{numList.shopInfo.areaName}}{{numList.shopInfo.address}}
				</view>
				<view class="distance" v-if="numList.shopInfo.distance&&numList.shopInfo.distance!= '0.00'">{{numList.shopInfo.distance}}km</view>
			</view>



		</view>


		<!-- 我的 相关 -->
		<view class="rowBoxBg">
			<view class="rowBox" @click="gonavigateTo('../index/shopList')">
				<view class="leftView">
					<image src="../../static/img/icon_me1.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">服务专家</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>


			<view class="rowBox" @click="gonavigateTo('')">
				<view class="leftView">
					<image src="../../static/img/icon_me2.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">我的车库</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>


			<view class="rowBox" @click="gonavigateTo('myBespeak')">
				<view class="leftView">
					<image src="../../static/img/icon_me3.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">我的预约</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>


			<view class="rowBox" @click="gonavigateTo('historySpend')">
				<view class="leftView">
					<image src="../../static/img/icon_me4.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">历史消费</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>

			<view class="rowBox" @click="gonavigateTo('checkReport')">
				<view class="leftView">
					<image src="../../static/img/icon_me5.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">车检报告</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>

			<view class="rowBox" @click="gonavigateTo('invite')">
				<view class="leftView">
					<image src="../../static/img/icon_me6.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">分享给好友</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>

			<view class="rowBox" @click="gonavigateTo('invite')">
				<view class="leftView">
					<image src="../../static/img/icon_me7.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">意见反馈</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>

			<view class="rowBox" @click="gonavigateTo('')">
				<view class="leftView">
					<image src="../../static/img/icon_me8.png" mode="" class="liftIcon"></image>
					<view class="rowTitle">清除缓存</view>
				</view>
				<image src="../../static/img/rightArrow.png" mode="" class="rightArrow"></image>
			</view>

		</view>


		<view class="signOut" @click="signOut">退出登录</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				iStatusBarHeight: '',
				userInfo: '',
				shopData: '',
				numList: '',
				uid: '',
				headImg: '',
				location: {
					lng: '',
					lat: '',
				},
			}
		},
		onLoad(opt) {
			var that = this;
			uni.getLocation({
				type: 'gcj02',
				success: function(res) {
					console.log(res)
					that.location.lat = res.latitude
					that.location.lng = res.longitude
			
					that.queryMyDetail() 
			
				},
				fail(err) {
			
				}
			});
			this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
			const wxOpenData = uni.getStorageSync("wxOpenData");
			if (wxOpenData) {
				this.headImg = wxOpenData.loginInfo.customerInfo.headImgurl;
				this.uid = wxOpenData.loginInfo.uid;
			}
			this.userInfo = uni.getStorageSync("userInfo")
		},
		onShow() {

			this.queryMyDetail();
			
		},
		methods: {
			
			map() {
				console.log("打开地图")
				var that = this;
				if (!that.location.lat || !that.location.lng) {
					uni.showToast({
						title: '该店铺未设置定位',
						icon: 'none',
						duration: 3000
					});
				} else {
					uni.openLocation({
						latitude: Number(that.location.lat),
						longitude: Number(that.location.lng),
						name: that.numList.shopInfo.shopName,
						address: that.numList.shopInfo.provinceName+that.numList.shopInfo.cityName+that.numList.shopInfo.areaName+that.numList.shopInfo.address,
						success: function() {
							console.log('success');
						},
						fail(err) {
							console.log(err)
						}
					});
				}

			},

			call() {
				uni.makePhoneCall({
					phoneNumber: this.userInfo.mobilePhone
				});
			},

			goorder(num) {
				uni.navigateTo({
					url: './myOrder/myOrder?num=' + num
				})
			},
			
			queryMyDetail() {
				uni.showLoading({
					title: '加载中'
				})
				this.$http('openreservation/getInfo', {
					lat: this.location.lat ? this.location.lat : '',
					lng: this.location.lng ? this.location.lng : '',
					
				}, 'GET').then(res => {
					uni.hideLoading();
					this.numList = res.data

				})
			},
			gonavigateTo(url) {

				uni.navigateTo({
					url: url
				})
			},
			signOut() {
				//uni.clearStorageSync();
				uni.removeStorageSync('logodata');
				// uni.navigateTo({
				// 	url: '../login/login'
				// })
			},

		},
		
		// 下拉刷新
		onPullDownRefresh() {
			
			this.queryMyDetail()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
	}
</script>

<style scoped>
	.box {

		width: 100vw;
		min-height: 100vh;
		background: linear-gradient(180deg, #FFFFFF 0%, #F4F5F7 100%);
		padding-bottom: 60rpx;
	}

	.topBox {

		background-image: url("data:image/png;base64,[encoded data, 219256 characters]");
		background-size: 100% 100%;
		height: 302rpx;
		width: 100vw;
	}

	.status_bar {

		width: 100vw;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
	}

	.nav {
		line-height: 44px;
		font-size: 34rpx;
		font-weight: 600;
		display: flex;
		justify-content: center;
		color: #333333;
		position: fixed;
		width: 100vw;
		left: 0;


	}




	.flex {
		display: flex;
	}

	.customerMes {
		display: flex;
		height: 120rpx;
		padding-left: 24rpx;
		margin-top: -120rpx;
	}

	.mes {
		margin: 20rpx 15rpx 0rpx;
	}

	.nick {

		margin-bottom: 5rpx;


		display: flex;
		justify-content: flex-start;

	}

	.nickName {
		font-size: 34rpx;
		color: #333333;
		font-weight: bold;

	}

	.grade {
		margin-left: 15rpx;
		font-size: 24rpx;
		color: #F19D01;
		padding: 0rpx 10rpx;
		border: 1rpx solid #F19D01;
		border-radius: 4rpx;
		height: 32rpx;
	}

	.phone {
		font-size: 24rpx;
		color: #666666;
	}


	.headerBox {
		padding: 30rpx 24rpx;

		display: flex;
		justify-content: space-around;
	}

	.quan {
		display: flex;
		flex-direction: column;
		align-items: center;
		height: 120rpx;
	}

	.numStr {
		font-size: 40rpx;
		font-weight: bold;
		color: #222222;
		line-height: 56rpx;
	}

	.nameStr {
		font-size: 24rpx;
		color: #666666;
	}

	.orderBox {
		margin: 0rpx 24rpx;

		background: #FFFFFF;
		padding: 30rpx 20rpx;
		border-radius: 10rpx;
	}



	.orderTitle {
		font-size: 30rpx;
		color: #333333;
		font-weight: bold;

	}

	.orderAll {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.orderLine {
		width: 25%;
		text-align: center;
	}

	.orderLineImg {
		width: 60rpx;
		height: 60rpx;
	}

	.orderLineTxt {
		font-size: 24rpx;
		color: #333333;
	}

	.orderImgBox {
		text-align: center;
		position: relative;
	}

	.orderLIneBox {
		display: flex;
		justify-content: space-between;
		padding-top: 30rpx;
	}

	.orderNum {
		line-height: 26rpx;
		background: #FF0000;
		padding: 0 8rpx;
		border-radius: 13rpx;
		color: #FFFFFF;
		font-size: 20rpx;
		position: absolute;
		top: -5rpx;
		right: 38rpx;
		z-index: 11;
	}

	.rightArrow {
		margin-right: 20rpx;
		width: 30rpx;
		height: 30rpx;

	}



	.rowBoxBg {

		margin: 20rpx 24rpx;
		margin-top: 30rpx;
		background: #FFFFFF;

		border-radius: 10rpx;
	}

	.rowBox {
		display: flex;
		justify-content: space-between;
		background: #FFFFFF;
		padding: 35rpx 0rpx;
		border-radius: 10rpx;
		align-items: center;

	}

	.leftView {
		display: flex;
		align-items: center;

	}

	.rightView {
		display: flex;
		align-items: center;

	}

	.liftIcon {
		width: 34rpx;
		height: 34rpx;
		margin: 0rpx 20rpx;
	}

	.rowTitle {
		color: #3C3C3C;
		font-size: 28rpx;
	}

	.signOut {
		width: 702rpx;
		height: 98rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		font-size: 30rpx;
		color: #FF3B30;
		line-height: 98rpx;
		text-align: center;

		margin: 40rpx 24rpx;
	}

	.shopBox {


		padding: 20rpx;
		margin: 20rpx 24rpx;

		background-color: #FFFFFF;
		border-radius: 10rpx;

	}

	.shopCont {
		display: flex;
		justify-content: space-between;
		align-items: center;

	}

	.shopName {
		font-size: 30rpx;
		font-weight: bold;
		color: #3C3C3C;
		line-height: 42rpx;
	}

	.shopRightBox {
		display: flex;
		justify-content: space-between;
	}

	.address {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.Address,
	.shopTime,
	.distance {
		color: #999999;
		font-size: 24rpx;
		padding-top: 15rpx;
		
		/* 隐藏文字显示 ...不换行 */
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}



	.shopRightBox {}

	.shopRightImg {
		width: 44rpx;
		height: 45rpx;
	}
</style>
