<template>
	<view class="page">
		<block v-if="myinfo.step < 9">
			<view class="list_info">
				<view class="name">姓名：</view>
				<view class="item">
					<input type="text" class="input" v-model="realname" placeholder="请输入真实姓名" maxlength="16" />
				</view>
				<view class="name">身份证号：</view>
				<view class="item">
					<input type="text" class="input" v-model="idcard" placeholder="请输入身份证号" maxlength="18" />
				</view>

				<view class="blankHeight"></view>
			</view>

			<view class="btn_submit" @click="setSFZ()">提交实名认证</view>
		</block>

		<block v-if="myinfo.step == 9">
			<view class="mainInfo">
				<image style="margin-top: 150rpx;height: 120rpx;" src="../../static/me/img_checkMark.png"
					mode="heightFix" />
				<text
					style="margin-top: 60rpx;margin-bottom: 30rpx;color:#FFFFFF;font-size: 28rpx;">{{$t('txt.恭喜您已完成实名认证')}}</text>

				<view class="idList">
					<view class="left">
						<text style="font-size: 28rpx;color: #999999;">{{$t('txt.姓名')}}</text>
					</view>
					<view class="right">
						<text style="font-size: 28rpx;color: #ffffff;">{{myinfo.realname}}</text>
					</view>
				</view>

				<view class="idList">
					<view class="left">
						<text style="font-size: 28rpx;color: #999999;">{{$t('txt.身份证号')}}</text>
					</view>
					<view class="right">
						<text style="font-size: 28rpx;color: #ffffff;">{{myinfo.idcard}}</text>
					</view>
				</view>

				<view class="reCheckBtn" v-if="false">
					<text style="color:#FF2A95;font-size: 32rpx;">{{$t('txt.重新认证')}}</text>

				</view>
			</view>
		</block>

		<!-- 提示框 -->
		<DialogBox ref="DialogBox"></DialogBox>

	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				title: '',
				myinfo: {},
				realname: '',
				idcard: ''
			}
		},
		onLoad() {
			this.loadInfo();
		},
		onShow() {},
		methods: {
			onBack() {},

			loadInfo() {
				uni.request({
					url: this.$apiHost + '/My/idcheck',
					data: {
						uuid: getApp().globalData.uuid
					},
					header: {
						"content-type": "application/json",
						'sign': getApp().globalData.headerSign
					},
					success: (res) => {
						console.log("----:", res.data);
						this.myinfo = res.data;
					},
					complete: (com) => {
						// uni.hideLoading();
					},
					fail: (e) => {
						console.log("----e:", e);
					}
				});
			},
			setSFZ() {
				if (this.realname == '') {
					uni.showToast({
						title: "请填写姓名",
						icon: 'none'
					});
					return;
				}
				if (this.idcard.length < 15) {
					uni.showToast({
						title: "请填写身份证号",
						icon: 'none'
					});
					return;
				}
				uni.request({
					url: this.$apiHost + '/My/setsfz',
					data: {
						uuid: getApp().globalData.uuid,
						realname: this.realname,
						idcard: this.idcard
					},
					header: {
						"content-type": "application/json",
						'sign': getApp().globalData.headerSign
					},
					success: (res) => {
						console.log("----:", res.data);
						uni.showToast({
							title: res.data.str,
							icon: 'none'
						})
						if (res.data.success == 'yes') {
							this.loadInfo();
						}
					},
					complete: (com) => {
						// uni.hideLoading();
					},
					fail: (e) => {
						console.log("----e:", e);
					}
				});
			},

		}
	}
</script>

<style scoped lang="scss">
	@import 'normal.scss';
	@import 'idcheck.scss';
</style>