<template>
	<view class="pageBg">
		<view class="pad">
			<!-- <view class="avatarBox" @click="uploadTap">
				<view class="avatar">
					<image :src="avatarLink" mode=""></image>
				</view>
				<view class="phoneIcon">
					<image src="@/static/images/mineIcon/camera.png" mode=""></image>
				</view>
			</view> -->
			<view class="card">
				<view class="row">
					<view class="lab">手机号</view>
					<view class="val">{{ vuex_userInfo.phone }}</view>
				</view>
			</view>
			
			<view class="card" v-if="vuex_userInfo.schoolName">
				<view class="row border">
					<view class="lab">我的驾校</view>
					<view class="val">{{ vuex_userInfo.schoolName||'' }}</view>
				</view>
				<view class="row border">
					<view class="lab">我的教练</view>
					<view class="val">{{ vuex_userInfo.coachName||'' }}</view>
				</view>
				<view class="row border">
					<view class="lab">所学车型</view>
					<view class="val">{{ vuex_userInfo.trainType||'' }}</view>
				</view>
				<view class="row">
					<view class="lab">报名时间</view>
					<view class="val">{{ $u.timeFormat(vuex_userInfo.applyDate, 'yyyy-mm-dd hh:MM:ss')}}</view>
				</view>
			</view>
			
			<view class="card" v-if="vuex_userInfo.cardType>1" @click="$goPage('/pages/mineEntry/personaInfo/myInfo')">
				<view class="row">
					<view class="lab">个人信息</view>
					<view class="flex">
						<view class="val">查看</view>
						<view class="icon">
							<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
				</view>
			</view>
			
			<view class="card" v-if="vuex_userInfo.cardType==1">
				<view class="row">
					<view class="lab">实名认证</view>
					<view class="val">已完成</view>
				</view>
			</view>
			
			<!-- <view class="card" v-if="vuex_userInfo.cardType==1">
				<view class="row">
					<view class="lab">拍照&体检&面签</view>
					<view class="val">已完成</view>
				</view>
			</view> -->
			
			<!-- <view class="logout" @click="deleteTestClick" style="margin-top: 40rpx;">删除测试账号（开发用的）</view> -->
			
		</view>
		<view class="footerBtn">
			<view class="btnBg" @click="logOutFn">退出登录</view>
		</view>
	</view>
</template>

<script>
	import { logOut,deleteTest } from '@/config/api.js'
	export default {
		data() {
			return {
				avatarLink: ''
			}
		},
		onLoad() {
			uni.$on('uAvatarCropper', (res)=>{
				this.avatarLink = res
			})
		},
		methods: {
			 logOutFn() {
				 let _this = this
				uni.showModal({
					content: '确定要退出登录吗？',
					success: async function  (res) {
						if (res.confirm) {
							logOut().then(()=>{
								_this.$store.commit('goLogin')
							}).catch(()=>{
								_this.$store.commit('goLogin')
							})
							
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
			},
			async deleteTestClick() {
				const res = await deleteTest({phone: this.vuex_userInfo.phone})
				this.$store.commit('goLogin')
				console.log(res)
			},
			uploadTap() {
				// let studentId = uni.getStorageSync('studentId')
				// if(!studentId&&!this.havePay) return false
				const _this = this;
				uni.chooseImage({
					count: 1, // 默认9
					sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
					success: (res) => {
						let url = res.tempFilePaths[0];
						//  获取裁剪图片资源后，给data添加src属性及其值
						uni.navigateTo({
							url: '/pages/indexEntry/enroll/uploadAvatar/uAvatarCropper/uAvatarCropper?url=' + encodeURIComponent(url)
						})
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		padding: 6rpx;
		margin-bottom: 20rpx;
	}
	.pad {
		overflow: hidden;
	}
	.avatarBox {
		width: 175rpx;
		height: 175rpx;
		margin: 50rpx auto 50rpx auto;
		position: relative;
		.avatar {
			width: 100%;
			height: 100%;
			border-radius: 50%;
			overflow: hidden;
			background-color: #E8E9EC;
		}
		.phoneIcon {
			width: 46rpx;
			height: 46rpx;
			position: absolute;
			right: 0;
			bottom: 0;
			z-index: 9;
		}
	}
	.row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 98rpx;
		font-size: 28rpx;
		padding:  0 30rpx;
		&.border {
			border-bottom: 2rpx solid #E8E9EC;
		}
	}
	.logout {
		width: 396rpx;
		height: 72rpx;
		background: #FFFFFF;
		border-radius: 8rpx;
		border: 2rpx solid #E8E9EC;
		font-size: 28rpx;
		color: #ADADAD;
		text-align: center;
		line-height: 72rpx;
		margin: 88rpx auto;
	}
</style>