<template>
	<view class="check">
		<uni-forms ref="form" :model="datainfo">
			<view class="cbox">
				<view class="chmain">
					<uni-forms-item label="头像" name="phonenumber">
						<view class="flexe mt10">
							<!-- <image :src="addbox" class="inimg"></image> -->
							<view class="addbox">
								<image :src="aphoto"></image>
							</view>
						</view>	
					</uni-forms-item>
					<uni-forms-item label="用户名称" name="phonenumber">
						<view class="flexc">
							<uni-easyinput v-model="datainfo.phonenumber" :disabled="isdisabled" :inputBorder='false' placeholder="请输入用户名称" />
						</view>
					</uni-forms-item>
					<uni-forms-item label="真实姓名" name="phonenumber">
						<view class="flexc">
							<uni-easyinput v-model="datainfo.phonenumber" :disabled="isdisabled" :inputBorder='false' placeholder="请输入真实姓名" />
						</view>
					</uni-forms-item>
					<uni-forms-item label="性别" name="realName">
						<picker  :disabled="isdisabled" range-key='text' :value="syqxidx" :range="sexs"   @change='bindDateChange'>
							<view class="flexc">
								<view class="flex1 txr f13" :class="datainfo.iszc?'co27':'coa'">{{datainfo.iszc?'是':'请选择性别'}}</view>
							</view>
						</picker>
					</uni-forms-item>
					<uni-forms-item label="年龄" name="phonenumber">
						<view class="flexc">
							<uni-easyinput v-model="datainfo.phonenumber" :disabled="isdisabled" :inputBorder='false' placeholder="请输入年龄" />
						</view>
					</uni-forms-item>
					<uni-forms-item label="手机号码" name="phonenumber">
						<view class="flexc">
							<uni-easyinput v-model="datainfo.phonenumber" :disabled="isdisabled" :inputBorder='false' placeholder="请输入手机号码" />
						</view>
					</uni-forms-item>
				</view>
			</view>
		</uni-forms>
		<view class="rhbtn mt30" @click="getNext">修改</view>

		<loading></loading>
	</view>
</template>

<script>
	import config from '@/config'
	import {
		checkPermi,
		checkRole
	} from "@/utils/permission"; // 权限判断函数
	import {
		uploadIdentify
	} from '@/utils/common.js'
	export default {
		components: {},
		data() {
			return {
				// line: require('@/work/static/car/line.png'),
				// car: require('@/work/static/car/carico.png'),
				// rimg: require('@/work/static/people/rimg.png'),
				aphoto: require('@/static/images/photo.png'),
				rdelimg: require('@/static/images/rdel.png'),
				baseUrl: config.baseUrl,
				checkflag:true,
				isdisabled:true,
				datainfo: {
					sex:0,
					realName: '',
					idCard: '',
					address: '',
					expirationDate: '',
					phonenumber: '',
					front: '',
					back: '',
				},
				syqxidx:'',
				sexs: [{
					text: '男',
					value: 0
				}, {
					text: '女',
					value: 1
				}],
			}
		},
		onLoad: function() {

		},
		methods: {
			checkPermi,
			checkRole,
			bindDateChange(e){
				var val=e.detail.value;
				// this.datainfo.applicationBank=this.sdyhlist[val].value;
				// this.applicationBank=this.sdyhlist[val].label;
			},
			getaddImage(e) {
				let that = this;
				// var rs=['D:\\idcard.png']
				// if(rs&&rs.length>0){
				// 	var obj={
				// 		type:e,
				// 		// url:baseUrl+rs.join(',')
				// 		url:rs.join(',')
				// 	}
				// 	that.getOcrIdCard(obj)
				// }
				// return
				let file = [],
					count = 9
				uni.chooseImage({
					count: 1,
					success: function(res) {
						let img = res.tempFilePaths;
						if (img.length + file.length > count) {
							uni.showToast({
								title: '最多上传' + count + '张图片',
								icon: 'none',
								duration: 2000
							})
						} else {
							let imglen = res.tempFilePaths.length;
							var fuwufile = [];
							uploadIdentify('/common/upload', img, 0, 0, 0, imglen, fuwufile, function(rs) {
								var resurl = rs[0];
								if (e == 'front') {
									that.datainfo.front = resurl.fileName;
								} else {
									that.datainfo.back = resurl.fileName;
								}
								if (rs && rs.length > 0) {
									var obj = {
										type: e,
										url: resurl.urlOnline
									}
									that.getOcrIdCard(obj)
								}
							})
						}
					}
				});
			},
			getOcrIdCard(obj) {
				var params = {
					image: obj.url,
					idCardSide: obj.type
				}
				getOcrIdCard(params).then(res => {
					if (res.code == 200) {
						var datainfo = res.data;
						if (obj.type == 'front') {
							this.datainfo.realName = datainfo.realName;
							this.datainfo.idCard = datainfo.idCard;
							this.datainfo.address = datainfo.address;
						} else {
							this.datainfo.expirationDate = datainfo.expirationDate
						}
					}
				})
			}
		}
	}
</script>
<style>
	page{background: #F3F3F0;}
</style>
<style lang="scss" scoped>
.check /deep/ .uni-forms-item{min-height: 106rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:10rpx 0;}
// .check .cbox /deep/ .uni-forms-item:last-child{border: none;}
.check /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
.check /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
.check /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 26rpx;}
.check /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
.check /deep/ .uni-input-input{font-size: 26rpx;}
.check /deep/ .uni-textarea-textarea{font-size: 26rpx;}
.check /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
.check /deep/ .uni-data-checklist .checklist-group .checklist-box{margin:10rpx 8rpx 10rpx 16rpx;}
.check /deep/ .uni-forms-item__label text{width: 110rpx;text-align-last: justify;}
.check /deep/ .uni-data-checklist{flex: 0 0 auto;}
.check{min-height: 100vh;padding: 20rpx 18rpx 24rpx;box-sizing: border-box;}
.cbox{background: #FFFFFF;border-radius: 20rpx;flex: 1;margin-bottom: 24rpx;
	.chmain{
		padding: 0 32rpx;
		.upbox{height: 224rpx;background: #EFF4FF;border-radius: 20rpx;display: flex;align-items: center;justify-content: center;flex-direction: column;margin-bottom: 8rpx;overflow: auto;
			.img{width: 100%;height: 100%;}
			.addimg{width: 70rpx;height: 70rpx;margin-bottom: 16rpx;}
			view{font-weight: bold;font-size: 26rpx;color: #4C6686;}
		}
		.rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
			image{width: 100%;height: 100%;}
		}
		.checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
		.aphoto{padding: 0 24rpx;border-left: 2rpx solid #e6e6e6;margin-left: 26rpx;
			image{width: 40rpx;height: 38rpx;}
		}
	}
	
}
.addimgs{display: flex;align-items: center;flex-wrap: wrap;justify-content: flex-end;
	
	.assimg{width: 128rpx;height: 128rpx;position: relative;overflow: hidden;margin: 0 0 20rpx 24rpx;
		.img{width: 100%;height: 100%;}
		.delimg{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
	}
}
.addbox{width: 102rpx;height: 102rpx;background: #F0F0F0;border-radius: 20rpx;display: flex;flex-direction: column;align-items: center;justify-content: center;margin-left: 24rpx;margin-bottom: 20rpx;flex: 0 0 auto;
		image{width: 48rpx;height: 42rpx;}
		// view{font-weight: 500;font-size: 24rpx;color: #666666;}
	}
.inimg{width: 102rpx;height: 102rpx;}
.tips{font-weight: bold;color: #272727;font-size: 26rpx;margin-left: 8rpx;}
</style>
