<template>
	<view class="home-page">
		<view class="bg">
			<view class=" u-flex">
				<view class="u-m-r-10">
					<image :src="avatar" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
				</view>
				<view class="u-flex-1 u-m-l-10" v-if="!isLogin">
					<view>
						<view class=" flex align-center">
							<view class="userName">{{userName}}</view>
							<view class="labe" @tap="stateSave" v-if="XCXIsSelect != '否'">
								<text class="yuan">
								</text>
								<view v-if="isTrue">已上线</view>
								<view v-if="!isTrue">已下线</view>
							</view>
						</view>
						<view class="flex " style="font-size: 24rpx;color: #222222;margin-top: 20rpx;"
							v-if="XCXIsSelect != '否'">
							<view v-if="renzheng == 0" @click.stop="goNav('/my/renzheng/rzType')">
								暂未实名认证
							</view>
							<view v-if="renzheng == 1" @click.stop="goNav('/my/renzheng/index')">
								实名审核中
							</view>
							<view v-if="renzheng == 2">
								已实名认证
							</view>
							<view v-if="renzheng == 3" @click.stop="goNav('/my/renzheng/index')">
								实名已拒绝
							</view>
						</view>

					</view>
				</view>
				<view v-else class="userName" @click="goLogin('/pages/public/login')">
					登录
				</view>
			</view>
			<view class="box" v-if="XCXIsSelect != '否'">
				<view class="label-item">
					￥<text class="number">{{sumMoney}}</text>
					<view class="label">总收益</view>
				</view>
				<view class="label-item">
					<text class="number">{{countOrderNum}}</text>
					<view class="label">总销量</view>
				</view>
				<view class="label-item">
					<text class="number">{{countTakingByUserId}}</text>
					<view class="label">用户评价</view>
				</view>
				<view class="label-item">
					<text class="number">{{countByUserId}}</text>
					<view class="label">访客人数</view>
				</view>
			</view>
		</view>
		<view >

			<view style="background: #FFFFFF;border-radius: 32rpx 32rpx 32rpx 32rpx;padding: 28rpx;" class="flex align-center justify-between" v-if="XCXIsSelect != '否'">
				<view class="text-center" @click="goNavs('/pages/my/mangshi')">
					<image src="../../static/images/index/shezhi.png" style="width: 80rpx;height:80rpx;"></image>
					<view style="font-size: 24rpx;color: #222222;margin-top: 20rpx;">忙时设置</view>
				</view>
				<view class="text-center" @click="goNavs('/my/qiandao/index')">
					<image src="../../static/images/index/qiandao.png" style="width: 80rpx;height:80rpx;"></image>
					<view style="font-size: 24rpx;color: #222222;margin-top: 20rpx;">签到中心</view>
				</view>
				<view class="text-center" @click="goNav('/pages/my/user')">
					<image src="../../static/images/index/geren.png" style="width: 80rpx;height:80rpx;"></image>
					<view style="font-size: 24rpx;color: #222222;margin-top: 20rpx;">个人信息</view>
				</view>
				<view class="text-center" @click="goNavs('/pages/index/jinji')">
					<image src="../../static/images/index/jinji.png" style="width: 80rpx;height:80rpx;"></image>
					<view style="font-size: 24rpx;color: #222222;margin-top: 20rpx;">紧急报警</view>
				</view>
			</view>

			<!-- <view class="box1" @click="goNav('/my/shuju/index')">
				<view class="text-bold text-lg margin-bottom-sm">订单数据</view>
				<view class="orderbox ">
					<view class="text-center">
						￥<text class="text-bold text-xl">{{orderMoney}}</text>
						<view class="margin-top-xs">订单收入</view>
					</view>
					<view class="text-center">
						<text class="text-bold text-xl">{{countOrder}}</text>
						<view class="margin-top-xs">总订单数</view>
					</view>
					<view class="text-center">
						￥<text class="text-bold text-xl">{{sumRefund}}</text>
						<view class="margin-top-xs">退款金额</view>
					</view>
					<view class="text-center">
						<text class="text-bold text-xl">{{countByUserId}}</text>
						<view class="margin-top-xs">访客人数</view>
					</view>
				</view>
			</view> -->
				<view class="box-title">订单管理</view>
				<view class="guanlibox" @click="goDetail(1)">
						
					<view class="item">
						<view class="icon-box">
							<image class="icon" src="../../static/images/index/order1.png">
							</image>
							<view class="label">待服务</view>
						</view>
						<text class="number">{{countOrderIng}}</text>
					</view>
					<view class="item item2">
						<view class="icon-box">
							<image class="icon" src="../../static/images/index/order2.png">
							</image>
							<view class="label">进行中</view>
						</view>
						<text class="number">{{countOrderAppraise}}</text>
					</view>
					<view class="item item3">
						<view class="icon-box">
							<image class="icon" src="../../static/images/index/order3.png">
							</image>
							<view class="label">已完成</view>
						</view>
							<text class="number">{{countOrderEnd}}</text>
					</view>
				</view>

				<view class="box-title">订单数据</view>
				<view class="guanlibox" @click="goNav('/my/shuju/index')">
					
					<view class="item">
						<view class="icon-box">
							<image class="icon" src="../../static/images/index/order4.png">
							</image>
							<view class="label">订单收入</view>
						</view>
						<text class="number">{{orderMoney}}</text>
					</view>
					
					<view class="item">
						<view class="icon-box">
							<image class="icon" src="../../static/images/index/order5.png">
							</image>
							<view class="label">总订单数</view>
						</view>
						<text class="number">{{countOrder}}</text>
					</view>
					
					<view class="item">
						<view class="icon-box">
							<image class="icon" src="../../static/images/index/order6.png">
							</image>
							<view class="label">退款金额</view>
						</view>
						<text class="number">{{sumRefund}}</text>
					</view>
				</view>

			<view style="margin-top: 40rpx;" v-if="goods.length > 0">
				<view class="text-bold text-lg">
					<view>今日服务</view>
				</view>
				<view class="bgwhite radius margin-top-sm padding-bottom-sm" v-for="(item,index) in goods" :key='index'
					@click="goNav('/my/order/pay?ordersId='+item.ordersId)">
					<view class="flex justify-between padding-sm">

						<view class="text-green" v-if="item.status ==1">待付款...</view>
						<view class="text-green" v-if="item.status ==2">待服务</view>
						<view class="text-green" v-if="item.status ==5">已完成</view>
						<view class="text-green" v-if="item.status ==6">进行中</view>
						<view class="text-green" v-if="item.status ==7">已出发</view>
						<view class="text-green" v-if="item.status ==8">已到达</view>
						<view class="text-green" v-if="item.status ==3">待评价</view>
						<view class="text-green" v-if="item.status ==4" style="color: #999999;">已取消</view>
						<view v-if="item.overTimeOrders == 1" style="color: red;font-size:26rpx">(订单已超时)</view>
						<!-- <view class="text-green" v-if="item.state ==1 ||item.state ==2">待完成</view>

						<view class="text-green" v-if="item.state ==3||item.state ==4">已完成</view> -->

						<view class="text-green">预约时间：{{item.serveTime}}</view>
					</view>
					<view class="xian"></view>
					<view class=" u-flex u-p-t-30 padding-sm">
						<view class="u-m-r-10">
							<u-avatar :src="item.massageImg?item.massageImg: '../../static/logo.png'" mode="square"
								size="100">
							</u-avatar>
						</view>
						<view class="u-flex-1  margin-left-xs">
							<view class="u-font-18  text-bold u-line-1" style="width: 560rpx;">
								<view class="margin-right-xs text-df margin-left-xs"
									style="margin-top: 0rpx;display: inline-block;width: 400rpx; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
									{{item.title}}
								</view>
							</view>
							<view class="margin-left-xs text-cut" style="width:550upx">{{item.address}}</view>

						</view>
					</view>
					<view class="flex u-p-t-20 justify-between align-center padding-sm">
						<view class=" flex-sub ">
							实收：<text class="text-df">￥</text><text
								class="text-xl text-bold">{{item.sumArtificerMoney}}</text>
						</view>
						<view class="flex text-right">
							<u-button v-if="item.status == 1" :custom-style="customStyle" shape="circle" :plain="true"
								@click="cancelOrder(item)">取消订单</u-button>
							<u-button v-if="item.status == 1" :custom-style="customStyle1" shape="circle" :plain="true"
								@click="bindphone(item.phone)">联系TA</u-button>

							<u-button v-if=" item.state==1" :custom-style="customStyle1" shape="circle" :plain="true"
								@click="goNav('/my/order/pay?id='+item.ordersId+'&isTrue=1')">查看详情</u-button>
							<u-button v-if="item.status == 6" :custom-style="customStyle" shape="circle" :plain="true"
								@click="cancel(item)">订单完成</u-button>
						</view>
					</view>
					<view class="xian" v-if="item.endTime && item.endTime.day && item.status == 6"></view>
					<view class="pintuan_syrs flex justify-between"
						v-if="item.endTime && item.endTime.day && item.status == 6">
						<view style="font-size: 28rpx;font-family: PingFang SC;font-weight: bold;color: #2FB57A;">服务倒计时
						</view>
						<uni-countdown :day="item.endTime.day" :hour="item.endTime.hour" :minute="item.endTime.minute"
							:second="item.endTime.second" color="#20C675">
						</uni-countdown>
					</view>
				</view>
			</view>
			<uni-popup ref="popup" type="center">
				<view style="background: #fff;width:658upx;height: 960upx; border-radius:17upx;position: relative;">
					<image :src="Guanggao" style="width: 100%;height: 100%;" mode="aspectFill"
						@tap="saveImgs(Guanggao)"></image>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	import empty from '@/components/empty.vue'
	export default {
		components: {
			empty
		},
		data() {
			return {
				Guanggao: '',
				ssDW: false,
				stateName: '休息中',
				avatar: '../../static/logo.png',
				isLogin: true,
				userName: '匿名',
				renzheng: 0,
				goods: [],
				sumMoney: 0, //总收益
				countOrderNum: 0, //总销量
				countTakingByUserId: 0, //用户评价数
				orderMoney: 0, //订单收入
				countOrder: 0, //总订单数
				sumRefund: 0, //退款金额
				countByUserId: 0, //访客人数
				countOrderIng: 0, //待接单
				countOrderAppraise: 0, //待完成
				countOrderEnd: 0, //已完成
				putaway: 0, //上架中
				soldOut: 0, //下架中
				page: 1,
				limit: 10,
				longitude: '',
				latitude: '',
				isTrue: true,
				showModal: true,
				userId: '',
				arr: [],
				city: '',
				invitationCode:'',
				isCashDeposit: 0,
				customStyle: {
					color: '#999999',
					border: '2rpx solid #999999',
					// backgroundColor: '#1E1F31',
					border: "8rpx",
					width: '180rpx',
					height: '54rpx',
					margin: "0 0 0 20rpx"
				},
				customStyle1: {
					color: '#2FB57A',
					border: '2rpx solid #2FB57A',
					border: "8rpx",
					width: '180rpx',
					height: '54rpx',
					margin: "0 0 0 20rpx"
				},
				XCXIsSelect: '否',
				time: ''
			}
		},
		onShareAppMessage(res) { //发送给朋友
			return {
				title: this.tuiguang,
				path: '/pages/index/index?invitation=' + this.invitationCode,
				imageUrl: this.tuiguangImg,
			}
		},
		onShareTimeline(res) { //分享到朋友圈
			return {
				title: this.tuiguang,
				path: '/pages/index/index?invitation=' + this.invitationCode,
				imageUrl: this.tuiguangImg,
			}
		},
		onLoad(e) {
			this.userId = uni.getStorageSync('userId')
			// 获取邀请码保存到本地
			if (e.invitation) {
				this.$queue.setData('inviterCode', e.invitation);
			}
			// #ifdef MP-WEIXIN
			if (e.scene) {
				const scene = decodeURIComponent(e.scene);
				this.$queue.setData('inviterCode', scene.split(',')[0]);
			}
			// #endif
			this.$Request.getT('/app/common/type/247').then(res => { //下单成功
				if (res.code == 0) {
					if (res.data && res.data.value) {
						this.arr.push(res.data.value)
					}
				}
			})
			this.$Request.getT('/app/common/type/249').then(res => { //用户完成成功
				if (res.code == 0) {
					if (res.data && res.data.value) {
						this.arr.push(res.data.value)
					}
				}
			})
			this.$Request.getT('/app/common/type/309').then(res => { //用户完成成功
				if (res.code == 0) {
					if (res.data && res.data.value) {
						this.arr.push(res.data.value)
					}
				}
			})

			// 技师端首页是否弹框 380
			this.$Request.get('/app/common/type/380').then(res => {
				if (res.code == 0 && res.data.value && res.data.value === '是') {
					this.$Request.get('/app/common/type/379').then(res => {
						if (res.code == 0 && res.data && res.data.value) {
							this.Guanggao = res.data.value;
							this.$refs.popup.open();
						}
					});
				}
			});
			// this.getcity()
		},
		onShow() {
			//是否开启技师端实时定位	375
			this.$Request.get('/app/common/type/375').then(res => {
				if (res.code == 0 && res.data) {
					if (res.data.value === '是') {
   						let that = this
   						let userId = uni.getStorageSync('userId')
   						let renzheng = uni.getStorageSync('renzheng')
   						if (userId && renzheng && renzheng == 2) {
   							that.getcity()
   						}
   					}
				}
			});

			this.$Request.get('/app/common/type/238').then(res => {
				if (res.code == 0) {
					// #ifdef MP-WEIXIN
					this.$queue.setData('XCXIsSelect', res.data.value);
					// #endif
					// #ifndef MP-WEIXIN
					this.$queue.setData('XCXIsSelect', '是');
					// #endif
					this.XCXIsSelect = this.$queue.getData("XCXIsSelect");
				}
			});
			this.userId = uni.getStorageSync('userId')
			this.isCashDeposit = uni.getStorageSync('isCashDeposit')
			if (this.userId) {
				this.isLogin = false
				this.getJinRiOrder();
				this.getUserInfo()
				this.getFb()

				this.getArtificer()

				this.getNewOrder()


				// #ifdef MP-WEIXIN
				//订阅
				if (this.showModal) {
					this.openMsg()
				}
				// #endif
				let that = this
				that.time = setInterval(function() {
					that.getNewOrder()
				},10000)
			} else {
				this.isLogin = true
				this.userName = '匿名'
				this.browse = 0
				this.fans = 0
				this.follow = 0
				this.visitor = 0
				this.avatar = '../../static/logo.png'
			}
		},
		methods: {
			getNewOrder() {
				let data = {
					page: 1,
					limit: 100,
					state: 51
				}
				if (this.isLogin) {return;}
				this.$Request.getT('/app/message/selectMessageByUserIds', data).then(res => {
					if (res.code == 0) {
						if (res.data.totalCount > 0) {
							this.aplayAudios()
						}
					} else {
						if(res.code == 401){
							this.isLogin = true
							this.userId = '';
						}else{
							this.$queue.showToast(res.msg);
						}
					}
				});
			},
			// 新订单语音播放
			aplayAudios() {
				console.log('语音提示')
				const innerAudioContext = uni.createInnerAudioContext();
				innerAudioContext.autoplay = true;
				innerAudioContext.src = 'https://bcdhub.oss-cn-beijing.aliyuncs.com/audio/order.mp3';
				innerAudioContext.onPlay(() => {
					console.log('开始播放');
				});
				innerAudioContext.onError((res) => {
					console.log(res.errMsg);
					console.log(res.errCode);
				});
			},
			saveImgs(imgs) {
				let imgArr = [];
				imgArr.push(imgs);
				// //预览图片
				uni.previewImage({
					urls: imgArr,
					current: 0
				});
			},
			stateSave() {
				this.$Request.postT('/app/artificer/updateArtificer').then(res => {
					if (res.code == 0) {
						this.getArtificer();
						this.$queue.showToast('切换成功！')
					} else {
						this.$queue.showToast(res.msg);
					}
				});
			},
			// 取消订单
			cancelOrder(e) {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认取消并删除订单？',
					success: function(res) {
						if (res.confirm) {
							let data = {
								ordersId: e.ordersId,
							}
							that.$queue.showLoading('提交中...')
							that.$Request.post('/app/artificer/deleteOrders', data).then(res => {
								uni.hideLoading();
								if (res.code == 0) {
									that.getJinRiOrder();
								} else {
									that.$queue.showToast(res.msg);
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			// 完成订单
			cancel(e) {
				let that = this
				uni.showModal({
					title: '提示',
					content: '如果服务未完成点击完成订单会遭到平台违规处理，请确认服务是否完毕?',
					success: function(res) {
						if (res.confirm) {
							let data = {
								ordersId: e.ordersId,
								accomplishLongitude: that.longitude,
								accomplishLatitude: that.latitude
							}
							that.$queue.showLoading('提交中...')
							that.$Request.post('/app/artificer/accomplishOrders', data).then(res => {
								uni.hideLoading();
								if (res.code == 0) {
									that.getJinRiOrder();
								} else {
									that.$queue.showToast(res.msg);
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			timeFormat(param) {
				return param < 10 ? '0' + param : param;
			},
			getJinRiOrder() {
				let data = {
					type: 1,
					page: 1,
					limit: 10,
					startTime: '',
					endTime: ''
				}
				this.$Request.getT('/app/artificer/selectTodayOrder', data).then(res => {
					if (res.code == 0) {
						this.goods = [];
						res.data.list.forEach(d => {
							if (d.status == 6 && d.endTime) {
								let data = {}
								data.day = 0;
								data.hour = 0;
								data.minute = 0;
								data.second = 0;
								var now = new Date().getTime();
								var endDate = new Date(d.endTime).getTime();
								let time = (endDate - now) / 1000;
								data.day = this.timeFormat(parseInt(time / (60 * 60 * 24)));
								data.hour = this.timeFormat(parseInt(time % (60 * 60 * 24) / 3600));
								data.minute = this.timeFormat(parseInt(time % (60 * 60 * 24) % 3600 / 60));
								data.second = this.timeFormat(parseInt(time % (60 * 60 * 24) % 3600 % 60));
								d.endTime = data;
							}
							this.goods.push(d);
						});
					}

				})
			},
			getcity() {
				let that = this
				uni.getLocation({
					type: 'wgs84',
					success: function(res) {
						console.log('当前位置的经度：' + res.longitude);
						console.log('当前位置的纬度：' + res.latitude);
						that.latitude = res.latitude
						that.longitude = res.longitude
						that.getcitys()
					}
				});
			},
			getcitys() {
				this.$Request.get('/app/Login/selectCity?lat=' + this.latitude + '&lng=' + this.longitude).then(res => {
					if (res.code == 0) {
						this.city = res.data.city ? res.data.city : '未知'
						// uni.setStorageSync('city', res.data.city)
						// let data = {
						// 	num: 1,
						// 	size: 10
						// }
						// this.getData(data)
					}
				});
			},
			//上线开关
			bindopen() {
				let bzjCheck = this.$queue.getData("bzjCheck");
				if (this.isCashDeposit == 0 && bzjCheck != '否') {
					uni.showModal({
						title: '提示',
						content: '请先去缴纳保证金',
						success: function(res) {
							if (res.confirm) {
								uni.navigateTo({
									url: '/my/publish/money'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				} else {
					let data = {
						longitude: this.longitude,
						latitude: this.latitude,
						// status: this.status,
						city: this.city
					}
					this.$Request.post("/app/artificer/updateArtificer", data).then(res => {
						if (res.code == 0) {
							this.getArtificer()
							this.getUserInfo()
						} else {
							// uni.showToast({
							// 	title: res.msg,
							// 	icon: 'none'
							// })
							uni.showModal({
								title: '提示',
								content: res.msg,
								success: function(res) {
									if (res.confirm) {
										uni.navigateTo({
											url: '/my/publish/money'
										})
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});
						}
					})
				}

			},
			//获取技师的信息
			getArtificer() {
				this.$Request.getT("/app/artificer/selectArtificer").then(res => {
					if (res.code == 0) {
						uni.setStorageSync("isTruestatus", res.data.status)
						if (res.data) {
							if (res.data.status == 1) {
								this.isTrue = true
							} else if (res.data.status == 2) {
								this.isTrue = false
							}
						} else {
							this.isTrue = false
						}
						uni.setStorageSync('artificerId', res.data.artificerId)
					}
				});
			},
			//获取用户发布
			getFb() {

				this.$Request.get("/app/artificer/selectArtificerIndex").then(res => {
					if (res.code == 0) {
						this.sumMoney = res.data.sumMoney //总收益
						this.putaway = res.data.putaway //上架中
						this.soldOut = res.data.soldOut //下架中
						this.countOrderNum = res.data.countOrderNum //总销量
						this.countTakingByUserId = res.data.countTakingByUserId //用户评价
						this.orderMoney = res.data.orderMoney //订单收入
						this.countOrder = res.data.countOrder //总订单数
						this.sumRefund = res.data.sumRefund //退款金额
						this.countByUserId = res.data.countByUserId //访客人数
						this.countOrderIng = res.data.countOrderIng //进行中
						this.countOrderEnd = res.data.countOrderEnd //已完成
						this.countOrderAppraise = res.data.countOrderJin //进行中
					}
				})
			},

			goDetail(index) {
				if (index == 1) {
					uni.switchTab({
						url: '/pages/order/index'
					})
				}
				if (index == 2) {
					uni.navigateTo({
						url: '/my/publish/index'
					})
				}
			},
			bindFb() {
				let userId = uni.getStorageSync('userId')
				let renzheng = uni.getStorageSync('renzheng')
				if (userId) {
					if (renzheng == 2) {
						uni.navigateTo({
							url: '/my/publish/index'
						})
					} else {
						uni.showModal({
							title: '提示',
							content: '您还未实名认证,请先认证',
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
									uni.navigateTo({
										url: '/my/renzheng/index'
									})
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
					}

				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/public/login'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			goNavs(e, name) {
				console.log(e)
				if (this.userId) {
					let renzheng = uni.getStorageSync('renzheng')
					if (renzheng == 2) {
						let bzjCheck = this.$queue.getData("bzjCheck");
						if (bzjCheck != '否') {
							if (this.isCashDeposit == 0) {
								uni.showModal({
									title: '提示',
									content: '请先去缴纳保证金',
									success: function(res) {
										if (res.confirm) {
											uni.navigateTo({
												url: '/my/publish/money'
											})
										} else if (res.cancel) {
											console.log('用户点击取消');
										}
									}
								});
							} else {
								uni.navigateTo({
									url: e,
								})
							}
						} else {
							uni.navigateTo({
								url: e,
							})
						}
					} else {
						uni.showModal({
							title: '提示',
							content: '您还未实名认证,请先认证',
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
									uni.navigateTo({
										url: '/my/renzheng/rzType'
									})
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
					}
				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/public/login'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			goNav(e, name) {
				console.log(e)
				if (this.userId) {
					uni.navigateTo({
						url: e
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/public/login'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			getUserInfo() {
				this.$Request.get("/app/user/selectUserById").then(res => {
					if (res.code == 0) {
						this.userName = res.data.userName
						this.invitationCode = res.data.invitationCode
						this.avatar = res.data.avatar ? res.data.avatar : '../../static/logo.png'
						this.isAuthentication = res.data.isAuthentication
						this.isCashDeposit = res.data.isCashDeposit
						uni.setStorageSync('avatar', res.data.avatar)
						uni.setStorageSync('userName', res.data.userName)
						uni.setStorageSync('invitationCode', res.data.invitationCode)
						// uni.setStorageSync('zhiFuBao', res.data.zhiFuBao)
						// uni.setStorageSync('zhiFuBaoName', res.data.zhiFuBaoName)

						if (res.data.isAuthentication == 0 || res.data.isAuthentication == null) {
							this.renzheng = 0
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 1) {
							this.renzheng = 1
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 2) {
							this.renzheng = 2
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 3) {
							this.renzheng = 3
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 4) {
							this.renzheng = 4
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 5) {
							this.renzheng = 5
							uni.setStorageSync("renzheng", this.renzheng)
						} else if (res.data.isAuthentication == 6) {
							this.renzheng = 6
							uni.setStorageSync("renzheng", this.renzheng)
						}

					}
				});
			},
			goLogin(e) {
				uni.navigateTo({
					url: e
				})
			},
			// 开启订阅消息
			openMsg() {
				console.log('订阅消息')
				var that = this
				uni.getSetting({
					withSubscriptions: true, //是否获取用户订阅消息的订阅状态，默认false不返回
					success(ret) {
						console.log(ret.subscriptionsSetting, '------------------')
						// if (ret.subscriptionsSetting.itemSettings && Object.keys(ret.subscriptionsSetting.itemSettings).length == 2) {
						if (ret.subscriptionsSetting.itemSettings) {
							uni.setStorageSync('sendMsg', true)
							uni.openSetting({ // 打开设置页 
								success(rea) {
									console.log(rea.authSetting)
								}
							});
						} else { // 用户没有点击“总是保持以上，不再询问”则每次都会调起订阅消息
							console.log(99999)
							uni.setStorageSync('sendMsg', false)
							uni.showModal({
								title: '提示',
								content: '为了更好的体验,请绑定消息推送',
								confirmText: '确定',
								cancelText: '取消',
								success: function(res) {
									if (res.confirm) {
										wx.requestSubscribeMessage({
											tmplIds: that.arr,
											success(re) {
												console.log(JSON.stringify(re),
													'++++++++++++++')
												var datas = JSON.stringify(re);
												if (datas.indexOf("accept") != -1) {
													console.log(re)
													// uni.setStorageSync('sendMsg', true)
												}
											},
											fail: (res) => {
												console.log(res)
											}
										})
										// uni.setStorageSync('sendMsg', true)
										console.log('确认')
										that.showModal = false
									} else if (res.cancel) {
										console.log('取消')
										// uni.setStorageSync('sendMsg', false)
										that.showModal = true
									}
								}
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.home-page {
		background: linear-gradient( 182deg, #F2F9F7 0%, #F6F6F6 100%);
		min-height: 100vh;
		padding: 60rpx 32rpx 20rpx;
		.userName{
			font-weight: bold;
			font-size: 32rpx;
			color: #222222;
		}
		.labe {
			width: 134rpx;
			height: 40rpx;
			background: #DCFFF2;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin-left: 20rpx;
			font-size: 24rpx;
			color: #222222;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: 400;
			.yuan {
				width: 10rpx;
				height: 10rpx;
				background: #1EDA94;
				border-radius: 50%;
				margin-right: 8rpx;
			}
		}
		
		.box{
			display: flex;
			padding: 28rpx 0;
			margin-top: 20rpx;
			.label-item{
				flex: 1;
				text-align: center;
				.number{
					font-weight: bold;
					font-size: 36rpx;
					color: #222222;
				}
				.label{
					font-size: 24rpx;
					color: #222222;
					margin-top: 20rpx;
				}
			}
		}
		
			
		.box-title{
			font-weight: bold;
			font-size: 32rpx;
			color: #222222;
			padding: 24rpx 0;
		}
		
		.guanlibox {
			display: flex;
			justify-content: space-between;
			.item{
				width: 216rpx;
				height: 170rpx;
				background: linear-gradient( 180deg, #DFECFF 0%, #FFFFFF 100%);
				border-radius: 32rpx 32rpx 32rpx 32rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				.icon-box{
					display: flex;
					.icon{
						width: 40rpx;
						height: 40rpx;
					}
					.label{
						font-size: 28rpx;
						color: #222222;
						margin-left: 12rpx;
					}
				}
				.number{
					font-weight: bold;
					font-size: 36rpx;
					color: #222222;
					margin-top: 24rpx;
				}
			}
			
			.item.item2{
				background: linear-gradient( 180deg, #FFF0E8 0%, #FFFFFF 100%);
			}
			.item.item3{
				background: linear-gradient( 180deg, #DCFFF2 0%, #FFFFFF 100%);
			}
		}
		
	}

	.xian {
		width: 100%;
		height: 1rpx;
		border: 1rpx solid #f8f8f8;
		margin-top: 20rpx;
	}

	.pintuan_syrs {
		color: #999999;
		font-size: 20upx;
		margin: 20rpx 20rpx 0rpx;
		display: flex;
		padding-right: 18upx;
	}



	.box1 {
		background: #FFFFFF;
		border-radius: 24rpx;
		padding: 30rpx;
		margin-top: 30rpx;
	}

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

	

	
</style>