<template>
	<view class="my">
		<view class="tops">
			<view class="title">
				我的
			</view>
			<view class="my-header">
				<img class="my-img" :src="wxImg ? wxImg :'https://www.jiubaotongxue.love/image/demo32.png'" alt="" @click="logins" />
				<view class="header-box" @click="logins">
					<view class="txt">
						<text>{{wxname ? wxname :'元芳'}}</text>
						<img class="txt-img" src="https://www.jiubaotongxue.love/image/demo33.png" alt="" />
					</view>
					<view class="tel">
						{{phoneNum ? phoneNum :''}}
					</view>
				</view>
				<view class="tongbu" @click="wxClose=1">
					
					<img class="i" src="https://www.jiubaotongxue.love/image/shua1.png" alt="" />同步资料
				</view>
			</view>
			<view class="my-header-flex" @click="secondaryCard">
				<view class="flex-header">
					<text class="t">{{Information.card}}</text>
					<text class="b">洗车卡</text>
				</view>
				<view class="flex-header" @click="getY">
					<text class="t">{{Information.coupon}}</text>
					<text class="b">券</text>
				</view>
				<view class="flex-header" @click="getInteGral">
					<text class="t">{{Information.points}}</text>
					<text class="b">积分</text>
				</view>
			</view>
			<view class="vip" :class="{vipActive:Information.vip===0,vipActives:Information.vip===1}">
				<view class="up">
					当前等级
				</view>
				<view class="vipBox">
					<view class="vipBox-left">
						<view class="top-img" v-if="Information.vip===0">
							<img class="img-l" src="https://www.jiubaotongxue.love/image/vip1.png" alt="" />
							<img class="img-r" src="https://www.jiubaotongxue.love/image/vip2.png" alt="" />
						</view>
						<view class="top-img" v-if="Information.vip===1">
							<img class="img-l" src="https://www.jiubaotongxue.love/image/vip11.png" alt="" />
							<img class="img-r" src="https://www.jiubaotongxue.love/image/vip22.png" alt="" />
						</view>
						<view class="txts">
							有效期：365天
						</view>
						<view class="txta">
							NO:{{Information.uid}}
						</view>
					</view>
					<img class="vipBox-right" src="https://www.jiubaotongxue.love/image/demo36.png" alt="" />

				</view>
			</view>
		</view>
		<view class="kongs">

		</view>
		<view class="neirong">
			<view class="neirong-title">
				服务
			</view>
			<view class="flex-car" @click="goOrderForm">
				<img class="flex-car-img" src="https://www.jiubaotongxue.love/image/flex1.png" alt="" />
				<text class="car-text">洗车订单</text>
			</view>
			<view class="flex-car" @click="secondaryCard">
				<img class="flex-car-img" src="https://www.jiubaotongxue.love/image/flex2.png" alt="" />
				<text class="car-text">洗车次卡</text>
			</view>
			<view class="flex-car" @click="balance">
				<img class="flex-car-img" src="https://www.jiubaotongxue.love/image/flex3.png" alt="" />
				<text class="car-text">我的余额</text>
			</view>
			<view class="flex-car" @click="getY">
				<img class="flex-car-img" src="https://www.jiubaotongxue.love/image/flex4.png" alt="" />
				<text class="car-text">我的卡券</text>
			</view>
		</view>
		<view class="neirong">
			<view class="neirong-title">
				工具
			</view>
			<view class="flex-car" @click="goGuanyu">
				<img class="flex-car-img" src="https://www.jiubaotongxue.love/image/flex5.png" alt="" />
				<text class="car-text">关于我们</text>
			</view>
			<view class="flex-car" @click="goYijian">
				<img class="flex-car-img" src="https://www.jiubaotongxue.love/image/flex6.png" alt="" />
				<text class="car-text">意见反馈</text>
			</view>
			<view class="flex-car" @click="hujiao=1">
				<img class="flex-car-img" src="https://www.jiubaotongxue.love/image/flex7.png" alt="" />
				<text class="car-text">联系客服</text>
			</view>
		</view>



		<view class="my-shop" @click="shop">

		</view>
		<view class="ding">

		</view>
	</view>
	<view class="gets" v-if="wxClose===1">
		<form @submit="suBmit" name="id">
			<view class="bgn">

				<view class="title">
					同步微信信息
				</view>
				<img class="bgnImg" :src="wxImg ? wxImg :'https://www.jiubaotongxue.love/image/demo32.png'" />
				<view class="inputs">
					<text><!-- 昵称 --></text> <input class="input" type="nickname" name="input" placeholder="获取昵称">
				</view>
				<button class="getImgs" open-type="chooseAvatar" @chooseavatar="chooseavatar">获取头像</button>
				<view class="btnView">
					<view class="left-btnView" @click="getClose">
						取消
					</view>
					<button class="left-btnViews" form-type="submit">
						确定
					</button>
				</view>
			</view>
		</form>

	</view>
	<view class="hujiao" v-if="hujiao===1">
		<view class="windows-hujiao">
			<img class="i" src="https://www.jiubaotongxue.love/image/demo76.png" alt="" />
			<view class="ke">
				客服电话
			</view>
			<view class="ke1">
				176-0532-6897
			</view>
			<view class="ke3">
				<button class="lefts" @tap="hujiao=0">取消</button><button class="rights" @click="dianhua">立即呼叫</button>
			</view>
			<view class="ke4">
				为了保证服务质量，您的通话可能会被录音
			</view>
		</view>
	</view>

</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad,
		onShow
	} from "@dcloudio/uni-app"
	import {
		my
	} from '../../stor/my/my.js'
	import {
		storeToRefs
	} from 'pinia';
	const mys = my()
	const {
		Information
	} = storeToRefs(mys)
	const isshows = ref(2)
	const wxClose = ref(0)
	const wxname = ref(null)
	const wxImg = ref('https://www.jiubaotongxue.love/image/tin.jpg')
	const oldImg = ref(null)
	const hujiao = ref(0)
	const phoneNum = ref()
	const goOrderForm = () => {
		uni.navigateTo({
			url: "/pages/orderForm/orderForm"
		})
	}
	const secondaryCard = () => {
		uni.navigateTo({
			url: "/pages/secondaryCard/secondaryCard"
		})
	}

	const Coupons = () => {
		uni.navigateTo({
			url: "/pages/Coupons/Coupons"
		})
	}

	const titles = ref('我的信息')
	const color = ref('#2264dc')
	onLoad(() => {
		wxname.value = uni.getStorageSync('wxname')
		wxImg.value = uni.getStorageSync('wxImg')
		titles.value = '我的信息'
		color.value = '#2264dc'
		if (uni.getStorageSync('phoneNumber')) {
			phoneNum.value = uni.getStorageSync('phoneNumber')
			console.log(phoneNum.value);
			phoneNum.value = phoneNum.value.toString()
			const prefix = phoneNum.value.slice(0, 3);
			const suffix = phoneNum.value.slice(3 + 5);
			phoneNum.value = prefix + '*****' + suffix;

			console.log(phoneNum.value);
		}else{
			uni.navigateTo({
				url:"/pages/login/login"
			})
		}
		// isUser()
	})
	onShow(() => {
		isUser()
	})
	//检查登录状态
	const isUser = () => {
		if (uni.getStorageSync("phoneNumber")) {
			console.log("登录状态存在");
			mys.getInformation(uni.getStorageSync("phoneNumber"))
		}
	}

	const shop = () => {
		uni.showToast({
			icon: "none",
			title: "暂未开通"
		})
	}
	const logins = () => {
		uni.navigateTo({
			url: "/pages/login/login"
		})
	}
	const tong = () => {
		wxClose.value = 1
	}
	const chooseavatar = (e) => {
		oldImg.value = wxImg.value
		wxImg.value = e.detail.avatarUrl
		uni.setStorageSync('wxImg', oldImg.value)
	}
	const getClose = () => {
		wxClose.value = 0
		wxImg.value = oldImg.value
		console.log(oldImg.value)
		uni.setStorageSync('wxImg', oldImg.value)
	}
	const suBmit = (e) => {
		uni.setStorageSync('wxname', e.detail.value.input)
		uni.setStorageSync('wxImg', wxImg.value)
		wxClose.value = 0
	}
	const GOji = () => {
		uni.navigateTo({
			url: "/pages/myIntegral/myIntegral"
		})
	}
	const balance = () => {
		uni.navigateTo({
			url: "/pages/myBalance/myBalance"
		})
	}
	const huiyuan = () => {
		uni.navigateTo({
			url: "/pages/huiyuan/huiyuan"
		})
	}
	const getY = () => {
		uni.navigateTo({
			url: "/pages/Coupons/Coupons"
		})
	}
	const getInteGral = () => {
		uni.navigateTo({
			url: "/pages/myIntegral/myIntegral"
		})
	}
	const goGuanyu = () => {
		uni.navigateTo({
			url: "/pages/guanyuMy/guanyuMy"
		})
	}

	const goYijian = () => {
		uni.navigateTo({
			url: "/pages/yijian/yijian"
		})
	}
	const dianhua = ()=>{
		uni.makePhoneCall({
			phoneNumber:'17605326897'
		})
	}
</script>

<style lang="scss">
	.my {
		width: 100%;
		height: 100%;
		position: absolute;
		background-color: #f2f2f2;

		.tops {
			width: 100%;
			height: 716rpx;
			background-image: url("https://www.jiubaotongxue.love/image/demo31.png");

			.title {
				width: 100%;
				height: 180rpx;
				box-sizing: border-box;
				text-align: center;
				font-size: 36rpx;
				line-height: 200rpx;
				color: white;
				padding-top: 29rpx;
			}

			.my-header {
				width: 100%;
				height: 132rpx;
				position: relative;
				display: flex;
				align-items: center;

				.my-img {
					width: 132rpx;
					height: 132rpx;
					margin-left: 20rpx;
					border-radius: 50%;

				}

				.header-box {
					width: 70%;
					height: 132rpx;
					margin-left: 20rpx;
					margin-top: 40rpx;

					.txt {
						width: 100%;
						height: 48rpx;
						line-height: 48rpx;
						font-size: 34rpx;
						color: white;
						display: flex;
						align-items: center;

						.txt-img {
							width: 82rpx;
							height: 30rpx;
							margin-left: 20rpx;
						}
					}

					.tel {
						width: 100%;
						font-size: 26rpx;
						color: white;
						margin-top: 10rpx;
					}
				}

				.tongbu {
					width: 136rpx;
					height: 46rpx;
					position: absolute;
					right: 30rpx;
					font-size: 22rpx;
					color: #169bd5;
					background: url("https://www.jiubaotongxue.love/image/shua2.png");
					text-align: center;
					line-height: 46rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 10rpx;

					.i {
						width: 24rpx;
						height: 24rpx;
					}
				}
			}

			.my-header-flex {
				width: 100%;
				height: 100rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20rpx;

				.flex-header {
					width: 30%;
					height: 100rpx;
					text-align: center;
					font-size: 34rpx;
					color: white;

					.t {
						display: block;

					}

					.b {
						display: block;
						font-size: 24rpx;
					}
				}
			}

			.vip {
				width: 690rpx;
				height: 320rpx;
				position: relative;
				margin-left: 50%;
				transform: translateX(-50%);
				background-size: 100% 100%;
				background-repeat: no-repeat;
				background-image: url("https://www.jiubaotongxue.love/image/demo34.png");
				.up {
					width: 120rpx;
					height: 40rpx;
					background: linear-gradient(99deg, #EAFBFF 0%, #AAEAFF 100%);
					font-size: 22rpx;
					text-align: center;
					line-height: 40rpx;
					border-radius: 20rpx 0rpx 20rpx 0rpx;
				}

				.vipBox {
					width: 100%;
					height: 200rpx;
					margin-top: 22rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.vipBox-left {
						width: 60%;
						height: 170rpx;

						.top-img {
							margin-left: 30rpx;
							height: 50rpx;
							display: flex;

							.img-l {
								width: 40rpx;
								height: 44rpx;
							}

							.img-r {
								width: 220rpx;
								height: 44rpx;
								margin-left: 10rpx;
							}
						}

						.txts {
							margin-top: 30rpx;
							font-size: 24rpx;
							margin-left: 30rpx;
							color: white;
							opacity: 0.6;
						}

						.txta {
							margin-top: 30rpx;
							font-size: 24rpx;
							margin-left: 30rpx;
							color: white;
							opacity: 0.6;
						}

					}

					.vipBox-right {
						width: 240rpx;
						height: 246rpx;

						.vipBox-right-i {
							width: 100%;
							height: 100%;
						}
					}
				}
			}

			.vipActive {
				background-image: url("https://www.jiubaotongxue.love/image/demo34.png");
			}

			.vipActives {
				background-image: url("https://www.jiubaotongxue.love/image/demo39.png");
			}
		}

		.kongs {
			width: 100%;
			height: 60rpx;
			position: absolute;
			z-index: 9;
			margin-top: 0rpx;
			background-color: #f2f2f2;
		}

		.neirong {
			width: 93%;
			// height: 130rpx;
			position: relative;
			margin-top: 25rpx;
			background-color: #fff;
			margin-left: 50%;
			transform: translateX(-50%);
			display: flex;
			flex-wrap: wrap;
			align-content: flex-start;
			z-index: 10;
			border-radius: 20rpx 20rpx 20rpx 20rpx;

			.neirong-title {
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
				box-sizing: border-box;
				padding-left: 30rpx;
				font-weight: 700;
			}

			.flex-car {
				width: 25%;
				height: 120rpx;
				margin-top: 20rpx;

				.flex-car-img {
					width: 50rpx;
					height: 50rpx;
					// background-color: sienna;
					margin-left: 50%;
					transform: translateX(-50%);

				}

				.car-text {
					display: block;
					font-size: 25rpx;
					width: 100%;
					text-align: center;
				}
			}
		}

		.my-shop {
			width: 690rpx;
			height: 306rpx;
			margin-top: 20rpx;
			background-color: #fff;
			margin-left: 50%;
			transform: translateX(-50%);
			background-image: url("https://www.jiubaotongxue.love/image/vip3.png");
			background-size: 100% 100%;
		}

		.ding {
			width: 100%;
			height: 100rpx;
			background-color: #f2f2f2;
		}
	}

	.gets {
		width: 100%;
		height: 100%;
		position: fixed;
		background-color: rgba(0, 0, 0, 0.8);
		z-index: 90;
		

		.bgn {
			width: 600rpx;
			// height: 700rpx;
			background-color: #fff;
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			border-radius: 20rpx;

			.title {
				width: 100%;
				height: 100rpx;
				text-align: center;
				line-height: 100rpx;
				font-size: 28rpx;
			}

			.bgnImg {
				width: 120rpx;
				height: 120rpx;
				margin-top: 30rpx;
				background-color: #cfcfcf;
				position: relative;
				margin-left: 50%;
				transform: translateX(-50%);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
			}

			.inputs {
				width: 100%;
				height: 80rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				border-top: 1rpx solid #ccc;
				// border-bottom: 1rpx solid #ccc;
				font-size: 26rpx;
				margin-top: 80rpx;

				.input {
					width: 500rpx;
					height: 30rpx;
					text-align: center;
					line-height: 30rpx;
				}

			}

			.getImgs {
				width: 100%;
				height: 80rpx;
				// margin-top: 20rpx;
				font-size: 26rpx;
				text-align: center;
				line-height: 80rpx;
				color: #999999;
				background: none;
				border: none;
				border-bottom: 1rpx solid #ccc;

			}

			.btnView {
				width: 100%;
				height: 80rpx;
				margin-top: 50rpx;
				display: flex;
				line-height: 80rpx;
				font-size: 28rpx;

				.left-btnView {
					width: 50%;
					height: 80rpx;
					text-align: center;
				}

				.left-btnViews {
					width: 50%;
					height: 80rpx;
					text-align: center;
					background-color: #169bd5;
					color: white;
					border-radius: 0rpx 0rpx 0rpx 0rpx;
				}
			}
		}
	}

	.hujiao {
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0rpx;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 99;

		.windows-hujiao {
			width: 630rpx;
			height: 614rpx;
			background: #FFFFFF;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			border-radius: 20rpx 20rpx 20rpx 20rpx;

			.i {
				width: 320rpx;
				height: 258rpx;
				margin-top: 40rpx;
				transform: translateX(-50%);
				margin-left: 50%;
			}

			.ke {
				width: 100%;
				text-align: center;
				height: 36rpx;
				font-size: 26rpx;
				color: #1276F7;
				line-height: 36rpx;
				margin-top: 24rpx;
			}

			.ke1 {
				width: 100%;
				text-align: center;
				height: 66rpx;
				font-weight: 600;
				font-size: 48rpx;
				color: #222222;
				line-height: 66rpx;
				margin-top: 16rpx;
			}

			.ke3 {
				width: 90%;
				height: 68rpx;
				transform: translateX(-50%);
				margin-left: 50%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 24rpx;

				.lefts {
					width: 266rpx;
					height: 68rpx;
					font-size: 26rpx;
					background-color: #ffffff;
					border: 1rpx solid #eee;
				}

				.rights {
					width: 266rpx;
					height: 68rpx;
					font-size: 26rpx;
					background: linear-gradient(270deg, #25A5FF 0%, #0177FF 100%);
					color: white;
				}
			}

			.ke4 {
				width: 100%;
				height: 32rpx;
				font-size: 22rpx;
				color: #666666;
				line-height: 32rpx;
				text-align: center;
				margin-top: 20rpx;
			}
		}
	}
</style>