<template>
	<view class="body_content">
		<view class="login_text">
			<view class="login_input flex" style="padding-top: 45rpx;">
				<view class="login_name">姓名</view>
				<view class="login_name"><input class="uni-input" type="text" v-model="username"
						placeholder="请输入真实姓名" /></view>
			</view>
			<view class="login_input flex">
				<view class="login_name"><text>身份证号</text></view>
				<view class="login_name"><input class="uni-input" type="idcard" v-model="idCard"
						placeholder="请输入身份证号" /></view>
			</view>
		</view>
		<view class="uploadText">身份证照片(正反两面）</view>
		<view class="flex upLoadBox">
			<view class="imageBox flex">
				<image @click="upimg('front_pic')" :src="front_pic||`../../static/img/add.png`" style="width: 180rpx;height: 180rpx;"
					mode="widthFix"></image>
				<image @click="upimg('back_pic')" :src="back_pic||`../../static/img/add.png`" style="width: 180rpx;height: 180rpx;"
					mode="widthFix"></image>
			</view>
		</view>
		<view class="submission">
			<button class="golden" type="golden" hover-class="none" @click="submission">提交认证</button>
		</view>
	</view>
	</view>
</template>
<script type="text/javascript">
	import {
		real_check
	} from '@/api/game.js';
	import {
		upload
	} from '@/api/order.js';
	export default {
		data() {
			return {
				username: '',
				idCard: '',
				phone: '',
				vcode: '',
				front_pic: '',
				back_pic: '',
			};
		},
		onLoad() {
			// this.uid = uni.getStorageSync('uid');
			// console.log(uni.getStorageSync('uid'),this.uid)
			//  this.loadData();
		},
		methods: {
			upimg(img) {
				const that = this;
				upload().then((re) => {
					that[img] = re[0].url;
				}).catch((re) => {
					console.log(re,'err');
				})
			},
			//获取数据
			// loadData() {
			// 	real_check({
			// 			name: this.username,
			// 			id_card: this.idCard,
			// 			front_pic: this.front_pic,
			// 			back_pic: this.back_pic,
			// 		})
			// 		.then(data => {
			// 			let obj = this;
			// 			obj.list = data.data;
			// 			if (data.data.card == null) {
			// 				obj.number = "";
			// 			} else {
			// 				obj.number = data.data.card;
			// 			}
			// 			if (data.data.email == null) {
			// 				obj.mail = "";
			// 			} else {
			// 				obj.mail = data.data.email;
			// 			}
			// 			if (data.data.name == null) {
			// 				obj.username = '';
			// 			} else {
			// 				obj.username = data.data.name;
			// 			}

			// 		})
			// 		.catch(err => {
			// 			console.log(err);
			// 		});
			// },
			// 提交
			submission() {
				if (this.username == '') {
					this.$api.msg('请输入真实姓名');
					return;
				}
				if (this.idCard == '') {
					this.$api.msg('请输入身份证号');
					return;
				}
				if (this.front_pic == ''||this.back_pic == '') {
					this.$api.msg('请上传身份证正反面');
					return;
				}
				real_check({
						name: this.username,
						id_card: this.idCard,
						front_pic: this.front_pic,
						back_pic: this.back_pic,
					})
					.then(function(e) {
						uni.showToast({
							title: e.msg,
							duration: 1500,
						});
					})
					.catch(function(e) {
						console.log(e);
					});
			},
			//下拉刷新
			onPullDownRefresh() {
				let obj = this;
				//监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
				setTimeout(function() {
					obj.loadData();
					uni.stopPullDownRefresh(); //停止下拉刷新动画
				}, 1000);
			}
		}
	};
</script>
<style lang="scss">
	.login_text {
		width: 100%;
		// padding: 25rpx 0rpx;
		font-size: 28rpx !important;
		padding: 0rpx 25rpx;
	}

	.login_input {
		border-bottom: 1px solid #464755;
		padding: 35rpx;
	}

	.uploadText {
		padding: 47rpx 40rpx;
		color: #ffffff;

	}

	.imageBox {
		width: 100%;
		padding: 50rpx 15%;
	}

	.uni-input {
		width: 450rpx;
		text-align: left !important;
		font-size: 26rpx;
	}

	.width {
		width: 265rpx !important;
	}

	.code {
		color: #EEC680;
		font-size: 23rpx;
		border-left: 1px solid #85858E;
		padding-left: 25rpx;
	}

	.submission {
		padding: 80rpx 25rpx;

		.golden {
			background: #0C5AFA;
			color: #ffffff;
		}
	}

	.login_name {
		color: #ffffff;
	}
</style>