<template>
	<view>
		<view>
			<view class=" u-flex padding " style="position: relative;">
				<image style="position: absolute;top: 42rpx;right: 32rpx;width: 48rpx;height: 48rpx;"
					src="../../static/images/index/setting.png" mode="" @click="goNav('/my/setting/index')"></image>
				<view class="u-m-r-10">
					<image :src="avatar" style="width: 100rpx;height: 100rpx;border-radius: 100rpx;"
						@click="goNav('/pages/my/userinfo')"></image>
					<view style="position: absolute; top: 6rpx; left: 90rpx;z-index: 9;"
						v-if="isVip&&XCXIsSelect !='否'">
						<image src="../../static/images/vp.png" style="width: 25px;height:24px;"></image>
					</view>

				</view>
				<view class="u-flex-1 u-m-l-10" v-if="!isLogin">
					<view>
						<view
							style="display: flex;padding-right: 120rpx; align-items: center; justify-content: space-between;">
							<view class="u-font-18 margin-left-sm margin-top-xs text-bold"
								style="font-weight: 800;font-size: 32rpx;color: #222222">{{userName}}</view>
							<view style="display: flex;align-items: center;" class="box-jishi" @click="handleTop">
								技师端入口
								<image src="/static/images/qiehuan.png" style="width:18rpx ;height: 18rpx;"></image>
							</view>
						</view>
						<view class="u-font-15 margin-left-sm margin-top-xs" style="font-size: 28rpx;color: #AAAAAA;">
							ID:{{invitationCode}}</view>
					</view>
				</view>
				<view  v-else style="display: flex;">
					<view class="text-xl u-p-l-20 text-bold" @click="goLogin('/pages/public/login')">
						登录
					</view>
					<view style="display: flex;align-items: center;margin-left: 120rpx;" class="box-jishi" @click="handleTop">
						技师端入口
						<image src="/static/images/qiehuan.png" style="width:18rpx ;height: 18rpx;"></image>
					</view>
				</view>
			</view>
			<view class="padding-lr margin-lr"
				style="background: linear-gradient( 118deg, #525264 0%, #1D233C 100%);;border-radius: 32rpx 32rpx 0px 0px;;height: 178rpx;position: relative;"
				v-if="XCXIsSelect != '否' && hyCheck != '否'">
				<!-- <image src="../../static/images/my/bg.png" style="width: 100%;height: 110rpx;" mode=""></image> -->
				<image src="@/static/images/my/huiyuan.png"
					style="width: 80rpx;height: 80rpx;position: absolute;top: -40rpx;right: 0;"></image>
				<view class="flex justify-between align-center" style="padding-top: 48rpx;">


					<view v-if="!isVip" class="vipttl flex align-center">
						<image src="@/static/images/my/vip-icon.png"
							style="width: 30rpx;height: 30rpx;margin-right: 16rpx;"></image>开通会员立享会员折扣价
					</view>
					<view v-if="isVip" class="vipttl">会员中心</view>
					<!-- <view class="flex-sub text-26 margin-left-xs" style="color: #8A6931;">会员可享贵族福利</view> -->
					<view v-if="!isVip" class="btn-bg" @click="goNav('/my/vip/index')">立即开通
					</view>
					<view v-if="isVip" class="btn-bg" @click="goNav('/my/vip/index')">会员特权
					</view>
				</view>
			</view>
		</view>
		<view
			style="margin: -30rpx 32rpx 30rpx;background: #fff;border-radius: 32rpx;padding: 28rpx;position: relative;z-index: 9;">
			<view class="title">我的订单</view>
			<view class="flex justify-around text-center">
				<view class=" padding-tb" @click="goNavOrder(1)">
					<image src="../../static/images/my/order1.png" style="width:60upx;height: 60upx;" mode="">
					</image>
					<view class="text-df" style="line-height: 50upx;">待付款</view>
				</view>
				<!-- 	<view class=" padding-tb" @click="goNavOrder(2)">
					<image src="../../static/images/my/order6.png" style="width: 60upx;height: 60upx;" mode="">
					</image>
					<view class="text-df" style="line-height: 50upx;">待确认</view>
				</view> -->
				<view class=" padding-tb" @click="goNavOrder(2)">
					<image src="../../static/images/my/order2.png" style="width: 60upx;height: 60upx;" mode="">
					</image>
					<view class="text-df" style="line-height: 50upx;">待服务</view>
				</view>
				<view class=" padding-tb" @click="goNavOrder(6)">
					<image src="../../static/images/my/order3.png" style="width: 60upx;height: 60upx;" mode="">
					</image>
					<view class="text-df" style="line-height: 50upx;">待评价</view>
				</view>
				<view class=" padding-tb" @click="goNavOrder(8)">
					<image src="../../static/images/my/order4.png" style="width: 60upx;height: 60upx;" mode="">
					</image>
					<view class="text-df" style="line-height: 50upx;">已完成</view>
				</view>
			</view>
		</view>

		<image src="/static/image/icon_kefu.png" class="kefu_view" @click="goChat"></image>


		<view class="box">
			<view class="title" style="margin: 28rpx 0 0 28rpx;">推荐工具</view>
			<view class="flex text-center flex-wrap">
				<view class="padding-tb-sm" @click="goNav('/my/wallet/index')" v-if="XCXIsSelect != '否'"
					style="width: 25%;">
					<image src="../../static/images/my/money.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">我的钱包</view>
				</view>
				<view class="padding-tb-sm" @click="goNav('/my/gird/shoucang')" style="width: 25%;">
					<image src="../../static/images/my/shoucang.png" style="width: 60rpx;height: 60rpx;" mode="">
					</image>
					<view class="text-df" style="line-height: 50upx;">我的收藏</view>
				</view>
				<view class="padding-tb-sm" @click="goNav('/my/hongbao/youhuijuan')" v-if="XCXIsSelect != '否'"
					style="width: 25%;">
					<image src="../../static/images/my/youhuijuan.png" style="width: 60rpx;height: 60rpx;" mode="">
					</image>
					<view class="text-df" style="line-height: 50upx;">优惠券</view>
				</view>
				<view class="padding-tb-sm" @click="bindFb()" v-if="XCXIsSelect != '否'" style="width: 25%;">
					<image src="../../static/images/my/ruzhu.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">成为按摩师</view>
				</view>
				<!-- <view class="padding-tb-sm" @click="goChat" style="width: 25%;">
					<image src="../../static/images/my/kefu.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">在线客服</view>
				</view> -->
				<!-- <view class="padding-tb-sm" @click="goNav('/my/feedback/index')" style="width: 25%;">
					<image src="../../static/images/my/yijian.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">意见反馈</view>
				</view> -->
				<!-- <view class="padding-tb-sm" @click="goNav('/my/order/tousuList')" style="width: 25%;">
					<image src="../../static/images/my/mytousu.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">我的投诉</view>
				</view> -->
				<view v-if="isShop == 1" class="padding-tb-sm" @click="goNav('/my/gonghui/index')" style="width: 25%;">
					<image src="../../static/images/my/gonghui.png" style="width: 60rpx;height: 60rpx;"></image>
					<view class="text-df" style="line-height: 50upx;">我的商户</view>
				</view>
				<view class="padding-tb-sm" @click="goNav('/pages/my/myteam')" style="width: 25%;"
					v-if="isAgency == 1 && tgCheck != '否'">
					<image src="../../static/images/my/myteam.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">我的团队</view>
				</view>
				<view class="padding-tb-sm" @click="goNav('/pages/my/invitationUser')" style="width: 25%;">
					<image src="../../static/images/my/myyao.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">分享好友</view>
				</view>
				<view class="padding-tb-sm" @click="goNav('/pages/my/cooperation')" style="width: 25%;"
					v-if="isAgency != 1 && tgCheck != '否'">
					<image src="../../static/images/my/mydl.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">成为代理商</view>
				</view>


				<view class="padding-tb-sm" @click="goNav('/my/address/address')" style="width: 25%;">
					<image src="../../static/images/my/yijian.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">地址管理</view>
				</view>
				<view class="padding-tb-sm" @click="goNav('/my/help/feedbackIndex')" style="width: 25%;">
					<image src="../../static/images/my/help.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">帮助中心</view>
				</view>
				<!-- <view class="padding-tb-sm" @click="goNav('/my/setting/index')" style="width: 25%;">
					<image src="../../static/images/my/set.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">设置中心</view>
				</view> -->
				<!-- #ifndef H5 -->
				<view class="padding-tb-sm" @click="goNav('/pages/my/jinji')" style="width: 25%;">
					<image src="../../static/images/my/set1.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
					<view class="text-df" style="line-height: 50upx;">紧急求助</view>
				</view>
				<!-- #endif -->
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				isShop: 0,
				hyCheck: '否',
				tgCheck: '否',
				isAgency: 0,
				avatar: '../../static/logo.png',
				isLogin: true,
				userName: '匿名',
				browse: 0, //浏览数
				fans: 0, //粉丝数
				follow: 0, //关注数
				visitor: 0, //访客数
				userId: '',
				isVip: false,
				invitationCode: '', //邀请码
				list: [{
						image: '',
						title: '',
						url: ''
					}, {
						image: '',
						title: '我的收藏',
						url: ''
					}, {
						image: '',
						title: '',
						url: ''
					}, {
						image: '',
						title: '成为按摩师',
						url: ''
					}, {
						image: '',
						title: '联系客服',
						url: ''
					}, {
						image: '',
						title: '意见反馈',
						url: ''
					},
					// {
					// 	image: '',
					// 	title: '帮助中心',
					// 	url: ''
					// }, 
					{
						image: '',
						title: '设置中心',
						url: ''
					}, {
						image: '',
						title: '退出登录',
						url: ''
					}
				],
				renzheng: 0,
				XCXIsSelect: '否',
			}
		},
		onLoad() {
			this.XCXIsSelect = this.$queue.getData("XCXIsSelect");

		},
		onShow() {
			this.hyCheck = this.$queue.getData('hyCheck');
			this.tgCheck = this.$queue.getData('tgCheck');
			this.userId = uni.getStorageSync('userId')
			if (this.userId) {
				this.isLogin = false
				this.getUserInfo()

				this.getAmount()
				this.getIsVip()
			} else {
				this.isShop = 0;
				this.isAgency = 0;
				this.isLogin = true
				this.userName = '匿名'
				this.browse = 0
				this.fans = 0
				this.follow = 0
				this.visitor = 0
				this.avatar = '../../static/logo.png'
				this.isVip = false
			}

		},
		methods: {
			handleTop() {
				// window.location.href()
				//#ifdef H5
				window.open('https://user.dstapp.cn/', '_target')
				//#endif
			},
			goChat() {
				let kefu = this.$queue.getData('kefu'); // 用户端联系方式 1 手机号 2企业微信 
				let kefuPhone = this.$queue.getData('kefuPhone');
				if (kefu == 1) {
					uni.makePhoneCall({
						phoneNumber: kefuPhone //仅为示例
					});
				} else if (kefu == 3) {
					uni.navigateTo({
						url: '/my/setting/customer'
					});
				} else {
					// #ifdef MP-WEIXIN
					let that = this
					try {
						wx.openCustomerServiceChat({
							extInfo: {
								url: that.$queue.getData('kefuUrl')
							},
							corpId: that.$queue.getData('kefuAppId'),
							success(res) {},
							fail(res) {
								console.error(res)
							}
						})
					} catch (error) {
						console.error("catchcatch" + error)
						uni.showToast({
							title: '请更新至微信最新版本'
						});
					}
					// #endif
					// #ifndef MP-WEIXIN
					let url = this.$queue.getData('kefuUrl');
					if (url.indexOf('/pages/') !== -1 || url.indexOf('/my/') !== -1) {
						uni.navigateTo({
							url
						});
					} else {
						//#ifndef H5
						uni.navigateTo({
							url: '/pages/index/webView?url=' + url
						});
						//#endif
						//#ifdef H5
						window.location.href = url;
						//#endif
					}
					// #endif
				}
			},
			//退出登录
			TuiLogin() {
				let that = this
				if (that.userId) {
					uni.showModal({
						title: '提示',
						content: '确定退出登录吗？',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.removeStorageSync('userName')
								uni.removeStorageSync('avatar')
								uni.removeStorageSync('userId')
								uni.removeStorageSync('token')
								uni.removeStorageSync('phone')
								uni.removeStorageSync('zhiFuBaoName')
								uni.removeStorageSync('zhiFuBao')
								uni.removeStorageSync('invitationCode')
								uni.removeStorageSync('unionId')
								uni.removeStorageSync('openId')
								uni.removeStorageSync('isVIP')
								uni.showToast({
									title: '退出成功！',
									icon: 'none'
								})
								that.isLogin = true
								that.userName = '匿名'
								that.browse = 0
								that.fans = 0
								that.follow = 0
								that.visitor = 0
								that.isVip = false
								that.avatar = '../../static/logo.png'
								that.userId = uni.getStorageSync('userId')

							} 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('用户点击取消');
							}
						}
					})
				}


			},
			//成为按摩师  跳转商户端
			bindFb() {
				if (this.userId) {
					uni.navigateTo({
						url: '/pages/my/hehuo'
					});
				} 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('用户点击取消');
							}
						}
					})
				}
			},
			goNavOrder(index) {
				let token = this.$queue.getData('token');
				if (token) {
					this.$queue.setData('SelectIndex', index);
					uni.switchTab({
						url: '/pages/order/index'
					})
				} 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('用户点击取消');
							}
						}
					})
				}
			},
			goLogin(e) {
				uni.navigateTo({
					url: e
				})
			},
			getAmount() {
				this.$Request.get("/app/userBrowse/selectAmount").then(res => {
					if (res.code == 0) {
						this.browse = res.data.browse
						this.fans = res.data.fans
						this.follow = res.data.follow
						this.visitor = res.data.visitor
					}
				});
			},
			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.isAgency = res.data.isAgency ? res.data.isAgency : 0; //是否是推广员 1是 2否
						// uni.setStorageSync('isAuthentication', res.data.isAuthentication)
						this.isShop = res.data.isShop ? res.data.isShop : 0;
						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)
						}

					}
				});

				// #ifdef APP-PLUS
				let clientid = plus.push.getClientInfo().clientid;
				let sysPhone = 1;
				if (plus.os.name.toLowerCase() === 'android') {
					sysPhone = 1;
				} else {
					sysPhone = 2;
				}
				let userId = this.$queue.getData('userId');
				if (userId) {
					this.$Request.postT('/app/user/updateClientId?clientId=' + clientid + '&userId=' + userId +
						'&sysPhone=' + sysPhone).then(
						res => {});
				}
				//#endif
			},

			getIsVip() {
				this.$Request.get("/app/UserVip/isUserVip").then(res => {
					if (res.code == 0) {
						this.isVip = res.data
						uni.setStorageSync('isVIP', res.data)
					}
				});
			}

		}
	}
</script>

<style lang="scss" scoped>
	.box-jishi {
		background: linear-gradient(180deg, #FFFFFF 0%, #FFBACA 100%);
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		border: 1rpx solid #FF6E98;
		color: #FF6E98;
		padding: 8rpx 20rpx;

	}

	page {
		background: linear-gradient(180deg, #FFE5ED 0%, #F6F6F6 400rpx);
	}

	.text-df {
		font-size: 24rpx;
		color: #222222;
		margin-top: 14rpx;
	}

	.kefu_view {
		width: 100rpx;
		height: 100rpx;
		position: fixed;
		right: 30rpx;
		bottom: 200rpx;
	}

	.bg {
		background: #05C25C;
	}

	.title {
		font-size: 32rpx;
		font-weight: bold;
		color: #222222;
	}

	.box {
		background: #FFFFFF;
		color: #333333;
		margin: 30rpx 32rpx;
		border-radius: 32rpx;
		padding-top: 1rpx;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.btn-bg {
		width: 160rpx;
		height: 64rpx;
		line-height: 64rpx;
		text-align: center;
		background: linear-gradient(145deg, #FFEACE 0%, #FEC186 100%);
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		border: 2rpx solid rgba(0, 0, 0, 0);
		font-weight: bold;
		font-size: 28rpx;
		color: #BB5D1E;
	}

	.images {
		width: 18rpx;
		height: 30rpx;
	}

	.vipttl {
		font-weight: bold;
		font-size: 32rpx;
		color: #F0D4C1;
		font-family: PingFang SC, PingFang SC;
	}
</style>