<template>
	<view class="content">
		<view class="" v-if="state">
			<view class="box">
				<view class="vflex jcenter box_top">
					<view class="text_style1">{{name}}</view>
					<view class="text_style1">{{idNumber}}</view>
				</view>
				<view class="text_style2">个人隐私信息安全保障中</view>
			</view>
		</view>
		<view class="" v-else>
			<view class="title">
				<view>实名认证</view>
				<view class="subTitle">为保障您的资金安全、提升您的账号信用、请您如实填写您的身份信息</view>
			</view>
			<view class="form">
				<view class="form_item">
					<view class="title">真实姓名</view>
					<u-input v-model="name" border="bottom" placeholder="请填写您本人的真实姓名"></u-input>
				</view>
				<view class="form_item">
					<view class="title">身份证号</view>
					<u-input v-model="idNumber" border="bottom" placeholder="请填写您的身份证号"></u-input>
				</view>
			</view>	
			<view class="hflex acenter">
				<u-checkbox-group @change="checkboxChange">
					<u-checkbox v-model="agree" shape="circle"></u-checkbox>
				</u-checkbox-group>
				<view class="text">阅读并同意<span class="read" @click="open(0)">《实名认证授权》</span>、<span class="read" @click="open(1)">《船百知隐私政策》</span></view>
			</view>
			<view class="button hflex acenter jcenter" @click="toAuth">
				<view>人脸认证</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	var that = ''
	export default {
		data() {
			return {
				name: '',
				idNumber: '',
				agree: false,
				showProtocol: false,
				protocolTitle: '',
				protocolContent: '',
				state: false,
			}
		},
		onLoad(options) {
			that = this
			that.state = options.state
			console.log(options);
		},
		methods: {
			// 阅读并同意
			checkboxChange(n) {
				this.agree = !this.agree
			},
			// 打开弹出层
			open(index) {
				const that = this
				// if(index == 0) {
				// 	$api.req({
				// 		url: '/api/Publics/config_info'
				// 	}, function(res) {
				// 		if (res.code == 1) {
				// 			that.protocolTitle = '用户协议'
				// 			that.protocolContent = res.data.xieyi
				// 		}
				// 	})
					
				// } else {
				// 	that.protocolTitle = '隐私政策'
				// 	that.protocolContent = ''
				// }
				// that.showProtocol = true
			},
			toAuth() {
				$api.req({
					url: '/data/api.auth.Center/userCertification',
					method: 'POST',
					data: {
						username: that.name,
						id_card: that.idNumber,
					}
				}, function(res) {
					if(res.code == 1) {
						console.log(res);
					}
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content::v-deep {
		padding: 0 30rpx;
		background-color: #fff;
		.title {
			margin-top: 40rpx;
			width: 100%;
			font-size: 48rpx;
			color: #222;
		}
		.subTitle {
			padding-top: 12rpx;
			font-size: 26rpx;
			color: #888;
			line-height: 36rpx;
		}
		.form {
			width: 100%;
			margin: 30rpx 0;
			.form_item {
				
				.title {
					font-size: 28rpx;
					color: #444;
				}
				.u-input {
					padding: 28rpx 0 !important;
				}
			}
		}
		.text {
			font-size: 24rpx;
			color: #9c9c9c;
		}
		.read {
			color: #2a63f3;
		}
		.button {
			width: 100%;
			height: 96rpx;
			background-color: #506dff;
			border-radius: 50rpx;
			box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
			font-size: 40rpx;
			color: #fff;
			margin: 106rpx 0 36rpx;
		}
		.box {
			margin-top: 40rpx;
			background: url('/static/images/mine/real-bg.png') no-repeat;
			background-size: 100%;
			width: 100%;
			height: 268rpx;
			.box_top {
				width: 100%;
				box-sizing: border-box;
				padding: 42rpx 0 42rpx 244rpx;
			}
			.text_style1 {
				font-size: 36rpx;
				color: #fff;
				margin-top: 18rpx;
			}
			.text_style2 {
				width: 100%;
				box-sizing: border-box;
				padding: 0 0 0 60rpx;
				font-size: 20rpx;
				color: #fff;
			}
		}
	}
</style>