<template>
	<view class="pageBgImg">
		<topNavbar title="人个中心"></topNavbar>
		<view class="pad">
			<view class="card">
				<view class="row">
					<view class="lab">手机号</view>
					<view class="val"> {{ hideMiddleDigits(vuex_userInfo.phone) }}  </view>
				</view>
			</view>
			
			<!-- <view class="card">
				<view class="row border">
					<view class="lab">我的驾校</view>
					<view class="val">江西海正驾校</view>
				</view>
				<view class="row border">
					<view class="lab">我的教练</view>
					<view class="val">xxx</view>
				</view>
				<view class="row border">
					<view class="lab">所学车型</view>
					<view class="val">xxx</view>
				</view>
				<view class="row">
					<view class="lab">报名时间</view>
					<view class="val">xxx</view>
				</view>
			</view> -->
			
			<view class="card">
				<view class="row"  @click="goPage(2)">
					<view class="lab">用户协议</view>
					<view class="val"><u-icon name="arrow-right" color="#999" size="18"></u-icon></view>
				</view>
			</view>
			<view class="card">
				<view class="row" @click="goPage(1)">
					<view class="lab">隐私政策</view>
					<view class="val"><u-icon name="arrow-right" color="#999" size="18"></u-icon></view>
				</view>
			</view>
			
			<view class="btnBox">
				<view class="logout" @click="loginOut">退出登录</view>
				<view class="logout cancel" @click="cancellationFn">注 销</view>
			</view>
			
			
		</view>
	</view>
</template>

<script>
	export default {
		
		
		methods: {
			hideMiddleDigits(phoneNumber) {
				if(!phoneNumber) return
			    // 判断是否为有效的电话号码
			    if (phoneNumber.length === 11) {
			        // 获取号码的前三位和后四位
			        const firstThreeDigits = phoneNumber.slice(0, 3);
			        const lastFourDigits = phoneNumber.slice(-4);
			
			        // 生成隐藏中间数字的字符串
			        const hiddenDigits = '*'.repeat(3);
			
			        // 拼接成最终的隐藏中间数字的电话号码
			        const hiddenPhoneNumber = firstThreeDigits + hiddenDigits + lastFourDigits;
			
			        return hiddenPhoneNumber;
			    } else {
			        // 如果不是有效的10位电话号码，可能需要进行错误处理
			        console.error('Invalid phone number format');
			        return phoneNumber;
			    }
			},
			loginOut() {
				let _this = this
				uni.showModal({
					content:'确定要退出登录吗？',
					success(val) {
						if(val.confirm) {
							_this.$store.commit('goLogin') 
						}
					}
				})
			},
			cancellationFn() {
				uni.showModal({
					content:'您的账号注销后将无法再登录该APP，并且账号注销后，各项信息将被清空且无法恢复，请谨慎使用此功能。如您还需要注销账号，请联系您所在驾校的管理后台的管理员，为您操作注销',
					success() {
						console.log('哈哈哈')
					}
				})
			},
			async goPage(type) {
				this.$goPage('/pages/login/privacyAgreement/privacyAgreement?type='+ type)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		padding: 6rpx;
		margin-bottom: 20rpx;
	}
	
	.row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 98rpx;
		font-size: 28rpx;
		padding:  0 30rpx;
		&.border {
			border-bottom: 2rpx solid #E8E9EC;
		}
	}
	.btnBox {
		// display: flex;
		// justify-content: center;
		// flex-direction: column;
		// width: 100%;
		// align-items: center;
		// margin: 188rpx 0;
		position: fixed;
		bottom: 20rpx;
		left: 0;
		padding: 0 30rpx;
		width: 100%;
	}
	.logout {
		width: 100%;
		height: 100rpx;
		background: #FFFFFF;
		border-radius: 8rpx;
		border: 2rpx solid #E8E9EC;
		font-size: 28rpx;
		color: #ADADAD;
		text-align: center;
		line-height: 100rpx;
		margin-top: 30rpx;
		&.cancel {
			background: none;
		}
	}
</style>