<template>
	<view class="content">
		<!-- <view class="moduleWrap">
			<view class="moduleBox" style="padding-bottom: 40rpx;">
				<view class="monthBox">
					<view class="text1">身份证信息</view>
					<text class="text2">上传本人身份证照片，保持图片清晰完整</text>
				</view>
				<view class="flex-between" style="margin-top: 20rpx;">
					<view>
						<img-upload @imgList="imgListz" style="width: 300rpx;height: 190rpx;">
							<template v-slot:upLoadImg>
								<image :src="path+'/assets/img/icon/IDbgz.png'" mode="widthFix" style="width: 300rpx;height: 190rpx;">
								</image>
							</template>
						</img-upload>
					</view>
					<view>
						<img-upload @imgList="imgListf" style="width: 300rpx;height: 190rpx;">
							<template v-slot:upLoadImg>
								<image :src="path+'/assets/img/icon/IDbgf.png'" mode="widthFix" style="width: 300rpx;height: 190rpx;">
								</image>
							</template>
						</img-upload>
					</view>
				</view>
			</view>
		</view> -->
		<view class="moduleWrap">
			<view class="moduleBox">
				<view class="text4">真实姓名</view>
				<view class="inputBox">
					<input v-model="realname" class="input1" type="text" placeholder="输入和身份证姓名一致" />
				</view>
			</view>
			<view class="moduleBox">
				<view class="text4">身份证号</view>
				<view class="inputBox">
					<input v-model="id_card_number" class="input1" type="text" placeholder="输入18位身份证号" />
				</view>
			</view>
			<view class="moduleBox">
				<view class="text4">有效日期</view>
				<view class="inputBox inputTwoBox">
					<text class="input1" @click="showStartDate=true">{{id_card_start_date||'开始时间'}}</text>
					<!-- <input class="input1" type="text" placeholder="开始日期" /> -->
					<text class="centerIcon">至</text>
					<text class="input2" @click="showEndDate=true">{{id_card_end_date||'结束时间'}}</text>
					<!-- <input class="input2" type="text" placeholder="开始日期" /> -->
				</view>
				<u-datetime-picker
					:show="showStartDate"
					v-model="dateStart"
					mode="date"
					@confirm="confirmStartDate"
				></u-datetime-picker>
				<u-datetime-picker
					:show="showEndDate"
					v-model="dateEnd"
					mode="date"
					@confirm="confirmEndDate"
				></u-datetime-picker>
			</view>
			<view class="moduleBox">
				<view class="text4">证件地址</view>
				<view class="inputBox">
					<input v-model="id_card_address" class="input1" type="text" placeholder="与身份证住址保持一致" />
				</view>
			</view>
			<view class="moduleBox">
				<view class="text4">联系电话</view>
				<view class="inputBox">
					<input v-model="mobile" class="input1" type="text" placeholder="输入您的联系方式" />
				</view>
			</view>
			<view class="moduleBox"  style="padding-bottom: 60rpx;">
				<view class="text4">代理区域</view>
				<view class="inputBox inputTwoBox2">
					<input class="input1" type="text" placeholder="请选择省份" />
					<text class="centerIcon">-</text>
					<input class="input2" type="text" placeholder="请选择城市" />
				</view>
			</view>
		</view>
		<view class="tipBox">
			Tips：我们会在3个工作日内审核并与您联系，请注意接听电话。
		</view>
		<view style="height: 130rpx;"></view>
		<view class="btnBox">
			<view class="btnEle flex-center" @click="apply">
				提交申请
			</view>
		</view>
	</view>
</template>


<script>  
	import imgUpload from '@/components/imgUpload.vue'
	import util from '../../common/util.js'
	export default { 
		data() {
			return { 
				showStartDate: false,
				showEndDate: false,
				dateStart: Number(new Date()),
				dateEnd: Number(new Date()),
				realname: '',
				id_card_number: '',
				id_card_front: '',
				id_card_back: '',
				id_card_start_date: '',
				id_card_end_date: '',
				id_card_address: '',
				mobile: ''
			}
		},
		components:{ 
			imgUpload
		},
		onLoad() { 
			
		},
		onShow() {
			
		},
		methods: {
			apply(){
				let data = {
					realname: this.realname,
					id_card_number: this.id_card_number,
					id_card_front: this.id_card_front,
					id_card_back: this.id_card_back,
					id_card_start_date: this.id_card_start_date,
					id_card_end_date: this.id_card_end_date,
					id_card_address: this.id_card_address,
					mobile: this.mobile
				}
				this.$api.applyCertification(data,res=>{
					if(res.code == '1'){
						uni.showToast({ title: res.msg , icon: 'success' })
						setTimeout(()=>{
							uni.navigateBack({
							  delta: 1
							})
						}, 2000)
					}else{
						uni.showToast({ title: res.msg , icon: 'none' })
					}
				}) 
			},
			imgListz(val){
				this.id_card_front = val
			},
			imgListf(val){
				this.id_card_back = val
			},
			confirmStartDate(val){
				this.showStartDate = false
				this.id_card_start_date = util.formatDate(val.value,'YYYY-MM-DD')
			},
			confirmEndDate(val){
				this.showEndDate = false
				this.id_card_end_date = util.formatDate(val.value,'YYYY-MM-DD')
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.content{
		padding: 20rpx 35rpx;
		background: #F5F5FA;
		height: 100%;
		overflow: auto;
	}
	.monthBox{
		display: flex;
		flex-direction: column;
		.text1{
			font-weight: bold;
			font-size: 32rpx;
			color: #333333;
		}
		.text2{
			font-weight: 400;
			font-size: 24rpx;
			color: #999999;
			margin-top: 10rpx;
		}
	}
	.moduleBox{
		background: #fff;
		padding: 34rpx 30rpx 28rpx;
		// border-bottom: 1rpx solid #DEDEDE;
		.text4{
			font-weight: bold;
			font-size: 28rpx;
			color: #333333;
		}
		.input1{
			margin-top: 40rpx;
			font-size: 28rpx;
		}
		.input2{
			margin-top: 40rpx;
			font-size: 28rpx;
			text-align: right;
		}
		.centerIcon{
			font-weight: 400;
			font-size: 28rpx;
			color: #333333;
		}
		.inputBox{
			border-bottom: 1rpx solid #DEDEDE;
			padding-bottom: 22rpx;
		}
	}
	.moduleBox:last-child{
		border-bottom: none;
	}
	.moduleWrap{
		
		margin-bottom: 20rpx;
		border-radius: 30rpx;
		overflow: hidden;
	}
	.inputTwoBox{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: flex-end;
	}
	.inputTwoBox2{
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: flex-end;
		.input1{
			margin-top: 40rpx;
			font-size: 28rpx;
			width: 200rpx;
		}
		.input2{
			margin-top: 40rpx;
			font-size: 28rpx;
			width: 200rpx;
		}
	}
	.tipBox{
		width: 680rpx;
		height: 110rpx;
		background: #FFF4ED;
		border-radius: 20rpx;
		font-weight: 400;
		font-size: 28rpx;
		color: #FF9348;
		line-height: 36rpx;
		padding: 0 30rpx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
	}
	
	.btnBox{
		padding: 10rpx 35rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		background: #fff;
		.btnEle{
			width: 100%;
			height: 90rpx;
			background: linear-gradient(90deg, #FFAD38 0%, #FF884E 100%);
			border-radius: 10rpx;
			font-weight: 500;
			font-size: 30rpx;
			color: #FFFFFF;
			line-height: 36rpx;
		}
	}
</style>