<template>
	<view class="page">
		<view class="dataBox" style="padding-bottom: 70px;">
			<view v-for="(item,index) in selectdataList" :key="index">
				<view class="itemBox">
					<view class="tip" v-if="item.tip">
						{{item.tip}}
					</view>
					<view class="name">
						{{item.name}} 
						<text v-if="item.tip2" class="tip2">{{item.tip2}}</text>
						<text v-if="item.type==1" style="font-size: 24rpx;color: #999999;">(照片至少2张)</text>
					</view>
					<view class="imgBox" v-if="item.type==1">
						<view class="left">
							<!-- 大照片 -->
							<view class="img1Box" :style="{'border-color': `${mainColor}`}" @click="chooseImg(0,'img1')">
								<image :src="data.AlbumList[0]" mode="aspectFill" class="img1" v-if="AlbumListShow.img1" ></image>
								<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img1" style="width: 100rpx;height: auto;" ></image>
								<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img1" @click.native.stop="deleteimg(0,'img1')"></u-icon>
							</view>
							
							 <view class="subImgBox">
								 <!-- 下面三张照片 -->
								 <view class="img2Box" @click="chooseImg(1,'img2')" :style="{'border-color': `${mainColor}`}">
								 	<image :src="data.AlbumList[1]" mode="aspectFill" class="img2" v-if="AlbumListShow.img2"></image>
									<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img2" class="imgDemo"></image>
									<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img2" @click.native.stop="deleteimg(1,'img2')"></u-icon>
								 </view>
							 	<view class="img2Box" @click="chooseImg(2,'img3')" :style="{'border-color': `${mainColor}`}">
							 		<image :src="data.AlbumList[2]" mode="aspectFill" class="img2" v-if="AlbumListShow.img3"></image>
									<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img3" class="imgDemo"></image>
									<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img3" @click.native.stop="deleteimg(2,'img3')"></u-icon>
							 	</view>
								<view class="img2Box" @click="chooseImg(3,'img4')" :style="{'border-color': `${mainColor}`}">
									<image :src="data.AlbumList[3]" mode="aspectFill" class="img2" v-if="AlbumListShow.img4"></image>
									<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img4" class="imgDemo"></image>
									<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img4" @click.native.stop="deleteimg(3,'img4')"></u-icon>
								</view>
								
							 </view>
						</view>
						<view class="right">
							<!-- 右边四张照片 -->
							<view class="img2Box" @click="chooseImg(4,'img5')" :style="{'border-color': `${mainColor}`}">
								<image :src="data.AlbumList[4]" mode="aspectFill" class="img2" v-if="AlbumListShow.img5"></image>
								<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img5" class="imgDemo"></image>
								<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img5" @click.native.stop="deleteimg(4,'img5')"></u-icon>
							</view>
							<view class="img2Box" @click="chooseImg(5,'img6')" :style="{'border-color': `${mainColor}`}">
								<image :src="data.AlbumList[5]" mode="aspectFill" class="img2" v-if="AlbumListShow.img6"></image>
								<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img6" class="imgDemo"></image>
								<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img6" @click.native.stop="deleteimg(5,'img6')"></u-icon>
							</view>
							<view class="img2Box" @click="chooseImg(6,'img7')" :style="{'border-color': `${mainColor}`}">
								<image :src="data.AlbumList[6]" mode="aspectFill" class="img2" v-if="AlbumListShow.img7"></image>
								<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img7" class="imgDemo"></image>
								<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img7" @click.native.stop="deleteimg(6,'img7')"></u-icon>
							</view>
							<view class="img2Box" @click="chooseImg(7,'img8')" :style="{'border-color': `${mainColor}`}">
								<image :src="data.AlbumList[7]" mode="aspectFill" class="img2" v-if="AlbumListShow.img8"></image>
								<image :src="photoDemo" mode="widthFix" v-if="!AlbumListShow.img8" class="imgDemo"></image>
								<u-icon name="clear" color='#F70027' size='50' class='gibistyle'  v-if="AlbumListShow.img8" @click.native.stop="deleteimg(7,'img8')"></u-icon>
							</view>
						</view>
					</view>
					<view class="conBox" v-if="item.type==2">
						<view v-for="(item1,index1) in item.childDataList" :key="index1">
							<view class="subItemBox" v-if="item1.subType!=4">
								 <view class="subName">
									{{item1.name}}
									<text v-if="item1.must!=undefined && item1.must" style="font-size: 12px;color: #F70027;margin-left: 3px;font-weight: normal;">*</text>
								 </view>
								 
								 <input  v-if="item1.name=='昵称' && item1.subType==1" maxlength='10' :placeholder="item1.placehloder" :disabled="item1.disabled" v-model="data[item1.field]" :type="item1.showType" class="subInput" />
								 <input  v-if="item1.name=='微信号' && item1.subType==1" maxlength='20' :placeholder="item1.placehloder" :disabled="item1.disabled" v-model="data[item1.field]" :type="item1.showType" class="subInput" />
								 <input  v-if="item1.name!='昵称'&&item1.name!='微信号'  && item1.subType==1" :placeholder="item1.placehloder" :disabled="item1.disabled" v-model="data[item1.field]" :type="item1.showType" class="subInput" @input='srnumber($event,item1.field)' />
									<!-- 显示有昵称的长度 -->
								<view class="unit" v-if="item1.name=='昵称' && item1.subType==1">{{data[item1.field].length}}/10</view>
								<view class="unit" v-if="item1.name=='微信号' && item1.subType==1">{{data[item1.field].length}}/20</view>
								 <view class="unit" v-if="item1.unit">
								 	{{item1.unit}}
								 </view>
								 <view class="subpicker" v-if="item1.subType==2">
								 	<picker :mode ="item1.mode" class="subpicker" range-key='Name' :disabled="item1.disabled" :range="item1.array" @change="changPicker($event,item1.field,item1.mode,item1.array)">
								 	       <!-- <input class="subInput" disabled type="text" :disabled="item1.disabled" :placeholder="item1.placehloder" v-model="data[item1.field]" /> -->
										   <view style="display: flex;align-items: center;justify-content: space-between;">
											   <text class="subInput" :style="{'color':data[item1.field]==''?'#B6B6B6':'#111111'}">{{data[item1.field]==''?item1.placehloder : data[item1.field]}}</text>
											   <u-icon  name="arrow"></u-icon>
										   </view>
								 	</picker>
									 
								 </view>
								 <view class="subpicker" v-if="item1.subType==3"  @click="addressShow = true">
									<Text :style="{'color':address!=''? '#303133':'#9D9C9B'}">{{address!=''? address :'请选择'}}</Text>
								 	<pickerAddress v-model="addressShow" @confirm="addresspick()" />
								 </view>
								 <view class="subpicker" v-if="item1.subType==5"  @click="addressShow2 = true">
									<Text  :style="{'color':location!=''? '#303133':'#9D9C9B'}">{{location!=''? location :'请选择'}}</Text>
								 	<pickerAddress v-model="addressShow2" @confirm="addresspick2()" />
								 </view>
							</view>
							<!-- 头像上传的情况 4-26新加 -->
							<view class="subItemBox" v-if="item1.subType==4" style="height: 140rpx;justify-content: flex-start">
								<view class="subName">
									{{item1.name}}
									<text v-if="item1.must!=undefined && item1.must" style="font-size: 12px;color: #F70027;margin-left: 3px;font-weight: normal;">*</text>
								</view>
								<view >
									<u-upload ref="uUpload" :action="action" :custom-btn="true" @on-success="uploadSuccessHandler" :show-upload-list="showUploadList"
									 :file-list="fileList" :multiple='false'>
										<u-avatar :src="data.Photo" size="110" slot="addBtn" mode="square"></u-avatar>
									</u-upload>
								</view>
							</view>
						</view>	
					</view>
					<view class="conBox" v-if="item.type==3">
						<textarea v-model="data[item.field]" class="textareaBox" maxlength='500' :placeholder="item.placehloder" />
					</view>
					
				</view>
				
			</view>
		</view>
		<view style="width: 100%;height:60px;position: fixed;left: 0;bottom: 0;display: flex;align-items: center;justify-content: center;background: #FFF;z-index: 99;">
			<view class="saveBtn" :style="{'background-color': `${mainColor}`}" @click="saveData">
				保存
			</view>
		</view>
		
	</view>
</template>

<script>
	import pickerAddress from './liudx-pickerAddress/index.vue'
	export default{
		components:{
			pickerAddress
		},
		data(){
			return{
				UserId:0,
				pageTitle:"编辑个人主页",
				mainColor: "",
				dataList:[{
					name:"相册",
					data:{},
					type:1
				},{
					name:"基础资料",
					tip:"基本资料（实名认证通过后，部分资料无法修改）",
					data:{},
					//subType:1输入框，2选择框
					childDataList:[{
						name:"昵称",
						field:"Name",
						placehloder:"请填写昵称",
						subType:1,
						showType:"text",
						disabled:false,
						must:true,//必填
					},{
						name:"头像",
						field:"Name",
						placehloder:"请填写头像",
						subType:4,
						showType:"text",
						disabled:false,
						must:true,//必填
					},{
						name:"出生日期",
						field:"Birthday",
						placehloder:"请选择出生日期",
						subType:2,
						array:"",
						mode:"date",
						disabled:false,
						must:true,
					},{
						name:"性别",
						field:"SexStr",
						placehloder:"请选择性别",
						subType:2,
						array:[{Name: "男", Id: 1}, {Name: "女", Id: 2}],
						mode:"selector",
						disabled:false,
						must:true,
					},{
						name:"身高",
						field:"Height",
						placehloder:"请填写身高",
						subType:1,
						unit:"厘米",
						showType:"number",
						disabled:false,
						must:true,
					},{
						name:"体重",
						field:"Weight",
						placehloder:"请填写体重",
						subType:1,
						unit:"公斤",
						showType:"number",
						disabled:false,
						must:true,
					},{
						name:"现居住地",
						field:"location",
						placehloder:"请选择现居住地",
						subType:5,
						array:[],
						mode:"region",
						must:true,
					},{
						name:"籍贯",
						field:"nativePlace",
						placehloder:"请选择籍贯",
						subType:3,
						array:[],
						mode:"region"
					},{
						name:"婚姻",
						field:"MarriageStr",
						placehloder:"请选择婚姻状况",
						subType:2,
						array:[],
						mode:"selector",
						disabled:false,
						must:true,
					},
						
					],
					type:2
				},{
					name:"详细资料",
					tip:"",
					data:{},
					//subType:1输入框，2选择框
					type:2,
					childDataList:[
						{
							name:"学历",
							field:"EducationTypeStr",
							placehloder:"请选择学历",
							subType:2,
							array:[],
							mode:"selector",
							disabled:false,
							must:true,
						},{
							name:"房屋",
							field:"HouseInfoStr",
							placehloder:"请选择房屋情况",
							subType:2,
							array:[],
							mode:"selector",
							disabled:false,
							must:true,
						},{
							name:"车辆",
							field:"CarInfoStr",
							placehloder:"请选择车辆情况",
							subType:2,
							array:[],
							mode:"selector",
							disabled:false,
							must:true,
						},{
							name:"年收入",
							field:"YearMoney",
							placehloder:"请填写年收入",
							subType:1,
							unit:"万",
							showType:"number",
							disabled:false,
							must:true,
						},{
							name:"毕业院校",
							field:"SchoolInfo",
							placehloder:"请填写毕业院校",
							subType:1,
							showType:"text",
							disabled:false,
							
						},{
							name:"工作单位",
							field:"WorkUnit",
							placehloder:"请填写工作单位",
							subType:1,
							showType:"text",
							disabled:false
						},{
							name:"职位",
							field:"Job",
							placehloder:"请填写职位",
							subType:1,
							showType:"text",
							disabled:false
						},
					],
					
				},
				{
					name:"联系方式",
					tip:"",
					data:{},
					//subType:1输入框，2选择框
					type:2,
					childDataList:[
						{
							name:"微信号",
							field:"WechatNo",
							placehloder:"请输入微信号",
							subType:1,
							showType:"text",
							disabled:false,
							must:true,
						},
						{
							name:"手机号码",
							field:"Moblie",
							placehloder:"请输入手机号码",
							subType:1,
							showType:"number",
							disabled:false,
							must:true,
						},
					],
					
				},
				
				],
				dataList_t:[{
					name:"自我描述",
					field:"About",
					placehloder:"自我描述",
					type:3
				  },{
					name:"家庭背景",
					field:"FamilyInfo",
					placehloder:"家庭成员、工作、成长环境等",
					type:3
				  },{
					name:"业余爱好",
					field:"Hobby",
					placehloder:"唱歌、跳街舞、拍照、旅游、看电影、画画、自驾游、等",
					type:3
				  }, {
				  	name:"曾经旅游过的地方",
				  	field:"ActivityRegion",
				  	placehloder:"去过好玩的旅游胜地",
				  	type:3
				  },{
					name:"理想的另一半是什么样的",
					field:"HopeYou",
					placehloder:"说出你对另一半的期许",
					type:3
				  },{
					name:"期待的未来生活是怎样的",
					field:"OtherInfo",
					placehloder:"写下你期待的未来生活是怎样的",
					type:3
				  }, {
					name:"最喜欢的一本书及原因",
					field:"LikeBook",
					placehloder:"写下你喜欢的书的名称",
					type:3
				  }, {
					name:"最喜欢的电影及原因",
					field:"LikeTV",
					placehloder:"写下最喜欢的电影及原因",
					type:3
				  },
				  
				  
				  
				  
				{
					name:"欣赏哪对名人的爱情，原因是什么",
					field:"IdealLove",
					placehloder:"快来说说吧",
					type:3
				  },
				
				 
				],
				selectdataList:[],
				showtype:1,
				photoDemo:"https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Static/camera.png",//占位图片
				data:{
					Name:"",
					Sex:"",
					SexStr:"",
					Birthday:"",
					Height:"",
					Weight:"",
					EducationType:0,
					EducationTypeStr:"",
					SchoolInfo:"",
					Marriage:0,
					MarriageStr:"",
					Job:"",
					WorkUnit:"",
					YearMoney:"",
					// NativePlace:"",//籍贯（省）
					// HuKou:"",//籍贯（国家）
					OtherInfo:"",
					nativePlace:"",//自定义籍贯
					addCode:"",//行政编码
					FamilyInfo:"",
					Hobby:"",
					LikeFood:"",
					LikeBook:"",
					LikeTV:"",
					LikeSong:"",
					IdealLove:"",
					LoveTalk:"",
					SingleReason:"",
					HopeYou:"",
					About:"",
					Appointment:"",
					AppointmentAddress:"",
					CName:"",//市名称
					DName:"",//区名称
					PName:"",//省名称
					Province:0,//省行政编码
					City:0,//市行政编码
					District:0,//区行政编码
					AlbumList:[],//照片墙
					Age:0,
					HouseInfo:0,//房屋信息
					CarInfo:0,//车辆信息
					IDCardNo:'',//身份证号 
					ActivityRegion:'',//活动区域
					IDCard:'',//身份证信息正面
					IDCardBack:'',//反面
					Moblie:'',//手机号
					WechatNo:'',//微信号
					location:'',//暂时参数个人定位
					DWProvince:0,//个人省
					DWCity:0,//个人市
					DWDistrict:0,//个人区 
				},
				locationtype:'',//判断地址选择是那个
				//控制图片显示
				AlbumListShow:{
					img1:false,
					img2:false,
					img3:false,
					img4:false,
					img5:false,
					img6:false,
					img7:false,
					img8:false,
				},
				addressShow:false,
				addressShow2:false,
				address:'',
				location:'',
				Jumptype:0,
				action:'',
				showUploadList:false,
				fileList:[],
			}
		},
		onShareAppMessage(res) {
		  let u = uni.getStorageSync("mall_UserInfo");
		  let uid = u.UserId ? u.UserId : 0;
			if(uid==0){
				uid = uni.getStorageSync("pid")?uni.getStorageSync("pid").pid:0
			}
		  let SmallShopId = u.SmallShopId ? u.SmallShopId : 0;
			if(SmallShopId == 0){//如果微店id为0 去找所属微店id
				SmallShopId = u.UserSmallShopId? u.UserSmallShopId:0
			}
			let Up = uni.getStorageSync("mall_UserInfo")?uni.getStorageSync("mall_UserInfo").UserPageType:0;
			console.log("/pages/index/index?&user_id=" + uid+ "&SmallShopId=" + SmallShopId+ "&Up=" + Up+'&JumpType=14')
		  return {
		    title:'邀请填写相亲资料',
		    path: "/pages/index/index?&user_id=" + uid+ "&SmallShopId=" + SmallShopId+ "&Up=" + Up+'&JumpType=14',
		    imageUrl:'',
		  };
		},
		methods:{
			changPicker(arg,e,mode,arr){
				if(mode=="selector"){
					this.data[e]=arr[arg.detail.value].Name;
					if(e == 'EducationTypeStr'){//把对应的id赋值
						this.data.EducationType = arr[arg.detail.value].Id;
					}else if(e == 'MarriageStr'){
						this.data.Marriage = arr[arg.detail.value].Id;
					}
					else if(e == 'HouseInfoStr'){
						this.data.HouseInfo = arr[arg.detail.value].Id;
					}
					else if(e == 'CarInfoStr'){
						this.data.CarInfo = arr[arg.detail.value].Id;
					}
				}else if(mode=="date"){
					this.data[e]=arg.detail.value
				}else if(mode=="region"){
					this.data.nativePlace=JSON.parse(JSON.stringify(arg.detail.value)).join(",")
					this.data.addCode=JSON.parse(JSON.stringify(arg.detail.code)) 
					this.$forceUpdate()
				}
			},
			addresspick(obj,type) {
				this.data.PName=obj.province.Name
				this.data.Province=obj.province.ID
				this.data.CName=obj.city.Name
				this.data.City=obj.city.ID
				this.data.DName=obj.area.Name
				this.data.District=obj.area.ID
				this.address=obj.province.Name+','+obj.city.Name+','+obj.area.Name
			},
			addresspick2(obj){
				this.data.DWProvince=obj.province.ID
				this.data.DWCity=obj.city.ID
				this.data.DWDistrict=obj.area.ID
				this.location=obj.province.Name+','+obj.city.Name+','+obj.area.Name
			},
			deleteimg(index,key){
				let that = this
				that.data.AlbumList[index]='';
				that.AlbumListShow[key]=false ;
				that.$forceUpdate()
			},
			chooseImg(index,key) {
				let that = this
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						 that.upFile(res.tempFilePaths[0],(_res)=>{
							  let resData=JSON.parse(_res.data)
							  that.data.AlbumList[index]=resData.data
							  that.AlbumListShow[key]=true ;
							  that.$forceUpdate()
						 })
					}
				});
				
			},
			upFile(img, resCall) {
				var that = this;
				wx.showLoading({
					title: '上传中'
				})
				
				uni.uploadFile({
					url: that.action,
					filePath: img,
					name: 'field',
					formData: {
						user: 'test'
					},
					success: (uploadFileRes) => {
						uni.hideLoading()
						resCall(uploadFileRes)
					},
					fail: function(res) {
						uni.hideLoading()
						wx.showToast({
							title: '上传失败!',
							icon: 'none',
							duration: 1000
						})
					}
				});
			},
			saveData(){
				let msg=JSON.parse(JSON.stringify(this.data))
				msg.Id=0
				if(this.data.AlbumList.length>0){
					msg.AlbumList=msg.AlbumList.filter((item)=>(item))
				}
				if(this.data.AlbumList.length<2){
					uni.showToast({
					    title: '照片墙至少2张',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(msg.Age==""){
					msg.Age=0
				}else{
					msg.Age=parseInt(msg.Age)
				}
				
				delete msg.nativePlace
				delete msg.addCode
				delete msg.location
				
				if(this.data.Name == ''){
					uni.showToast({
					    title: '昵称不能为空',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.SexStr=="男"){
					msg.Sex=1
				}else{
					msg.Sex=2
				}
				if(this.data.Birthday==""){
					uni.showToast({
					    title: '请选择出生日期',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				
				
				if(this.data.Birthday==""){
					uni.showToast({
					    title: '请选择出生日期',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.Moblie==""){
					uni.showToast({
					    title: '请输入电话号码',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.WechatNo==""){
					uni.showToast({
					    title: '请输入微信号',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.Height ==""){
					uni.showToast({
					    title: '请填写身高',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.Weight==""){
					uni.showToast({
					    title: '请填写体重',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.EducationType==0){
					uni.showToast({
					    title: '请选择学历',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.Marriage==0){
					uni.showToast({
					    title: '请选择婚姻状况',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.YearMoney==""){
					uni.showToast({
					    title: '请填写年收入',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.HouseInfo==0){
					uni.showToast({
					    title: '请选择房屋信息',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.CarInfo==0){
					uni.showToast({
					    title: '请选择车辆信息',
					    duration: 2000,
						icon:"none"
					});
					return
				}
				if(this.data.DWProvince==0){
					uni.showToast({
					    title: '请选择个人定位',
					    duration: 2000,
						icon:"none"
					});
					return
				}
			
				// if(this.data.address==""){
				// 	uni.showToast({
				// 	    title: '请选择籍贯',
				// 	    duration: 2000,
				// 		icon:"none"
				// 	});
				// 	return
				// }
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - 2]; // 前一个页面
				this.request2({
						url: '/api/AppletMiai/GetSetMiAiBaseInfo',
						data: msg
					},
					res => {
						if (res.resultCode == 1) {
							uni.showToast({
							    title: res.message,
							    duration: 2000,
								icon:"success",
								success:()=>{
									setTimeout(()=>{
										if(this.Jumptype == 0){
											uni.navigateBack({
											    delta: 1
											});
										}else if(this.Jumptype == 1){
											uni.reLaunch({
												url: '/pages/blindDate/persondetails?UserId='+ this.UserId+'&Jumptype=1'
											})
										}else if(this.Jumptype == 2){
											uni.navigateBack({
												 success: function() {
													 beforePage.$vm.getisAttestation(); // 执行前一个页面的方法
												 }
											});
										}
										
										
									},1000)
									
								}
							});
							
						}
					}
				);
			},
			getEnumList(){//学历
				this.request2(
					{
						url: '/api/AppletMiai/GetEducationTypeEnumList',
						data: {}
					},
					res => {
						if(res.resultCode==1){
							if(res.data.length > 0){
								this.dataList[2].childDataList.map(x=>{
									if(x.name == '学历'){
										x.array = res.data;
										return
									}
								})
							}
							
						}
					}
				);
			},
			getMarriage(){
				this.request2(
					{
						url: '/api/AppletMiai/GetMarriageEnumList',
						data: {}
					},
					res => {
						if(res.resultCode==1){
							if(res.data.length > 0){
								this.dataList[1].childDataList.map(x=>{
									if(x.name == '婚姻'){
										x.array = res.data;
										return
									}
								})
							}
						}
					}
				);
			},
			GetHouseList(){
				this.request2(
					{
						url: '/api/AppletMiai/GetHouseInfoEnumList',
						data: {}
					},
					res => {
						if(res.resultCode==1){
							if(res.data.length > 0){
								this.dataList[2].childDataList.map(x=>{
									if(x.name == '房屋'){
										x.array = res.data;
										return
									}
								})
							}
						}
					}
				);
			},
			GetCarList(){
				this.request2(
					{
						url: '/api/AppletMiai/GetCarInfoEnumList',
						data: {}
					},
					res => {
						if(res.resultCode==1){
							if(res.data.length > 0){
								this.dataList[2].childDataList.map(x=>{
									if(x.name == '车辆'){
										x.array = res.data;
										return
									}
								})
							}
						}
					}
				);
			},
			
			//获取个人资料
			getInfo(){
				this.request2(
					{
						url: '/api/AppletMiai/GetMiAiBaseIfo',
						data: { UserId:this.UserId}
					},
					res => {
						if(res.resultCode==1){
							this.data=res.data
							if(res.data.PName&&res.data.DName&&res.data.CName){
								this.address=res.data.PName+','+res.data.CName+','+res.data.DName
							}else{
								this.address=""
								
							}
							if(res.data.DWPName&&res.data.DWCName&&res.data.DWDName){
								this.location=res.data.DWPName+','+res.data.DWCName+','+res.data.DWDName
							}else{
								this.location=""
							}
							
							if(res.data.AlbumList){
								res.data.AlbumList.map((item,index)=>{
										this.AlbumListShow[`img${index+1}`]=true
								})
							}
							if(this.data.AlbumList==null){
								this.data.AlbumList=[]
							}
							console.log(this.data)
							if(this.data.Sex==1){
								this.data.SexStr="男"
							}else if(this.data.Sex==2){
								this.data.SexStr="女"
							}else{
								this.data.SexStr="";
								this.dataList[1].childDataList.map(x=>{
									if(x.name == '性别'){
										
										x.disabled = false;
										return
									}
								})
							}
							if(this.data.RealName && this.data.RealName!=''){
								this.dataList[1].childDataList.map(x=>{
									if(x.field == 'Birthday'){
										x.disabled = true;
										return
									}
								})
							}
							
							
						}
					}
				);
			},
			redirectPrev() {
				uni.navigateBack({
					delta: 1,
				});
			},
			upimg(type){//身份证上传
				var that = this;
				uni.chooseImage({
				    count: 1, //默认9
				    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				    success: function (res) {
						
						that.upFile2(res.tempFilePaths[0],type)
				        
				    }
				});
				     
			},
			upFile2(img,type){
				//图片上传
				var that = this;
				wx.showLoading({ title: '上传中' })
				let MallBaseId = uni.getStorageSync("mall_UserInfo").MallBaseId ? uni.getStorageSync("mall_UserInfo").MallBaseId :1;
				let action = that.host2 + '/api/File/UploadTencent?MallBaseId=' + MallBaseId
				uni.uploadFile({
					url: action,
					filePath: img,
					name: 'file',
					formData: {
						user: 'test'
					},
					success: (uploadFileRes) => {
						uni.hideLoading()
						if (uploadFileRes.statusCode == 200) {
							let data = JSON.parse(uploadFileRes.data)
							if(type==1){
								that.data.IDCard = data.data
							}else{
								that.data.IDCardBack = data.data
							}
						}
					},
					fail: function(res) {
						console.log(res)
						wx.showToast({
							title: '上传失败!',
							icon: 'none',
							duration: 1000
						})
					}
				});
			},
			uploadSuccessHandler(data, index, lists) {
			   let r = JSON.parse(data);
			   this.data.Photo = r.data;
			},
			srnumber(e,Name){//处理输入的是01的情况
				let value  = e.target.value;
				value = value.replace(/\b(0+)/gi,"")
				if(Name=='Height' || Name == 'Weight' || Name == 'YearMoney'|| Name == 'Moblie'){
					this.data[Name] = value
				}
			}
		},
		onLoad(options) {
			this.UserId = uni.getStorageSync("mall_UserInfo")?uni.getStorageSync("mall_UserInfo").UserId:null;
			this.getInfo();
			if(options && options.Jumptype){
				this.Jumptype = options.Jumptype
			}
			if(options && options.type){
				this.showtype = options.type;
				if(this.showtype ==1){
					this.selectdataList = this.dataList
				}else{
					this.selectdataList = this.dataList_t
				}
			}
			let MallBaseId = uni.getStorageSync("mall_UserInfo").MallBaseId ? uni.getStorageSync("mall_UserInfo")
				.MallBaseId : 1;
			this.action = this.host2 + '/api/File/UploadTencent?MallBaseId=' + MallBaseId
		},
		created() {
			this.mainColor = this.$uiConfig.mainColor;
			// this.secondary = this.$uiConfig.secondary;
			// this.pricecolor = this.$uiConfig.pricecolor;
		},
		mounted() {
		this.getEnumList();
		this.getMarriage();
		// 4-14
		this.GetHouseList()//获取房屋枚举 
		this.GetCarList()//获取车辆枚举 
		uni.setNavigationBarTitle({
		    title: this.pageTitle
		});
		}
	}
</script>

<style lang="scss" scoped>
	.page{
		padding: 0 30rpx 65rpx;
		.header{
			height: 88rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 32rpx;
			font-weight: 800;
			color: #111111;
			position: relative;
			.arrow{
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				left: 30rpx;
			}
		}
		.dataBox{
			.img2Box{
				width: 147rpx;
				height: 147rpx;
				border-width:1rpx;
				border-style:solid;
				border-radius: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				// overflow: hidden;
				position: relative;
				.img2{
					width: 100%;
					height: 100%;
					border-radius: 20rpx;
				}
				
			}
			.imgDemo{
				width: 54rpx;
				height: auto;
			}
			.itemBox{
				margin-bottom: 40rpx;
				.tip{
					font-size: 24rpx;
					font-weight: 500;
					color: #C1C1C1;
				}
				
				.name{
					font-size: 30rpx;
					font-weight: bold;
					color: #111111;
					margin-top: 20rpx;
					margin-bottom: 20rpx;
					.tip2{
						font-size: 24rpx;
						font-weight: bold;
						color: #111111;
						margin-left: 4rpx;
					}
				}
				
			}
			.imgBox{
				position: relative;
				display: flex;
				justify-content: space-between;
				.left{
					width: 492rpx;
					.img1Box{
						width: 492rpx;
						height: 492rpx;
						border-width:1rpx;
						border-style:solid;
						border-radius: 30rpx;
						margin-bottom: 25rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						// overflow: hidden;
						position: relative;
						.img1{
							width: 100%;
							height: 100%;
							border-radius: 30rpx;
							
						}
						
					}
					.subImgBox{
						width: 492rpx;
						height: 147rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
					}
				}
				.right{
					width: 147rpx;
					display: flex;
					flex-wrap: wrap;
					align-content: space-between;
				}
				
			}
			.conBox{
				.subItemBox{
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 100rpx;
					width: 100%;
					border-bottom: 1rpx solid #E2E2E2FF;
					.subName{
						width: 130rpx;
						font-size: 26rpx;
						font-weight: 500;
						color: #666666;
					}
					.subInput{
						flex-grow: 5;
						font-size: 26rpx;
						font-weight: bold;
						color: #111111;
					}
					.subpicker{
						flex-grow: 5;
						font-size: 26rpx;
						font-weight: bold;
						color: #111111;
						// background-color: #008000;
					}
					.unit{
						font-size: 24rpx;
						font-weight: bold;
						color: #B6B6B6;
					}
				}
				.textareaBox{
					height: 180rpx;
					width: 100%;
					border-bottom: 1rpx solid #E2E2E2FF;
					font-size: 24rpx;
					font-weight: bold;
					color: #111111;
				}
			}
		}
		
	}
	.saveBtn{
		margin: 0 auto;
		width: 690rpx;
		height: 88rpx;
		// background-color: #00C6C1;
		border-radius: 44rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 32rpx;
		font-weight: 500;
		color: #FFFFFF;
		// margin-top: 50rpx;
	}
	/deep/.input-placeholder{
		font-size: 24rpx;
		font-weight: bold;
		color: #999999;
	}
	/deep/.textarea-placeholder{
		font-size: 24rpx;
		font-weight: bold;
		color: #999999;
	}
	.gibistyle{
		position: absolute;
		right: -10px;
		top: -10px;
	}
	.page .sfz{
		width: 100%;
		Height: 130px;
		border-radius: 10px;
		margin-top: 15px;
		background: #F8F8F8;
		display: flex;
		flex-direction: row;
		padding: 17px 20px;
		justify-content: space-between;
	}
	.page	.sfz-l-title{
		font-size: 17px;
		color: #111111;
		font-weight: bold;
		margin-top: 10px;
	}
	.page .sfz-l-c{
		font-size: 12px;
		color: #999999;
		margin-top: 10px;	
	}
	.page .sfz-r{
		width: 286upx;
		Height: 97px;
		
	}
</style>
