<template>
	<view class="check">
		<uni-forms ref="form" :model="datainfo" :rules="rules">
			<view class="cbox">
				<view class="chmain">
					<picker range-key='dictLabel' :disabled="ptype=='edit'?true:false" :value="rylxidx" :range="rylxList"   @change='bindDateChangee'>
						<uni-forms-item label="人员类型" required name="residentType">
							<view class="flexc mh35">
								<view class="flex1 txr f13 co27" v-if="datainfo.residentType&&!rylx">{{statusFormats(datainfo.residentType,rylxList,'rylx')}}</view>
								<view class="flex1 txr f13" v-else :class="rylx?'co27':'coa'">{{rylx||"请选择人员类型"}}</view>
								<view class="rimg"><image :src="rimg"></image></view>
							</view>
						</uni-forms-item>
					</picker>
					<uni-forms-item label="姓名"  name="residentName">
						<view class="flexc">
							<uni-easyinput :disabled="isdisabled"  v-model="datainfo.residentName"  :inputBorder='false' placeholder="请输入姓名" />
						</view>
					</uni-forms-item>
					<uni-forms-item label="手机号码" required name="residentPhone">
						<view class="flexc">
							<uni-easyinput  :disabled="isdisabled"  v-model="datainfo.residentPhone"  :inputBorder='false' placeholder="请输入手机号码" />
						</view>
					</uni-forms-item>
					<uni-forms-item label="小区名称" required name="tenantId">
						<w-select
						      style="margin-left: 20rpx;" 
						     v-model="datainfo.tenantId"
						      :list='voList'
							  width='200rpx'
						      valueName='dictLabel' 
						      keyName="dictValue"
							  :valuea="datainfo.tenantId"
							  :chosevalue="tenantName?tenantName:statusFormats(datainfo.tenantId,voList,'tenant')"
							  :isdisabled="ptype=='edit'?true:false"
							  :filterable="filterable"
						      @change='getchangea'
						    >
						    </w-select>
					</uni-forms-item>
					<block v-if="datainfo.residentType&&datainfo.residentType!=3">
						<uni-forms-item label="房屋号" required name="houseId" v-if="datainfo.residentType!=3">
							<w-select
							      style="margin-left: 20rpx;" 
							     v-model="datainfo.houseId"
							      :list='fwlist'
							      valueName='dictLabel' 
							      keyName="dictValue"
								  :valuea="datainfo.houseId"
								  :isdisabled="ptype=='edit'?true:false"
								  :chosevalue="datainfo.detailedAddress"
								  :filterable='filterable'
							      @change='getchange'
							    >
							    </w-select>
						</uni-forms-item>
						<block v-if="datainfo.residentType==1">
							<uni-forms-item label="是否户主" required name="isHouseholder">
								<view class="flexc ">
									<view class="flex1"></view>
									<view class="sylist flexcc" :class="datainfo.isHouseholder==ite.dictValue?'act':''" v-for="(ite,idx) in sfList" :key="idx" @click="getSyFn(ite.dictValue)">{{ite.dictLabel}}</view>
									<view class="rimg"><image :src="rimg"></image></view>
								</view>
							</uni-forms-item>
							<block v-if="datainfo.isHouseholder!='Y'">
								<picker range-key='dictLabel' :disabled="isdisabled" :value="hzgxidx" :range="hzgxList"   @change='bindDateChangea'>
									<uni-forms-item class="isnobor" label="与户主关系" required name="residentRelationship">
										<view class="flexc mh35">
											<view class="flex1 txr f13 co27" v-if="datainfo.residentRelationship&&!hzgx">{{statusFormats(datainfo.residentRelationship,hzgxList,'hzgx')}}</view>
											<view class="flex1 txr f13" v-else :class="hzgx?'co27':'coa'">{{hzgx||"请选择与户主关系"}}</view>
											<view class="rimg"><image :src="rimg"></image></view>
										</view>
									</uni-forms-item>
								</picker>
							</block>
						</block>
					</block>
				</view>
				<uni-collapse ref="collapse" v-model="value" >
					<block>
						<view class="chtit">人员信息</view>
							<block>
								<uni-collapse-item title-border="none" class="chmain">
										<template v-slot:title>
											<uni-forms-item label="身份证号" required name="residentIdCard">
												<view class="flexc">
													<uni-easyinput :disabled="isdisabled"  v-model="datainfo.residentIdCard"  :inputBorder='false' placeholder="自动识别" />
													<image v-if='datainfo.idCardBack' :src="baseUrl+datainfo.idCardBack" class="cmico" @click.stop="getPreview(datainfo.idCardBack)"></image>
													<image :src="cmico" @click.stop="getaddImage('front')" class="cmico"></image>
												</view>
											</uni-forms-item>
										</template>
										<view>
											<uni-forms-item label="性别" required name="residentGender">
												<view class="flexc">
													<view class="flex1"></view>
													<uni-data-checkbox  :map="map" :disabled="isdisabled" selectedColor="#0156FE" selectedTextColor="#272727" v-model="datainfo.residentGender" :localdata="xbList" />
												</view>
											</uni-forms-item>
											<uni-forms-item label="家庭地址" required name="idCardAddress">
												<view class="flexc">
													<uni-easyinput  disabled  v-model="datainfo.idCardAddress"  :inputBorder='false' placeholder="自动识别" />	
												</view>
											</uni-forms-item>
											<picker range-key='dictLabel' :disabled="isdisabled" :value="rymmidx" :range="rymmList"   @change='bindDateChangef'>
												<uni-forms-item label="人员面貌" required name="residentAppearance">
													<view class="flexc mh35">
														<view class="flex1 txr f13 co27" v-if="datainfo.residentAppearance&&!rymm">{{statusFormats(datainfo.residentAppearance,rymmList,'rymm')}}</view>
														<view class="flex1 txr f13" v-else :class="rymm?'co27':'coa'">{{rymm||"请选择人员面貌"}}</view>
														<view class="rimg"><image :src="rimg"></image></view>
													</view>
												</uni-forms-item>
											</picker>
											<picker range-key='dictLabel' :disabled="isdisabled" :value="dslxidx" :range="dslxList"   @change='bindDateChangeg'>
												<uni-forms-item label="特殊类型" name="specialType">
													<view class="flexc mh35">
														<view class="flex1 txr f13 co27" v-if="datainfo.specialType&&!dslx">{{statusFormats(datainfo.specialType,dslxList,'dslx')}}</view>
														<view class="flex1 txr f13" v-else :class="dslx?'co27':'coa'">{{dslx||"如有五保户等特殊类型,请选择"}}</view>
														<view class="rimg"><image :src="rimg"></image></view>
													</view>
												</uni-forms-item>
											</picker>
											<uni-forms-item label="工作单位"  name="residentEmployer">
												<view class="flexc">
													<uni-easyinput :disabled="isdisabled"  v-model="datainfo.residentEmployer"  :inputBorder='false' placeholder="请输入工作单位" />
												</view>
											</uni-forms-item>
											<uni-forms-item label="兴趣爱好" name="residentHobby">
												<view class="flexc ml10">
													<uni-easyinput type="textarea" :disabled="isdisabled" autoHeight v-model="datainfo.residentHobby" :inputBorder='false' placeholder="请输入兴趣爱好" />
												</view>
											</uni-forms-item>
											
											<uni-forms-item label="上传头像" name="facePhoto">			
												<view class="addimgs">
													<block v-if="phofile&&phofile.length">
														<view class="assimg" v-for="(ite,idx) in phofile" :key="idx" @click="getPreviewa(idx,phofile)">
															<image :src="baseUrl+ite" class="img"></image>
															<image :src="rdelimg" class="delimg" @click.stop="getDelFn(idx,'fm')"></image>
														</view>
													</block>
													<view class="addbox" @click="getaddImageava">
														<image :src="aphoto"></image>
														<view>添加图片</view>
													</view>
												</view>
											</uni-forms-item>
										</view>
									</uni-collapse-item>
							</block>
					</block>
				<block v-if="datainfo.residentType==1&&datainfo.isHouseholder=='Y'">
					<view class="chtit">房本信息</view>
						<block>
							<uni-collapse-item title-border="none" class="chmain">
									<template v-slot:title>
										<uni-forms-item label="房屋坐落" required name="location">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled"  v-model="houserinfo.location"  :inputBorder='false' placeholder="自动识别" />
												<image v-if='houserinfo.houseImage' :src="baseUrl+houserinfo.houseImage" class="cmico" @click.stop="getPreview(houserinfo.houseImage)"></image>
												<image :src="cmico" @click.stop="getaddImage('fbxx')" class="cmico"></image>
											</view>
										</uni-forms-item>
									</template>
									<view >
										<uni-forms-item label="权利人姓名" name="ownerName">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.ownerName" :inputBorder='false' placeholder="自动识别" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="权利类型" name="rightType">
											<picker range-key='dictLabel' :disabled="isdisabled" :value="qllxidx" :range="qllxList"  @change='bindDateChange'>
												<view class="flexc">
													<view class="flex1 txr f13 co27" v-if="houserinfo.rightType&&!qllx">{{statusFormats(houserinfo.rightType,qllxList,'qllx')}}</view>
													<view class="flex1 txr f13" v-else :class="qllx?'co27':'coa'">{{qllx||"请选择权利类型"}}</view>
													<view class="rimg"><image :src="rimg"></image></view>
												</view>
											</picker>
										</uni-forms-item>
										<uni-forms-item label="建筑面积" required name="area">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.area" :inputBorder='false' placeholder="自动识别" />
												<view class="tips">m²</view>
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="不动产单元号" name="propertyUnitNumber">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.propertyUnitNumber" :inputBorder='false' placeholder="请输入不动产单元号" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="相关的字第号" name="documentNumber">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.documentNumber" :inputBorder='false' placeholder="请输入相关的字第号" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="小区名称" name="communityName">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.communityName" :inputBorder='false' placeholder="请输入小区名称" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="门牌号" required name="detailedAddress">
											<view class="flexc">
												<uni-easyinput disabled v-model="houserinfo.detailedAddress" :inputBorder='false' placeholder="请输入门牌号" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="使用期限" name="usagePeriod">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.usagePeriod" :inputBorder='false' placeholder="请输入使用期限" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="登记日期" name="registrationDate">
											<!-- <picker mode="timed" :disabled="isdisabled"  @change='bindDateChangea'>
												<view class="flexc">
													<view class="flex1 txr f13"  :class="datainfo.registrationDate?'co27':'coa'">{{datainfo.registrationDate||"请选择登记日期"}}</view>
													<view class="rimg"><image :src="rimg"></image></view>
												</view>
											</picker> -->
											<!-- :hide-second='true' -->
											<view class="flexc">
												<uni-datetime-picker  :disabled="isdisabled" :class="houserinfo.registrationDate?'co27':'coa'" type="datetime" placeholder="请选择登记日期" :border="false"  v-model="houserinfo.registrationDate"  />
												<view class="rimg"><image :src="rimg"></image></view>
											</view>
										</uni-forms-item>
										
										<uni-forms-item label="共有姓名" name="coOwner">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.coOwner" :inputBorder='false' placeholder="请输入共有姓名" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="共有情况" name="coOwnership">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.coOwnership" :inputBorder='false' placeholder="请输入共有情况" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
										<uni-forms-item label="房屋状态" name="houseStatus">
											<picker range-key='dictLabel' :disabled="isdisabled" :value="fwztidx" :range="fwztList"   @change='bindDateChangeb'>
												<view class="flexc">
													<view class="flex1 txr f13 co27" v-if="houserinfo.houseStatus&&!fwzt">{{statusFormats(houserinfo.houseStatus,fwztList,'fwzt')}}</view>
													<view class="flex1 txr f13" v-else :class="fwzt?'co27':'coa'">{{fwzt||"请选择房屋状态"}}</view>
													<view class="rimg"><image :src="rimg"></image></view>
												</view>
											</picker>
										</uni-forms-item>
										<uni-forms-item label="房屋用途" name="usageType">
											<picker range-key='dictLabel' :disabled="isdisabled" :value="fwytidx" :range="fwytList"   @change='bindDateChangec'>
												<view class="flexc">
													<view class="flex1 txr f13 co27" v-if="houserinfo.usageType&&!fwyt">{{statusFormats(houserinfo.usageType,fwytList,'fwyt')}}</view>
													<view class="flex1 txr f13" v-else :class="fwyt?'co27':'coa'">{{fwyt||"请选择房屋用途"}}</view>
													<view class="rimg"><image :src="rimg"></image></view>
												</view>
											</picker>
										</uni-forms-item>
										<uni-forms-item label="有无车位" name="hasParkingSpace">
											<picker range-key='dictLabel' :disabled="isdisabled" :value="ywcwidx" :range="ywcwList"   @change='bindDateChanged'>
												<view class="flexc">
													<view class="flex1 txr f13 co27" v-if="houserinfo.hasParkingSpace&&!ywcw">{{statusFormats(houserinfo.hasParkingSpace,ywcwList,'ywcw')}}</view>
													<view class="flex1 txr f13" v-else :class="ywcw?'co27':'coa'">{{ywcw||"请选择有/无"}}</view>
													<view class="rimg"><image :src="rimg"></image></view>
												</view>
											</picker>
										</uni-forms-item>
										<uni-forms-item label="车位号" name="parkingNumber">
											<view class="flexc">
												<uni-easyinput :disabled="isdisabled" v-model="houserinfo.parkingNumber" :inputBorder='false' placeholder="请输入车位号" />
												<view class="rimg"></view>
											</view>
										</uni-forms-item>
									</view>
								</uni-collapse-item>
						</block>
				</block>
				</uni-collapse>
				<view class="hfbtns flexcj" v-if="datainfo.examine==1&&checkPermi(['wuYe:residentInfo:examineStaff'])">
					<view class="btn btn1" @click.stop="getShFn('3')">拒绝</view>
					<view class="btn btn2" @click.stop="getShFn('2')">通过</view>
				</view>
				<!-- <view class="hfbtns flexcj" v-if="datainfo.examine==3&&checkPermi(['wuYe:residentInfo:editAuthentication'])">
					<view class="btn btn2" @click.stop="getSubmit">修改提交</view>
				</view> -->
			</view>
		</uni-forms>
		

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

<script>
	import config from '@/config'
	import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
	import {uploadIdentify,uploadmore} from '@/utils/common.js'
	import {listNoPageTenant,houseInfoDet,examineResident} from "@/api/work/work.js"
	import {gettenantList} from "@/api/login.js"
	import {residentInfoDet,authenticationPut} from "@/api/work/people.js"
	import {getDictionaryFn} from "@/api/system/user.js"
	import {selectValueKey} from "@/utils/common.js"
	import {getOcrIdCard,getrealEstateCertificatee} from "@/api/system/card.js"
	import wSelect from "@/people/components/w-select/w-select.vue"
	export default {
		components: {wSelect},
		data() {
			return {
				rimg: require('@/mine/static/house/rimg.png'),
				cmico: require('@/mine/static/house/cmico.png'),
				aphoto: require('@/service/static/service/photo.png'),
				baseUrl: config.baseUrl,
				checkflag:true,
				backgroundColor: "transparent",
				value:'',
				datainfo: {
					"tenantId":"",//租户id
					"residentType":"",//人员类型:1:业主 2:租户 3:其他
					"residentName":"",//居住人员姓名
					"residentPhone":"",//人员手机号
					"houseInfoRedidentList":[],//用户房屋信息集合
					"houseId":"",//关联房屋信息表的house_id
					"residentRelationship":"",//居住人员与户主的关系,如父子、夫妻等
					"isHouseholder":"",//是否是户主 N不是 Y是
					
					"residentIdCard":"",//居住人员身份证号码,18位
					// "residentBirthday":"",//居住人员出生日期
					"residentGender":'',//居住人员性别:1-男,2-女
					
					// "isTenant":"",//是否是租户:Y-是,N-否
					"residentEmployer":"",//居住人员工作单位
					"residentAppearance":"",//居住人员面貌,如党员、群众等
					"residentHobby":"",//爱好
					"facePhoto":"",//人脸地址
					"idCardAddress":"",//身份证住址
					"specialType":"",//特殊类型
					"idCardFront":"",//身份证正面
					"idCardBack":"",//身份证反面
				},
				rules:{
					residentType: {rules: [{required: true,errorMessage: '请选择人人员类型' }]},
					// residentIdCard: {rules: [{required: true,errorMessage: '请输入身份证号码' }]},
					// residentName: {rules: [{required: true,errorMessage: '请输入姓名' }]},
					// residentGender: {rules: [{required: true,errorMessage: '请选择性别' }]},
					// houseId: {rules: [{required: true,errorMessage: '请选择房屋号' }]},
					// detailedAddress: {rules: [{required: true,errorMessage: '请输入居住地址' }]},
					// isHouseholder: {rules: [{required: true,errorMessage: '请选择是否户主' }]},
					// residentRelationship: {rules: [{required: true,errorMessage: '请选择与户主关系' }]},
					residentPhone: {rules: [{required: true,errorMessage: '请输入手机号'}, {pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,errorMessage:'请输入正确的手机号码'}]},
				  },
				hzgx:"",
				rylx:"",
				hzgxidx:0,
				dslxidx:0,
				rylxidx:0,
				list:[],
				phofile:[],
				fwlist:[],
				rylxList:[],
				fwzt:'',
				qllx:'',
				fwyt:'',
				ywcw:'',
				hzgx:'',
				
				sfhz:"",
				sfzh:"",
				rymm:"",
				dslx:"",
				fwztidx:0,
				qllxidx:0,
				fwytidx:0,
				ywcwidx:0,
				hzgxidx:0,
				sfzhidx:0,
				rymmidx:0,
				sfhzidx:0,
				dslxidx:0,
				fwztList:[],
				qllxList:[],
				fwytList:[],
				hzgxList:[],
				sfList:[],
				rymmList:[],
				dslxList:[],
				xbList:[],
				ywcwList:[{dictLabel:'有',dictValue:'Y'},{dictLabel:'无',dictValue:'N'},],
				isdisabled:false,
				ptype:'add',
				filterable:true,
				chooseValue:'',
				map:{text:'dictLabel',value:'dictValue'},
				userId:this.$store.state.user.userId,
				voList:[],
				tenantName:'',
				houseInfoRedidentList:[],
				fwztList:[],
				qllxList:[],
				fwytList:[],
				sfList:[],
				rzflag:false,
				choseidx:'',
				houserinfo:{
					"houseId":'',
					"tenantId":"",//租户id
					"houseImage":null,//房本照片
					"ownerName":null,//权利人姓名
					"location":null,//房屋坐落位置
					"rightType":null,//权利类型,如所有权、使用权等
					"area":null,//房屋面积,单位为平方米
					"documentNumber":null,//房屋相关的字第号
					"propertyUnitNumber":null,//不动产单元号
					"coOwnership":null,//房屋的共有情况,如共有比例等
					"usageType":null,//房屋用途,如住宅、商业等
					"usagePeriod":null,//房屋使用期限
					"registrationDate":null,//房屋登记日期
					"coOwner":null,//共有人姓名,多个共有人可以用逗号分隔
					"detailedAddress":null,//房屋的详细门牌号
					"hasParkingSpace":null,//是否有车位,Y表示有,N表示无
					"communityName":null,//房屋所在小区名称
					"houseStatus":null,//房屋状态:1-自住,2-出租,3-空闲,4-待售
					"parkingNumber":null,//车位号
				}
			}
		},
		onLoad: function(e) {
			if(e.type){
				this.rztype=e.type
				this.rzflag=true;
				this.datainfo.residentPhone=this.$store.state.user.phonenumber;
				this.datainfo.userId=this.$store.state.user.userId;
			}else{
				// var tenantId=this.$store.state.user.tenantId;
				// this.datainfo.tenantId=tenantId;
				// this.getRoleNopage(tenantId)
			}
			this.gettenantList();
			if(e.id){
				this.id=e.id;
				this.ptype="edit";
				// this.isdisabled=true;
				this.getDetail()
			}
			this.init()
		},
		onPageScroll(e) {
			var scrollTop = Number(e.scrollTop);
			if (scrollTop > 0) {
				this.backgroundColor = '#48CC9A'
			} else {
				this.backgroundColor = 'transparent'
			}
		},
		methods: {
			checkPermi,
			checkRole,
			getEditFn(){
				this.isdisabled=false;
			},
			getSyFn(e){
				this.datainfo.isHouseholder=e
				console.log(this.datainfo.isHouseholder)
			},
			getShFn(type){
				var that=this;
				var params=JSON.parse(JSON.stringify(this.datainfo))
				params.examine=type;
				examineResident(params).then(res=>{
					if(res.code==200){
						this.$toast('审核成功')
						setTimeout(function() {
							uni.$emit('refHouseList')
							uni.navigateBack({
								delta:1
							})
						}, 1500);
					}
				})
			},
			getChose(idx){
				this.choseidx=idx;
			},
			getAddfb(){
				var obj={
					"ownerName":"",//权利人姓名
					"location":"",//房屋坐落位置
					"rightType":"",//权利类型,如所有权、使用权等
					"area":"",//房屋面积,单位为平方米
					"documentNumber":"",//房屋相关的字第号
					"propertyUnitNumber":"",//不动产单元号
					"coOwnership":"",//房屋的共有情况,如共有比例等
					"usageType":"",//房屋用途,如住宅、商业等
					"usagePeriod":"",//房屋使用期限
					"registrationDate":"",//房屋登记日期
					"coOwner":"",//共有人姓名,多个共有人可以用逗号分隔
					"detailedAddress":"",//房屋的详细门牌号
					"hasParkingSpace":"",//是否有车位,Y表示有,N表示无
					"communityName":"",//房屋所在小区名称
					"houseStatus":"",//房屋状态:1-自住,2-出租,3-空闲,4-待售
					"parkingNumber":'',//车位号
				}
				this.houseInfoRedidentList.push(obj)
			},
			getDelfb(idx){
				this.houseInfoRedidentList.splice(idx,1)
			},
			statusFormats(data, list,type) {
				var aite=selectValueKey(list, data);
				if(type=='qllx'){
					this.qllxidx=aite.key;
				}else if(type=='rylx'){
					this.rylxidx=aite.key;
				}else if(type=='hzgx'){
					this.hzgxidx=aite.key;
				}else if(type=='fwzt'){
					this.fwztidx=aite.key;
				}else if(type=='fwyt'){
					this.fwytidx=aite.key;
				}else if(type=='ywcw'){
					this.ywcwidx=aite.key;
				}else if(type=='tenant'){
					this.tenantName=aite.actions;
				}else if(type=='rymm'){
					this.rymmidx=aite.key;
				}else if(type=='dslx'){
					this.dslxidx=aite.key;
				}
				return aite.actions;
			},
			getchangea(e){
				var tenantId=this.datainfo.tenantId;
				this.datainfo.tenantId=e.dictValue;
				this.houserinfo.communityName=e.dictLabel;
				// 业主或租户
				if(this.datainfo.residentType!=3){
					this.listNoPageTenant(e.dictValue)
				}
			},
			getchange(e){
				this.datainfo.houseId=e.dictValue;
				this.datainfo.detailedAddress=e.dictLabel;
				this.houserinfo.detailedAddress=e.dictLabel;
				this.houserinfo.houseId=e.dictValue;
				this.houserinfo.location=e.location;
			},
			// 获取租户列表
			gettenantList(){
				gettenantList().then(res=>{
					if(res.code==200){
						if(res.data.voList&&res.data.voList.length){
							this.voList = res.data.voList.map(v => {
								return {
									dictLabel: v.companyName,
									dictValue: v.tenantId
								}
							})
						}
						
					}else{
						this.$toast(res.msg)
					}
				})
			},
			listNoPageTenant(id){
				var params={
					tenantId:id,
				}
				listNoPageTenant(params).then(res=>{
					if(res.code==200){
						this.fwlist= res.data.map(v => {
							return {
								dictLabel: v.detailedAddress,
								dictValue: v.houseId,
								location: v.location
							}
						})
						// if(res.rows&&res.rows.length<2){
						// 	var newObj=res.rows[0];
						// 	this.datainfo.houseId=newObj.houseId;
						// 	this.datainfo.detailedAddress=newObj.detailedAddress
						// }
					}
				})
			},
			init(){
				// 人员类型
				getDictionaryFn('resident_Type').then(res=>{
					if(res.code==200){
						this.rylxList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				// 是否
				getDictionaryFn('sys_yes_no').then(res=>{
					if(res.code==200){
						this.sfList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				//户主关系
				getDictionaryFn('relationship_householder').then(res=>{
					if(res.code==200){
						this.hzgxList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				// 房屋状态
				getDictionaryFn('house_status').then(res=>{
					if(res.code==200){
						this.fwztList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				//权利类型
				getDictionaryFn('types_rights').then(res=>{
					if(res.code==200){
						this.qllxList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				//房屋用途
				getDictionaryFn('use_remises').then(res=>{
					if(res.code==200){
						this.fwytList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				//人员面貌
				getDictionaryFn('affiliation_personnel').then(res=>{
					if(res.code==200){
						this.rymmList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				// 特殊类型
				
				getDictionaryFn('special_type').then(res=>{
					if(res.code==200){
						this.dslxList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: v.dictValue
							}
						})
					}
				})
				//性别
				getDictionaryFn('gender').then(res=>{
					if(res.code==200){
						this.xbList = res.data.map(v => {
							return {
								dictLabel: v.dictLabel,
								dictValue: Number(v.dictValue)
							}
						})
					}
				})
				
			},
			getBackFn(){
				uni.navigateBack({
					delta:1
				})
			},
			bindDateChange(e){
				var val=e.detail.value;
				this.houserinfo.rightType=this.qllxList[val].dictValue;
				this.qllx=this.qllxList[val].dictLabel;
			},
			bindDateChangea(e){
				var val=e.detail.value;
				this.houserinfo.registrationDate=val;
			},
			bindDateChangeb(e){
				var val=e.detail.value;
				this.houserinfo.houseStatus=this.fwztList[val].dictValue;
				this.fwzt=this.fwztList[val].dictLabel;
			},
			bindDateChangec(e){
				var val=e.detail.value;
				this.houserinfo.usageType=this.fwytList[val].dictValue;
				this.fwyt=this.fwytList[val].dictLabel;
			},
			bindDateChanged(e){
				var val=e.detail.value;
				this.houserinfo.hasParkingSpace=this.ywcwList[val].dictValue;
				this.ywcw=this.ywcwList[val].dictLabel;
			},
			bindDateChangee(e){
				var val=e.detail.value;
				this.datainfo.residentType=this.rylxList[val].dictValue;
				this.rylx=this.rylxList[val].dictLabel;
			},
			bindDateChangef(e){
				var val=e.detail.value;
				this.datainfo.residentAppearance=this.rymmList[val].dictValue;
				this.rymm=this.rymmList[val].dictLabel;
			},
			bindDateChangeg(e){
				var val=e.detail.value;
				this.datainfo.specialType=this.dslxList[val].dictValue;
				this.dslx=this.dslxList[val].dictLabel;
			},
			getDetail(){
				residentInfoDet(this.id).then(res=>{
					if(res.code==200){
						this.datainfo=res.data;
						if(res.data.facePhoto){
							this.phofile=res.data.facePhoto.split(',')
						}
						var data=JSON.parse(JSON.stringify(res.data))
						if(data.residentType!=3){
							this.listNoPageTenant(data.tenantId)
						}
						if(res.data.houseInfoRedidentList&&res.data.houseInfoRedidentList.length&&res.data.houseInfoRedidentList[0]){
							var houseinfo=res.data.houseInfoRedidentList[0]
							this.houserinfo=JSON.parse(JSON.stringify(houseinfo))
						}
						
					}
				})
			},
			getSubmit(){
				var that=this;
				this.$refs.form.validate().then(res => {
					var params=JSON.parse(JSON.stringify(this.datainfo))
					var phofile=JSON.parse(JSON.stringify(this.phofile))
					// if(phofile&&phofile.length){
					// 	params.facePhoto=this.phofile.join(',');
					// }
					params.facePhoto=this.phofile.join(',');
					if(!params.tenantId){
						this.$toast('请选择小区名称')
						return
					}
					if(params.residentType==1&&params.isHouseholder=='Y'){
						var houserinfo=JSON.parse(JSON.stringify(this.houserinfo))
						if(!houserinfo.location){
							this.$toast('请输入房屋坐落')
							return
						}
						if(!houserinfo.area){
							this.$toast('请输入房屋面积')
							return
						}
						if(!houserinfo.detailedAddress){
							this.$toast('请输入详细门牌号')
							return
						}
						houserinfo.tenantId=params.tenantId;
						var newarr=[]
						newarr.push(houserinfo)
						params.houseInfoRedidentList=JSON.parse(JSON.stringify(newarr))
					}
					if(params.residentType==2){
						params.isTenant='Y'
					}else{
						params.isTenant=''
					}
					// if(!params.detailedAddress){
					// 	this.$toast('请选择居住门户')
					// 	return
					// }
					// let _IDRe18 =
					// 	/^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
					// let _IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
					// // 校验身份证:
					// if (params.residentIdCard&&!_IDRe18.test(params.residentIdCard) && !_IDre15.test(params.residentIdCard)) {
					// 	this.$toast("请输入正确身份证号")
					// 	return
					// }
					if(this.ptype=='add'){
						if(this.rzflag){
							residentInfoAdd(params).then(res=>{
								if(res.code==200){
									this.$toast("新增成功")

									setTimeout(function(){
										uni.$emit("residentInfoList")
										var initFace='';
										that.$store.dispatch('checkInitFace', initFace).then(() => {
											
										})
										uni.navigateBack({
											delta:1
										})
									},1500)
								}
							})
						}else{
							
						}
					}else{
						if(this.rzflag){
							params.isFilter=true;
							residentInfoPut(params).then(res=>{
								if(res.code==200){
									this.$toast("修改成功")
									setTimeout(function(){
										uni.$emit("residentInfoList")
										var initFace='';
										that.$store.dispatch('checkInitFace', initFace).then(() => {
											
										})
										uni.navigateBack({
											delta:1
										})
									},1500)
								}
							})
						}else{
							authenticationPut(params).then(res=>{
								if(res.code==200){
									this.$toast("修改成功")
									setTimeout(function(){
										uni.$emit("residentInfoList")
										uni.navigateBack({
											delta:1
										})
									},1500)
								}
							})
						}
						
					}	
				})
			},
			getPreviewa(idx,arr) {
				var newArr=[];
				arr.forEach(ite=>{
					var ds=this.baseUrl+ite
					newArr.push(ds)
				})
				uni.previewImage({
					urls: newArr,
					current:idx,
					success: function(data) {},
					fail: function(err) {}
				});
			},
			getPreview(img) {
				var newArr=[];
				var url=this.baseUrl+img
				newArr.push(url)
				uni.previewImage({
					urls: newArr,
					current:0,
					success: function(data) {},
					fail: function(err) {}
				});
			},
			getDelFn(idx,type){
				var that=this;
				uni.showModal({
					title: '确认删除',
					content: "是否确认删除",
					cancelText: '取消',
					confirmText: '确认',
					success: function(res) {
						if (res.confirm) {
							that.phofile.splice(idx,1)	
						} else if (res.cancel) {
						}
					}
				});
			},
			getaddImageava(type){
				if(this.isdisabled){
					return
				}
				let that = this;
				let file =[],count=9
				uni.chooseImage({
					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 = [];
							uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
								that.phofile = that.phofile.concat(rs);
							})	
						}
					}
				});
			},
			getaddImage(type){
				if(this.isdisabled){
					return
				}
				let that = this;
				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(type=='front'){
									that.datainfo.idCardBack = resurl.fileName;
									if (rs && rs.length > 0) {
										var obj = {
											type:type,
											url: resurl.urlOnline
										}
										that.getOcrIdCard(obj)
									}
								}else{
									that.houserinfo.houseImage=resurl.fileName
								}
								
								// if(rs&&rs.length>0){
								// 	var obj={
								// 		url:resurl.urlOnline
								// 	}
								// 	that.getOcrIdCardfz(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.residentName = datainfo.realName;
							this.datainfo.residentIdCard = datainfo.idCard;
							this.datainfo.idCardAddress = datainfo.address;
						// } else {
						// 	this.datainfo.expirationDate = datainfo.expirationDate
						}
					}
				})
			},
			getOcrIdCardfz(obj){
				var params={
					image:obj.url
				}
				getrealEstateCertificatee(params).then(res=>{
					if(res.code==200){
						var datainfo=res.data;
						// var obj=JSON.parse(JSON.stringify(this.houseInfoRedidentList[idx]))
						this.houserinfo.ownerName=datainfo.ownerName;
						this.houserinfo.location=datainfo.location;
						this.houserinfo.rightType=datainfo.rightType;
						this.houserinfo.area=datainfo.area;
						this.houserinfo.documentNumber=datainfo.documentNumber;
						this.houserinfo.propertyUnitNumber=datainfo.propertyUnitNumber;
						this.houserinfo.coOwnership=datainfo.coOwnership;
						this.houserinfo.usageType=datainfo.usageType;
						this.houserinfo.usagePeriod=datainfo.usagePeriod;
						this.houserinfo.registrationDate=datainfo.registrationDate;
						this.houserinfo.coOwner=datainfo.coOwner;
						// this.houseInfoRedidentList.splice(idx,1,obj)
					}
				})
			},
		}
	}
</script>
<style>
	page{background: #F3F3F0;}
</style>
<style lang="scss" scoped>
.coa /deep/ .uni-date__x-input{text-align: right;color: #AAAAAA;}
.check /deep/ .select-wrap{border: none;width: 100%;}
.mh35{min-height: 70rpx;display: flex;align-items: center;}
.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 .chmain /deep/ .isnobor{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-data-checklist{flex: 0 0 auto;}
.check /deep/ .is-required{font-size: 26rpx;color: #F40027;margin-right: 4rpx;}
.check /deep/ .uni-collapse{background-color: transparent;}
// .check /deep/ .uni-collapse .chmain{margin-bottom: 24rpx;}
.check{min-height: 100vh;box-sizing: border-box;padding: 20rpx 18rpx 54rpx;}
.cbox{
	.chtit{font-weight: 500;font-size: 24rpx;color: #666666;padding:20rpx 14rpx;}
	.chmain{
		padding: 0rpx 28rpx;background: #FFFFFF;border-radius: 20rpx;
		.rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
			image{width: 100%;height: 100%;}
		}
	}
	.hbtns{font-weight: bold;display: flex;align-items: center;justify-content: center;font-size: 26rpx;height: 88rpx;border-radius: 20rpx;box-sizing: border-box;
		&.bga{border: 1px solid #0256FD;color: #FFFFFF;background: #0256FD;}
		&.bgb{border: 1px solid #0256FD;color: #0256FD;background: #CADBFF;}
		
	}
	.sylist{background: #F0F0F0;border-radius: 26rpx;border:2rpx solid #DADADA;margin-left: 26rpx;font-weight: 500;min-width:112rpx;height: 54rpx;box-sizing: border-box;
	font-size: 26rpx;
	color: #666666;
		&.act{border: 2rpx solid #0256FD;background: #DCE8FF;color: #0256FD;}
	}
	.cmico{width: 48rpx;height: 48rpx;margin-left: 16rpx;}
	.delbox{padding: 12rpx 32rpx;
		image{width: 26rpx;height: 26rpx;margin-right: 14rpx;}
		view{font-weight: 500;font-size: 26rpx;color: #FF6969;}
	}
}
.addbox{width: 160rpx;height: 128rpx;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;margin-bottom: 12rpx;}
		view{font-weight: 500;font-size: 24rpx;color: #666666;}
	}
.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;}
	}
}
.hfbtns{margin-top: 60rpx;
	.btn{height: 88rpx;background: #FFF8F8;border-radius: 20rpx;width: 316rpx;display: flex;align-items: center;justify-content: center;font-weight: bold;
font-size: 26rpx;box-sizing: border-box;
		&.btn1{border: 2rpx solid #FF6969;background: #FFF8F8;color: #FF6969;}
		&.btn2{background: #0256FD;color: #ffffff;}
	}
}
</style>