<template>
	<view class="lf-w-100 lf-h-100">
		<view class="lf-row-between lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32 title-border">
			<view class="input-title">
				<text style="color: #E21196;">*</text>
				<text class="lf-m-l-10" style="color: #131315;">真实姓名</text>
			</view>
			<view>
				<input type="text" placeholder="请填写真实姓名" style="text-align: right;" />
			</view>
		</view>
		<view class="lf-row-between lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32">
			<view class="input-title">
				<text style="color: #E21196;">*</text>
				<text class="lf-m-l-10" style="color: #131315;">身份证号</text>
			</view>
			<view>
				<input type="text" placeholder="请填写身份证号" style="text-align: right;" />
			</view>
		</view>
		<view class="flr"></view>
		<view>
			<view class="lf-color-777 lf-font-32 lf-p-t-30 lf-p-b-30 lf-p-l-32">
				请根据示例图上传清晰照片
			</view>
			<view class="authen-pic">
				<view @click="lookImage(1,image_list.length-1)" v-if="image_list.length">
					<image :src="image_list[image_list.length-1]" mode="aspectFill" style="width: 200rpx;height: 135rpx;"></image>
				</view>
				<view v-else>
					<text class="lf-iconfont icon-shenfenzhengzhengmian" style="font-size: 150rpx;"></text>
					<!-- <image src="../../static/logo.png" mode="aspectFill" style="width: 200rpx;height: 135rpx;"></image> -->
				</view>
				<view @tap="uploadImage(1)">
					<view>
						<u-icon name="camera-fill" style="font-size: 80rpx;"></u-icon>
					</view>
					<view class="lf-color-999 lf-font-24">点击上传照片</view>
				</view>
			</view>
		</view>
		<view class="lf-row-center lf-font-28 lf-m-t-20">
			<text style="color: #E21196;">*</text><text class="lf-m-l-10 lf-color-222">上传身份证正面</text>
		</view>
		<view class="authen-pic" style="margin-top: 60rpx;">
			<view @click="lookImage(2,image_list_back.length-1)" v-if="image_list_back.length">
				<image :src="image_list_back[image_list_back.length-1]" mode="aspectFill" style="width: 200rpx;height: 135rpx;"></image>
			</view>
			<view v-else>
				<text class="lf-iconfont icon-shenfenzhengbeimian" style="font-size: 150rpx;"></text>
			</view>
			<view @tap="uploadImage(2)">
				<view>
					<u-icon name="camera-fill" style="font-size: 80rpx;"></u-icon>
				</view>
				<view class="lf-color-999 lf-font-24">点击上传照片</view>
			</view>
		</view>
		<view class="lf-row-center lf-font-28 lf-m-t-20">
			<text style="color: #E21196;">*</text><text class="lf-m-l-10 lf-color-222">上传身份证反面</text>
		</view>
		
		<view class="apply-btn">
			申请认证
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				image_list: [],
				image_list_back: [],
				image_count: 6,
				content: '',
				frontImg: '',
				backImg: ''
			}
		},
		methods: {
			// 预览图片
			lookImage(type,index){
				if(type == 1) {
					this.$u.throttle(() => {
						uni.previewImage({
							urls: this.image_list,
							current: index
						});
					}, 500);
				}else {
					this.$u.throttle(() => {
						uni.previewImage({
							urls: this.image_list_back,
							current: index
						});
					}, 500);
				}
				
				
			},
			// 移除图片
			removeInage(current){
				this.image_list.splice(current, 1);
			},
			// 上传凭证图片
			uploadImage(type){
				let current_count = this.image_count - this.image_list.length;
				if(current_count == 0) return;
				uni.chooseImage({
					count: current_count,
					complete: result => {
						let tempFiles = result.tempFiles;
						let image_list = [];
						let overstep = false;
						tempFiles.map(item => {
							// 上传的图片需小于10MB
							if(item.size < 10464788){
								if(type == 1) {
									this.image_list.push(item.path)
									console.log(this.image_list)
									// this.frontImg = item.path
								}else {
									// this.backImg = item.path
									this.image_list_back.push(item.path)
								}
							}else{
								overstep = true;
							}
						})
						if(overstep){
							uni.showModal({
								title: '温馨提示',
								content: '您上传的图片含有超出10M大小的限制，请优化大小后再上传！',
								showCancel: false
							})
						}
						// this.image_list.push(...image_list);
					}
				})
			},
		
		}
	}
</script>

<style scoped="scoped">
	.apply-btn {
		width: 686rpx;
		height: 100rpx;
		background: #E21196;
		border-radius: 60rpx;
		margin: 0 auto;
		font-size: 36rpx;
		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 60rpx;
	}
	.flr{
		width: 100%;
		height: 20rpx;
		background: #F5F5F5;
	}
	.title-border {
		border-bottom: 1rpx solid rgba(0,0,0,0.1);
		border-top: 1rpx solid rgba(0,0,0,0.1) ;
	}
	.input-title {
		font-size: 32rpx;
		color: #131315;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.authen-pic {
		width: 686rpx;
		height: 349rpx;
		background: #F5F5F5;
		border-radius: 10rpx;
		margin: 0 auto;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		align-items: center;
		text-align: center;
	}
</style>
