<template>
	<view class="">
		<view class="margin-top padding margin" style="background: #FFFFFF; border-radius: 20upx;">
			<view class="title">基本信息</view>
			<view style="margin-top: 20rpx;">
				姓名
			</view>
			<view class="flex"
				style="margin: 20rpx 0; padding: 20rpx;border-radius: 11rpx; border: 1px #ccc solid;">
				<input class="uni-input" style="width: 90%;" placeholder="请输入真是姓名" />
				<image v-if="globalImages" :src="globalImages + 'images/cuo.png'" style="width: 44rpx;height: 44rpx;margin-left: 15rpx;"
					mode=""></image>
			</view>
			<view style="margin-top: 20rpx;">
				身份证号码
			</view>
			<view class="flex"
				style="margin: 20rpx 0; padding: 20rpx;border-radius: 11rpx; border: 1px #ccc solid;">
				<input class="uni-input" type="number" style="width: 90%;" placeholder="请输入身份证号码" />
				<image v-if="globalImages" :src="globalImages + 'images/cuo.png'" style="width: 44rpx;height: 44rpx;margin-left: 15rpx;"
					mode=""></image>
			</view>
			<view style="color: #ccc;font-size: 24rpx;">
				请确保信息准确有效
			</view>
			<view class="title" style="margin-top: 30rpx;">人脸识别</view>
			<view style="text-align: center;">
			    <view class="parent-container">
			        <view style="width: 300rpx; height: 300rpx; border-radius: 150rpx; background: #b2b2b0; margin-top: 30rpx;"></view>
			    </view>
			    <button type="primary" style="background: #00c18a; margin-top: 50rpx;" size="mini" class="feedback-submit">开始验证</button>
			    <view style="margin-top: 15rpx;">
			        请正对摄像头，确保光线充足
			    </view>
			</view>
		</view>
		<view class="margin-top padding margin" style="background: #FFFFFF; border-radius: 20upx;">
			<view class="title">车辆信息</view>
			<view style="margin-top: 20rpx;">
				行驶证照片
			</view>
			<view style="width: 100%;margin-top: 20rpx;padding: 30rpx;">
				<view @click="addImages(1)"
					v-if="!form.frontIdentityCard">
					<image src="../../static/upload/czsfzrx.png" style="width: 100%;"></image>
				</view>
				<image @click="disabled? '':addImages(1)" v-else :src="form.frontIdentityCard"
					style="width: 100%;"></image>
			</view>
			<view style="margin-top: 20rpx;">
				车辆照片
			</view>
			<view style="width: 100%;margin-top: 20rpx;padding: 30rpx;">
				<view @click="addImages(2)"
					v-if="!form.backIdentityCard">
					<image src="../../static/upload/czsfzfm.png" style="width: 100%;"></image>
				</view>
				<image @click="disabled? '':addImages(2)" v-else :src="form.backIdentityCard"
					style="width: 100%;"></image>
			</view>
		</view>
		<view class=" margin-top footer text-xxl flex align-center" style="font-size: 24rpx; padding: 0 30rpx;">
			<text @tap="isShowAgree" class="cuIcon" :class="showAgree?'cuIcon-radiobox':'cuIcon-round'">同意并接受</text>
			<!-- 协议地址 -->
			<navigator url="/my/setting/sijixieyi" style="color: #00c18a;" open-type="navigate">《司机代驾服务用户协议 》</navigator>
		</view>
		<view class="login_btn">开始验证</view>
	</view>
</template>

<script>
	import { waitForGlobalImages } from '@/utils/globalImageLoader'
	export default {
		data() {
			return {
				selectedModule: 'douyin',
				globalImages: ''
			}
		},
		onLoad() {
			waitForGlobalImages().then((path) => {
			    console.log('✅ 全局图片路径:', path)
			    this.globalImages = path
			  })
		},
		methods: {
			selectModule(module) {
				this.selectedModule = module;
			},
			addImages(e) {
				uni.chooseImage({
					count: 1,
					sourceType: ['album', 'camera'],
					success: res => {
						for (let i = 0; i < 1; i++) {
							this.$queue.showLoading("上传中...");
							uni.uploadFile({ // 上传接口
								// url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
								url: 'https://shunfengcheshop.xianmxkj.com/sqx_fast/alioss/upload',
								filePath: res.tempFilePaths[i],
								name: 'file',
								success: (uploadFileRes) => {
									console.log(uploadFileRes)
									if (e == 1) {
										this.form.frontIdentityCard = JSON.parse(uploadFileRes
											.data).data
									} else if (e == 2) {
										this.form.backIdentityCard = JSON.parse(uploadFileRes
											.data).data
									} else if (e == 3) {
										this.form.drivingLicense = JSON.parse(uploadFileRes
											.data).data
									} else if(e == 4){
										this.form.driverLicense = JSON.parse(uploadFileRes
											.data).data
									}
									uni.hideLoading();
								}
							});
						}
					}
				})
			},
		},
		mounted() {

		}
	}
</script>

<style scoped>
	.title {
		font-size: 33rpx;
		font-family: PingFang SC;
		color: #333333;
	}

	.login_btn {
		width: calc(100% - 60rpx);
		margin: 30rpx auto;
		text-align: center;
		background: #00c18a;
		height: 80rpx;
		border-radius: 16rpx;
		color: #ffffff;
		line-height: 80rpx;
	}
	
	.parent-container {
	    display: flex;
	    justify-content: center;
	    align-items: center;
	    position: relative;
	}
</style>