<template>
	<view class="content">
		<view style="height: 190rpx;"></view>
		<view class="a-title">
			<view class="title">本人实名认证</view>
			<view class="text">用于身份实名核验，反洗钱，资料将严格保密</view>
		</view>
		<view class="a-idcard-box">
			<view class="front" v-if="frontImg!=''"  @click="chooseImage(1)">
				<image :src="frontImg" mode=""></image>
			</view>
			<view class="front bg-image" @click="chooseImage(1)" v-else>
				<zzx-icon name="upload" size="30"></zzx-icon>
				<view class="">上传人像面</view>
			</view>
			<view class="flip-side" v-if="flipSideImg!=''" @click="chooseImage(2)">
				<image :src="flipSideImg" mode=""></image>
			</view>
			<view class="flip-side bg-image" v-else  @click="chooseImage(2)">
				<zzx-icon name="upload" size="30"></zzx-icon>
				<view class="">上传国徽面</view>
			</view>
		</view>
		<view class="a-form">
			<view class="form-item">
				<view class="">真实姓名</view>
				<input type="text" v-model="formData.fullName" placeholder="请输入本人姓名" />
			</view>
			<view class="form-item">
				<view class="">身份证号</view>
				<input type="idcard" v-model="formData.identityCard" placeholder="请输入本人身份证号" />
			</view>
			<view class="form-item">
				<view class="">手机号码</view>
				<input type="number" v-model="formData.phone" placeholder="请输入手机号" />
			</view>
			<view class="form-tips">老人或无手机号，可填写亲友手机号</view>
		</view>
		<view class="u-select-btn">
			<button hover-class="hover-btn" @click="submit">下一步</button>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { ref, onMounted } from 'vue';
	import { http } from '@/utils/http';
	import { RouterUtils,TipsUtils } from '@/utils/util';
	const formData = ref({
		fullName: '',
		identityCard: '',
		phone: ''
	})
	
	const frontImg = ref('')
	const flipSideImg=ref('')
	const chooseImage = (e) => {
		uni.chooseImage({
			count: 1,
			sizeType: ['original', 'compressed'],
			sourceType: ['album', 'camera'],
			success: function (res) {
				if(e==1){
					frontImg.value=res.tempFilePaths;
				}else{
					flipSideImg.value=res.tempFilePaths;
				}
			}
		});
	}
	
	const submit = () => {
		http.post('/my/familyMembers/addFamilyMembers',{...formData.value},{loading:true}).then((res)=>{
			TipsUtils.tips_toast(res.message)
			formData.value.fullName = ''
			formData.value.identityCard = ''
			formData.value.phone = ''
		})
		
		// uni.navigateTo({
		// 	url: '/pages/index/identityCertifying/index'
		// })
		// uni.checkIsSupportSoterAuthentication({
		// 	success: (res) => {
		// 		wx.startFacialRecognitionVerify({
		// 			name: '',
		// 			idCardNumber: '',
		// 			success: (res) => {
		// 				if (res.errMsg == 'startFacialRecognitionVerify:ok') {
		// 					console.log(res,'人脸识别结果：success');
		// 				}
		// 			},
		// 			fail: (err) => {
		// 				console.log(err,'人脸识别结果：fail')
		// 				uni.showToast({
		// 					title: '人脸识别失败',
		// 					icon: 'none',
		// 					duration: 20000,
		// 				});
		// 			}
		// 		})
		// 	},
		// 	fail: (err) => {
		// 		console.log(err)
		// 	}
		// })
	}
</script>

<style lang="less" scoped>
	.content {
		background: #fff;
		height: 1300rpx;

		.a-title {
			text-align: center;

			.title {
				font-weight: 800;
				font-size: 36rpx;
				color: #222222;
			}

			.text {
				margin-top: 20rpx;
				font-size: 24rpx;
				color: #AAAAAA;
			}
		}
		.a-idcard-box{
			display: flex;
			align-items: center;
			justify-content: space-around;
			font-size: 28rpx;
			color: #222222;
			margin-top: 40rpx;
			.front{
				width: 332rpx;
				height: 204rpx;
				border-radius: 16rpx;
				background-image: url('@/static/idcard-front.png');
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
				&>image{
					width: 100%;
					height: 100%;
					border-radius: 16rpx;
				}
			}
			.flip-side{
				width: 332rpx;
				height: 204rpx;
				border-radius: 16rpx;
				background-image: url('@/static/idcard-flipSide.png');
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
				&>image{
					width: 100%;
					height: 100%;
					border-radius: 16rpx;
				}
			}
		}

		.a-form {
			margin-top: 20rpx;

			.form-item {
				height: 110rpx;
				display: flex;
				align-items: center;
				gap: 20rpx;
				border-bottom: 1rpx solid #F0F0F0;
				font-weight: bold;
				font-size: 28rpx;
				color: #222222;

				&>input {
					font-weight: normal;
				}
			}
			.form-tips{
				margin-top: 20rpx;
				font-size: 24rpx;
				color: #AAAAAA;
			}
		}

		.u-select-btn {
			position: fixed;
			width: 100%;
			height: 300rpx;
			left: 0;
			bottom: 0;
			background: #fff;

			&>button {
				width: 95%;
				height: 100rpx;
				line-height: 100rpx;
				background: #D3FD76;
				border-radius: 60rpx;
				font-weight: bold;
				font-size: 32rpx;
				color: #222222;
			}

			&>button::after {
				border: none;
			}

			.hover-btn {
				background: #ccf371;
				color: #999999;
			}
		}
	}
</style>