<template>
	<view>
		<u-navbar back-text="编辑资料"></u-navbar>
		<view class="edit-head">
			<u-avatar :src="personal_info.faceImage" size="160" :show-level="true" level-icon="edit-pen-fill" level-bg-color ="#4E8DF6" @click="uploadPhoto"></u-avatar>
		</view>
		
		<view class="edit-form">
			<u-form :model="form" ref="uForm" label-width ="160">
				<u-form-item label="姓名"><u-input  :disabled='true' v-model="personal_info.realName" input-align="right" placeholder="周扬青"/></u-form-item>
				<u-form-item label="身份证号"><u-input :disabled='true' v-model="idCard" input-align="right" placeholder="42100***************111"/></u-form-item>
				<u-form-item label="手机号"><u-input :disabled='true' v-model="personal_info.phone" input-align="right" placeholder="1380****9999"/></u-form-item>
				<u-form-item label="性别"><u-input :disabled='true' v-model="form.sex" input-align="right" placeholder="男"/></u-form-item>
				<u-form-item label="年龄"><u-input :disabled='true' v-model="personal_info.age" input-align="right" placeholder="31岁"/></u-form-item>
				<u-form-item label="身高">
					<u-input v-model="form.height" input-align="right" placeholder="172cm" type="select" @click="show_height = true" />
					<u-select v-model="show_height" :defaultValue="defaultData.height" mode="single-column" :list="height_ranges" @confirm="heightConfirm"></u-select>
				</u-form-item>
				<u-form-item label="体重">
					<u-input v-model="form.weight" input-align="right" placeholder="75kg" type="select" @click="show_weight = true"/>
					<u-select v-model="show_weight" :defaultValue="defaultData.weight" mode="single-column" :list="weight_ranges" @confirm="weightConfirm"></u-select>
				</u-form-item>
				
				<view class="edit-line"></view>
				
				<u-form-item label="出身地">
					<u-input v-model="personal_info.birthplaceN" input-align="right" placeholder="荆州市沙市区" type="select" @click='birthdayAddressChange'/>
					<u-select v-model="show_birthday_address" mode="mutil-column-auto" :default-value='defaultData.address' :list="defaultColumns" @confirm="onBirthdayCityConfirm"></u-select>
				</u-form-item>
				<u-form-item label="户口所在地">
					<u-input v-model="personal_info.registeredResidenceN" input-align="right" placeholder="荆州市沙市区" type="select" @click='registeredResidenceAddressChange'/>
					<u-select v-model="show_registered_residence" mode="mutil-column-auto" :default-value='defaultData.registered_residence' :list="defaultColumns" @confirm="onResidenceRegisteredCityConfirm"></u-select>
				</u-form-item>
				<u-form-item label="工作所在地">
					<u-input v-model="personal_info.workplaceN" input-align="right" placeholder="荆州市沙市区" type="select" @click='workAddressChange'/>
					<u-select v-model="show_work_address" mode="mutil-column-auto" :default-value='defaultData.work_address' :list="defaultColumns" @confirm="onWorkCityConfirm"></u-select>
				</u-form-item>
				
				<view class="edit-line"></view>
				
			
				
				<u-form-item label="学历" >
					<u-input v-model="personal_info.educationN" input-align="right" placeholder="大学本科" type="select" @click="show_education = true"/>
					<u-select v-model="show_education" :defaultValue="defaultData.education" mode="single-column" :list="base_dictionary.xlList" @confirm="educationConfirm"></u-select> 				
				</u-form-item>
				<u-form-item label="行业" >
					<u-input v-model="personal_info.industryN" input-align="right" placeholder="IT/互联网" type="select" @click="show_profession = true"/></u-form-item>
					<u-select v-model="show_profession" :defaultValue="defaultData.profession" mode="single-column" :list="base_dictionary.hyList" @confirm="professionConfirm"></u-select> 				
				<u-form-item label="工作单位">
					<u-input v-model="personal_info.workUnit" input-align="right" placeholder="湖北荆鹏软件开发有限公司"  /></u-form-item>
				<u-form-item label="岗位">
					<u-input v-model="personal_info.post" input-align="right" placeholder="软件工程师" /></u-form-item>
				
				<view class="edit-line"></view>
				
				<u-form-item label="月薪" >
					<u-input v-model="personal_info.salaryRangeN" input-align="right" placeholder="请选择" type="select" @click="show_salary = true" />
					<u-select v-model="show_salary"  :defaultValue="defaultData.salary_range" mode="single-column" :list="base_dictionary.yxList" @confirm="salaryConfirm"></u-select> 				
				</u-form-item>
				<u-form-item label="住房状况">
					<u-input v-model="personal_info.housingSituationN" input-align="right" placeholder="请选择" type="select"  @click="show_house = true"/>
					<u-select v-model="show_house" :defaultValue="defaultData.house_status" mode="single-column" :list="base_dictionary.zfqkList" @confirm="houseConfirm"></u-select> 				
				</u-form-item>
				<u-form-item label="婚姻状况">
					<u-input v-model="personal_info.maritalStatusN" input-align="right" placeholder="未婚" type="select"  @click="show_marriage = true"/>
					<u-select v-model="show_marriage" :defaultValue="defaultData.marriage_status" mode="single-column" :list="base_dictionary.hyqkList" @confirm="marriageConfirm"></u-select> 				
				</u-form-item>
				<u-form-item label="子女状况" >
					<u-input v-model="personal_info.childStatusN" input-align="right" placeholder="无" type="select" @click="show_children = true"/>
					<u-select v-model="show_children"  :defaultValue="defaultData.children_status" mode="single-column" :list="base_dictionary.znqkList" @confirm="childrenConfirm"></u-select> 				
				</u-form-item>
				
				<view class="edit-line"></view>
				<view class="edit-row">
					<p>兴趣爱好</p>
					<view class="edit-label">
						<span v-for="(item,index) in base_dictionary.hobbyInfoList" :key="index"  :class="item.isMemberSelect ? 'active' : ''"  @tap="selectInterest(index)">
							{{item.name}}
						</span>
						<!--
						<span class="active">摄影</span>
						<span>烹饪</span>
						<span>健身</span>
						<span>打游戏</span>
						<span>摄影</span>
						<span>烹饪</span>
						<span>健身</span>
						<span>打游戏</span>-->
					</view>
				</view>
				
				<view class="edit-line"></view>				 
				 
				<view class="edit-row" @click="editSelfEvaluation">
					<view class="u-flex u-row-between " >
						<p>自我评价</p>
						<u-icon custom-prefix="custom-icon" name="youjiantou"></u-icon>
					</view>
					<view class="edit-text">
						{{personal_info.selfEvaluation}}	
					</view>
				</view>
				<view class="edit-title">择偶标准</view>
			
				<u-form-item label="年龄范围" >
					<u-input v-model="personal_info.taAgeRangeN" input-align="right" placeholder="20~35" type="select" @click="show_ta_age_ranges = true"/>
					<u-select v-model="show_ta_age_ranges" :defaultValue="defaultData.ta_age_range" mode="single-column" :list="base_dictionary.nlfwList" @confirm="taAgeRangeConfirm"></u-select> 				
				</u-form-item>
				
				<u-form-item label="月薪" >
					<u-input v-model="personal_info.taIncomeRangeN" input-align="right" placeholder="不限" type="select" @click="show_ta_salary = true"/>
					<u-select v-model="show_ta_salary" :defaultValue="defaultData.ta_salary_range" mode="single-column" :list="base_dictionary.yxList" @confirm="taSalaryRangeConfirm"></u-select> 				
				</u-form-item>
				<u-form-item label="学历" >
					<u-input v-model="personal_info.taEduN" input-align="right" placeholder="不限" type="select" @click="show_ta_education = true"/>
					<u-select v-model="show_ta_education" :defaultValue="defaultData.ta_education"   mode="single-column" :list="base_dictionary.xlList" @confirm="taEducationConfirm"></u-select>
				</u-form-item>
				<u-form-item label="职业">
					<u-input v-model="personal_info.taOccupation" input-align="right" placeholder="不限"  /></u-form-item>
				<u-form-item label="所在地">
					<u-input v-model="personal_info.taWorkplaceN" :defaultValue="defaultData.ta_work_address" input-align="right" placeholder="请选择" type="select" @click='taWorkAddressChange'/>
					<u-select v-model="show_ta_work_address" mode="mutil-column-auto" :default-value='defaultData.ta_work_address' :list="defaultColumns" @confirm="onTaWorkCityConfirm"></u-select>
				</u-form-item>
				<u-form-item label="其他要求">
					<u-input v-model="personal_info.taOther"  input-align="right" placeholder="请选择" /></u-form-item>
			</u-form>
		</view>
		
		
		<view class="personal-btn">
			<u-button type="error" shape="circle" :custom-style="customStyle" @click="formsubmit">
				<span>保存</span>
			</u-button>
		</view>
		<view>
			
			<u-popup  border-radius="20" v-model="showSelfEvaluation" @close="close"   mode="bottom" length="90%" height="600rpx">
				<view style="display: flex; flex-direction: column;">
					<view style="display:flex;flex-direction:row;margin-top: 50rpx;justify-content: space-between; ">
						<view style="margin-left: 50rpx;font-weight: bold!important; font-size:30rpx;margin-bottom: 20rpx;">自我评价</view>
						<view style="font-color:#E5E7EA;margin-right: 50rpx;">{{selfEvaluation.length}}/200</view>
					</view>
					<view style="display: flex; uni-textarea; margin-bottom: 20rpx;justify-content: center;align-items:center;">
						<textarea style="width: 80%; padding-top: 10rpx;padding-bottom: 10rpx; border-radius:30rpx;padding-left: 20rpx;padding-right: 20rpx; background-color: #E5E7EA;overflow: auto;" :adjust-position="false" placeholder="请填写内容" maxlength="200" name="summary"  v-model="selfEvaluation">			
							 
						</textarea> 
					</view>
					<view>
						<button style="border-radius:100rpx;background-color: #FF5E5E;width:75%;color:#FFFFFF" @click="saveSelfEvaluation">保存</button>
					</view> 
				</view>
			</u-popup>
 		</view>
		
		 <!--
		<u-action-sheet
				:show="show_education"
				:actions="base_dictionary.xlList"
				title="请选择学历"
				description=""
				@close="show_education = false"
				@select="educationSelect"
		>
		</u-action-sheet>
		<u-action-sheet
				:show="show_salary"
				:actions="base_dictionary.yxList"
				title="请选择月薪"
				description=""
				@close="show_salary = false"
				@select="salarySelect"
		>
		</u-action-sheet>
		<u-action-sheet
				:show="show_profession"
				:actions="base_dictionary.hyList"
				title="请选择行业"
				description=""
				@close="show_profession = false"
				@select="professionSelect"
		>
		</u-action-sheet>
		<u-action-sheet
				:show="show_house"
				:actions="base_dictionary.zfqkList"
				title="请选择住房状况"
				description=""
				@close="show_house = false"
				@select="houseSelect"
		>
		</u-action-sheet>
		<u-action-sheet
				:show="show_marriage"
				:actions="base_dictionary.hyList"
				title="请选择婚姻状况"
				description=""
				@close="show_marriage = false"
				@select="marriageSelect"
		>
		</u-action-sheet>
		<u-action-sheet
				:show="show_children"
				:actions="base_dictionary.znqkList"
				title="请选择子女状况"
				description=""
				@close="show_children = false"
				@select="childrenSelect"
		>
		</u-action-sheet>
		 
		<u-action-sheet
				:show="show_ta_age_ranges"
				:actions="base_dictionary.nlfwList"
				title="请选择年龄范围"
				description=""
				@close="show_ta_age_ranges = false"
				@select="taAgeRangeSelect"
		>
		</u-action-sheet>
		<u-action-sheet
				:show="show_ta_education"
				:actions="base_dictionary.xlList"
				title="请选择学历"
				description=""
				@close="show_ta_education = false"
				@select="taEducationSelect"
		>
		</u-action-sheet>
		<u-action-sheet
				:show="show_ta_salary"
				:actions="base_dictionary.nlfwList"
				title="请选择月薪"
				description="xxxxxxx"
				@close="show_ta_salary = false"
				@select="taSalarySelect"
		>
		</u-action-sheet>-->
 	</view>
</template>

<script>
	
	import * as loginApi from '@/apis/login.js'
	
//	import mpvueCityPicker from "@/pagesB/components/mpvue-citypicker/mpvueCityPicker.vue";
//	import mpvueCityPicker from "../../pagesB/components/mpvue-citypicker/mpvueCityPicker.vue";
	import {provinceData,cityData,areaData,setCityData,getCityData,getCityPosition} from '@/apis/city.js';
	let _self;
	export default {
/*		components:{
			mpvueCityPicker
		},*/
		data() {
			return {
				defaultColumns: [],				
				cityPickerValueDefault:[16,6,0],
				customStyle: {
					background: '#FF5E5E'
				}, 
				defaultData:{
					height:[45],
					weight:[45],
					
					address:[16,6,0],
					registered_residence:[16,6,0],
					work_address:[16,6,0],
					education:[1],
					profession:[1],
					salary_range:[1],
					house_status:[1],
					marriage_status:[1],
					children_status:[1],
					ta_age_range:[1],
					ta_salary_range:[1],
					ta_education:[1],
					ta_work_address:[16,6,0]
				},				
				form: {
					name: '',
					sex: '',
					height:'',
					weight:'',
					
					address:'',
					registered_residence:'',
					work_address:'',
					work_corporation:'',
					work_post:'',
					education:'',
					profession:'',
					salary_range:'',
					house_status:'',
					marriage_status:'',
					children_status:'',
					self_assess:'',
					
					addressId:'',
					registered_residenceId:'',
					work_addressId:'',
					educationId:'',
					professionId:'',
					salary_rangeId:'',
					house_statusId:'',
					marriage_statusId:'',
					children_statusId:'',
				},				
				selfEvaluation:'',
				personal_info:{
					faceImage:' /static/img/sexMan.png'
				},
				height_ranges:[],
				weight_ranges:[],
				showSelfEvaluation:false,
				show_height:false,
				show_weight:false,
				
				show_birthday_address:false,
				show_registered_residence:false,
				show_work_address:false,
				show_salary:false,
				show_profession:false,
				show_education:false,
				show_house:false,
				show_marriage:false,
				show_children:false,				
				show_ta_age_ranges:false,
				show_ta_education:false,
				show_ta_salary:false,
				show_ta_work_address:false,
				base_dictionary:{
					zfqkList:[],
					yxList:[],
					znqkList:[],
					qyList:[],
					xlList:[],
					hyList:[],
					nlfwList:[],
					hyqkList:[],
					hobbyInfoList:[],
					
				}
			}
 

		},
		computed:{
			 
			idCard(){
				if(this.personal_info.idCard && this.personal_info.idCard.length>=15){
					let prefix = this.personal_info.idCard.substr(0,5);
					let suffix = this.personal_info.idCard.substr(this.personal_info.idCard.length-3,3);
					return prefix + '********'+ suffix;
				}
				return '42100********111'
			}
		},
		onLoad(){
			_self = this;
			 
//			console.log('省'+JSON.stringify(provinceData))
			
			//let personalInfoPlus = this.carhelp.getPersonInfoPlus();
			//console.log('personalInfoPlus'+JSON.stringify(personalInfoPlus))
			this.personal_info = this.carhelp.getPersonInfo();	
//			console.log('个人信息'+JSON.stringify(this.personal_info))
			let subject = {subject:''}		
			loginApi.getBaseDictionary(subject).then(function(data){
				//console.log('基础字典'+JSON.stringify(data));
				let personal_info = _self.carhelp.getPersonInfo();
				if(data.data)
				{
					_self.base_dictionary = data.data;
					if(_self.base_dictionary.zfqkList){ 
						
						for(let i = 0;i< _self.base_dictionary.zfqkList.length;i++)
						{
							_self.base_dictionary.zfqkList[i].label = _self.base_dictionary.zfqkList[i].name;
						}
						if(_self.personal_info.housingSituation!=null && _self.personal_info.housingSituation<= _self.base_dictionary.zfqkList.length)
						{
							_self.personal_info.housingSituationN =_self.base_dictionary.zfqkList[_self.personal_info.housingSituation-1].label						
						}
					}
					
					//console.log('住房情况'+JSON.stringify(_self.base_dictionary.zfqkList));
					if(_self.base_dictionary.yxList){
						
						for(let i = 0;i< _self.base_dictionary.yxList.length;i++)
						{
							_self.base_dictionary.yxList[i].label = _self.base_dictionary.yxList[i].name;
						}
						if(_self.personal_info.salaryRange!=null && _self.personal_info.salaryRange<= _self.base_dictionary.yxList.length)
						{
							_self.personal_info.salaryRangeN =_self.base_dictionary.yxList[_self.personal_info.salaryRange-1].label						
						}
						if(_self.personal_info.taIncomeRange!=null && _self.personal_info.taIncomeRange<= _self.base_dictionary.yxList.length)
						{
							_self.personal_info.taIncomeRangeN =_self.base_dictionary.yxList[_self.personal_info.taIncomeRange-1].label						
						}
					}
					
					//console.log('月薪情况'+JSON.stringify(_self.base_dictionary.yxList));
					if(_self.base_dictionary.znqkList){
						
						for(let i = 0;i< _self.base_dictionary.znqkList.length;i++)
						{
							_self.base_dictionary.znqkList[i].label = _self.base_dictionary.znqkList[i].name;
						}
						if(_self.personal_info.childStatus!=null && _self.personal_info.childStatus<= _self.base_dictionary.znqkList.length)
						{
							_self.personal_info.childStatusN =_self.base_dictionary.znqkList[_self.personal_info.childStatus-1].label						
						}
					} 
					//console.log('子女情况'+JSON.stringify(_self.base_dictionary.znqkList));
					/*
					if(_self.base_dictionary.qyList){ 
						
						for(let i = 0;i< _self.base_dictionary.qyList.length;i++)
						{
							_self.base_dictionary.qyList[i].label = _self.base_dictionary.qyList[i].name;
						}
					}
					console.log('区域'+JSON.stringify(_self.base_dictionary.qyList));
					*/
					if(_self.base_dictionary.xlList){ 
						
						for(let i = 0;i< _self.base_dictionary.xlList.length;i++)
						{
							_self.base_dictionary.xlList[i].label = _self.base_dictionary.xlList[i].name;
						}
						
						//console.log('学历'+JSON.stringify(_self.base_dictionary.xlList.length))
						if(_self.personal_info.education!=null && _self.personal_info.education <= _self.base_dictionary.xlList.length)
						{
							//console.log('学历'+JSON.stringify(_self.personal_info.education))
							_self.personal_info.educationN =_self.base_dictionary.xlList[Number(_self.personal_info.education)-1].label						
						}
						if(_self.personal_info.taEdu!=null && _self.personal_info.taEdu<= _self.base_dictionary.xlList.length)
						{
							_self.personal_info.taEduN =_self.base_dictionary.xlList[_self.personal_info.taEdu-1].label						
						}
					}
					//console.log('学历情况'+JSON.stringify(_self.base_dictionary.xlList));
					
					if(_self.base_dictionary.hyList){ 
						
						for(let i = 0;i< _self.base_dictionary.hyList.length;i++)
						{
							_self.base_dictionary.hyList[i].label = _self.base_dictionary.hyList[i].name;
						}
						if(_self.personal_info.industry!=null && _self.personal_info.industry<= _self.base_dictionary.hyList.length)
						{
							_self.personal_info.industryN =_self.base_dictionary.hyList[_self.personal_info.industry-1].label						
						}
 					
					}
//					console.log('行业情况'+JSON.stringify(_self.base_dictionary.hyList));
					if(_self.base_dictionary.nlfwList){ 
						
						for(let i = 0;i< _self.base_dictionary.nlfwList.length;i++)
						{
							_self.base_dictionary.nlfwList[i].label = _self.base_dictionary.nlfwList[i].name;
						}
						if(_self.personal_info.taAgeRange!=null && _self.personal_info.taAgeRange<= _self.base_dictionary.nlfwList.length)
						{
							_self.personal_info.taAgeRangeN =_self.base_dictionary.nlfwList[_self.personal_info.taAgeRange-1].label						
						}
					}
					//console.log('年龄范围'+JSON.stringify(_self.base_dictionary.nlfwList));
					if(_self.base_dictionary.hyqkList){ 
						
						for(let i = 0;i< _self.base_dictionary.hyqkList.length;i++)
						{
							_self.base_dictionary.hyqkList[i].label = _self.base_dictionary.hyqkList[i].name;
						}
						if(_self.personal_info.maritalStatus!=null && _self.personal_info.maritalStatus<= _self.base_dictionary.hyqkList.length)
						{
							_self.personal_info.maritalStatusN =_self.base_dictionary.hyqkList[_self.personal_info.maritalStatus-1].label						
						}
					}
					//console.log('婚姻情况'+JSON.stringify(_self.base_dictionary.hyqkList));
					if(_self.base_dictionary.hobbyInfoList){ 
						
						for(let i = 0;i< _self.base_dictionary.hobbyInfoList.length;i++)
						{
							_self.base_dictionary.hobbyInfoList[i].isMemberSelect = false;
							_self.base_dictionary.hobbyInfoList[i].label = _self.base_dictionary.hobbyInfoList[i].name;
							if(_self.personal_info.hobby!=null){
//								console.log('hobby'+JSON.stringify(_self.personal_info.hobby))
								if(_self.personal_info.hobby.indexOf(_self.base_dictionary.hobbyInfoList[i].id)>=0)
								{
									_self.base_dictionary.hobbyInfoList[i].isMemberSelect = true;
//									console.log('选中'+JSON.stringify(_self.base_dictionary.hobbyInfoList[i]))
								} 
							}
						}
					} 
//					console.log('兴趣爱好'+JSON.stringify(_self.base_dictionary.hobbyInfoList));
					 if(_self.personal_info.birthplace!=null){
					 	_self.personal_info.birthplaceN = getCityData(Number(_self.personal_info.birthplace));
 //						console.log('address'+JSON.stringify(_self.form.addressId))
					 }
					 if(_self.personal_info.registeredResidence!=null){
						 _self.personal_info.registeredResidenceN = getCityData(Number(_self.personal_info.registeredResidence));
 					 } 
					 if(_self.personal_info.workplace!=null){
					 	_self.personal_info.workplaceN = getCityData(Number(_self.personal_info.workplace));
 					 							 
					 } 
					 if(_self.personal_info.taWorkplace!=null){
					 	_self.personal_info.taWorkplaceN = getCityData(Number(_self.personal_info.taWorkplace));
					 							 
					 }  
				} 
			},function(err){
				console.log('获取基础字典错误'+JSON.stringify(err))
			}) 
						
			for(let i = 130;i<=220;i++)
			{
				let height_range = {value: i, label: i.toString()+"cm"};
				this.height_ranges.push(height_range);
				//this.height_ranges.push(i.toString());
			}
			for(let i = 20;i<=120;i++)
			{
//				this.weight_ranges.push(i.toString());
				let weight_range = {value:i, label:i.toString()+"kg"};
				this.weight_ranges.push(weight_range);
			}
			if(this.personal_info){
				this.form.sex = this.personal_info.gender?'女':'男'
				if(this.personal_info.height)
				{
					this.form.height = this.personal_info.height+'cm'
					
				}
				if(this.personal_info.weight)
				{
					this.form.weight = this.personal_info.weight+'kg'
					
				}
			}
			
			if(provinceData.length<=0){
				  loginApi.getCityList().then(function(data){
//					console.log('获取城市成功'+JSON.stringify(data));
					if(data.result &&  data.data){
						setCityData(data.data);
						_self.init_city_data();
						
						//_self.$refs.mpvuebirtydayCityPicker.setCityData(data.data);		
						//console.log('province data '+JSON.stringify(provinceData))
						if(_self.personal_info.birthplace!=null){
							_self.personal_info.birthplaceN = getCityData(Number(_self.personal_info.birthplace));
							 _self.defaultData.address = getCityPosition(Number(_self.personal_info.birthplace));
							//this.defaultData.registered_residence = this.defaultData.address;
							//this.defaultData.work_address = this.defaultData.address;	//		
							console.log('address'+JSON.stringify(_self.defaultData.address))
						 }
						 if(_self.personal_info.registeredResidence!=null){
							 _self.personal_info.registeredResidenceN = getCityData(Number(_self.personal_info.registeredResidence));
							 _self.defaultData.registered_residence = getCityPosition(Number(_self.personal_info.registeredResidence));
						 } 
						 if(_self.personal_info.workplace!=null){
							_self.personal_info.workplaceN = getCityData(Number(_self.personal_info.workplace));
							 _self.defaultData.work_address = getCityPosition(Number(_self.personal_info.workplace));
													 
						 } 
						 if(_self.personal_info.taWorkplace!=null){
							_self.personal_info.taWorkplaceN = getCityData(Number(_self.personal_info.taWorkplace));
							 _self.defaultData.ta_work_address = getCityPosition(Number(_self.personal_info.taWorkplace));
													 
						 } 
					} 
					
				  },function(err){
					console.log('获取城市列表错误'+JSON.stringify(err))
				  })		
			}else{
				_self.init_city_data();
				if(_self.personal_info.birthplace!=null){
					_self.personal_info.birthplaceN = getCityData(Number(_self.personal_info.birthplace));
					 _self.defaultData.address = getCityPosition(Number(_self.personal_info.birthplace));
					//this.defaultData.registered_residence = this.defaultData.address;
					//this.defaultData.work_address = this.defaultData.address;	//		
					console.log('address'+JSON.stringify(_self.defaultData.address))
				 }
				 if(_self.personal_info.registeredResidence!=null){
					 _self.personal_info.registeredResidenceN = getCityData(Number(_self.personal_info.registeredResidence));
					 _self.defaultData.registered_residence = getCityPosition(Number(_self.personal_info.registeredResidence));
				 } 
				 if(_self.personal_info.workplace!=null){
					_self.personal_info.workplaceN = getCityData(Number(_self.personal_info.workplace));
					 _self.defaultData.work_address = getCityPosition(Number(_self.personal_info.workplace));
											 
				 } 
				 if(_self.personal_info.taWorkplace!=null){
					_self.personal_info.taWorkplaceN = getCityData(Number(_self.personal_info.taWorkplace));
					 _self.defaultData.ta_work_address = getCityPosition(Number(_self.personal_info.taWorkplace));
											 
				 } 
			}
			
			
//			console.log('个人信息'+JSON.stringify(this.personal_info))
		},
		methods:{
			init_city_data(){
				for(let i = 0;i< provinceData.length;i++){
					let province = provinceData[i];
					if(cityData[i].length>0){
						province.children = [];
						for(let j = 0;j< cityData[i].length;j++){
							let city = cityData[i][j];
							if(areaData[i][j].length>0){
								city.children = [];
								for(let k = 0;k< areaData[i][j].length;k++){
									city.children.push(areaData[i][j][k])
								}
							}
							province.children.push(city);
						}
					}
					this.defaultColumns.push(province);
				}		
			},
			saveSelfEvaluation(){
				this.showSelfEvaluation = false;
				this.personal_info.selfEvaluation = this.selfEvaluation;
				console.log('自我评价'+JSON.stringify(this.selfEvaluation))
			},
			editSelfEvaluation(){
				if(this.personal_info.selfEvaluation!=null)
				{
					this.selfEvaluation = this.personal_info.selfEvaluation;					
				}else
				{
					this.selfEvaluation = ''
				}
				this.showSelfEvaluation = true
				
				console.log('editSelfEvaluation')
			},
			open() {
			         console.log('open');
			      },
			  close() {
				this.showSelfEvaluation = false
				 console.log('close');
			  },
			selectInterest(index){
//				let interest = this.interests;
				this.base_dictionary.hobbyInfoList[index].isMemberSelect = !this.base_dictionary.hobbyInfoList[index].isMemberSelect;
 				console.log('item'+JSON.stringify(this.base_dictionary.hobbyInfoList[index])) 
			},
			birthdayAddressChange(){
				_self.show_birthday_address = true; 
//				console.log('birthdayAddress change')
//				this.$refs.mpvuebirtydayCityPicker.show()
			},
			registeredResidenceAddressChange(){
				_self.show_registered_residence = true;
//				this.$refs.mpvueRegisteredResidenceCityPicker.show()
			},
			workAddressChange(){
				_self.show_work_address = true;
//				this.$refs.mpvueWorkCityPicker.show()
			},
			taWorkAddressChange(){
				_self.show_ta_work_address = true;
//				this.$refs.mpvueTaWorkCityPicker.show()
			},
			onBirthdayCityConfirm(e) {
//				console.log('e'+JSON.stringify(e))
				//this.defaultData.address = [this.base_dictionary.znqkList.findIndex(item => item.value === e[0].value)]
				//this.defaultData.address = [17,1,1]
				let province = e[0];
				let city = e[1];
				let area = e[2];
				
				this.defaultData.address = getCityPosition(area.value);
				this.defaultData.registered_residence = this.defaultData.address;
				this.defaultData.work_address = this.defaultData.address;
//				console.log('address '+JSON.stringify(this.defaultData.address))
				this.personal_info.birthplaceN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.birthplace = val.value; 
					let name = getCityData(Number(val.value));
					_self.personal_info.birthplaceN = name;
					
					//						
					_self.personal_info.registeredResidenceN= _self.personal_info.birthplaceN;
					_self.personal_info.registeredResidence = _self.personal_info.birthplace;
					_self.personal_info.workplaceN = _self.personal_info.birthplaceN;
					_self.personal_info.workplace = _self.personal_info.birthplace;
				}) 
//				console.log('地址选择'+JSON.stringify(_self.form.addressId))
			},
			onResidenceRegisteredCityConfirm(e) {
				let province = e[0];
				let city = e[1];
				let area = e[2];
				
				this.defaultData.registered_residence = getCityPosition(area.value);
//				console.log('address '+JSON.stringify(this.defaultData.address))
				this.personal_info.registeredResidenceN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label 
					let name = getCityData(Number(val.value));
					_self.personal_info.registeredResidenceN = name;
					_self.personal_info.registeredResidence = val.value; 
				})  
			},
			onWorkCityConfirm(e) {
				let province = e[0];
				let city = e[1];
				let area = e[2];
				
				this.defaultData.work_address = getCityPosition(area.value);
//				console.log('address '+JSON.stringify(this.defaultData.address))
				this.personal_info.workplaceN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label 
					let name = getCityData(Number(val.value));
					_self.personal_info.workplaceN = name;
					_self.personal_info.workplace = val.value;
				})   
			},
			onTaWorkCityConfirm(e) {
				let province = e[0];
				let city = e[1];
				let area = e[2];
				
				this.defaultData.ta_work_address = getCityPosition(area.value);
//				console.log('address '+JSON.stringify(this.defaultData.address))
				this.personal_info.taWorkplaceN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label 
					let name = getCityData(Number(val.value));
					_self.personal_info.taWorkplaceN = name;
					_self.personal_info.taWorkplace = val.value;
				})   
				 
			},
			formsubmit(){
				let personal_info = {type:1,id:this.personal_info.id};
				let _personal_info = this.personal_info;
				if(_personal_info.faceImage)
				{
					personal_info.faceImage = _personal_info.faceImage;
					console.log('faceImage'+personal_info.faceImage)
				} 
				personal_info.hobby = ''
				for(let i=0;i<_self.base_dictionary.hobbyInfoList.length;i++)
				{
					if(_self.base_dictionary.hobbyInfoList[i].isMemberSelect)
					{
						if(personal_info.hobby.length>0)
						{
							personal_info.hobby+=','
						}
						personal_info.hobby += _self.base_dictionary.hobbyInfoList[i].id;
					}
				} 
				if(_personal_info.selfEvaluation)
				{
					personal_info.selfEvaluation = _personal_info.selfEvaluation;
					console.log('selfEvaluation'+personal_info.selfEvaluation);
				}
				if(_personal_info.weight)
				{
					personal_info.weight = _personal_info.weight;
					console.log('weight'+personal_info.weight)
				}
				if(_personal_info.height)
				{
					personal_info.height = _personal_info.height;
					console.log('height'+personal_info.height)
				} 
				if(_personal_info.education)
				{
					personal_info.education = _personal_info.education;
					console.log('education'+personal_info.education)
				} 
				/*
				if(_personal_info.educationN)
				{
					personal_info.educationN = _personal_info.educationN;
					console.log('education'+personal_info.educationN)
				} */
				if(_personal_info.workUnit)
				{
					personal_info.workUnit = _personal_info.workUnit;
					console.log('workUnit'+personal_info.workUnit)
				}  
				if(_personal_info.post)
				{
					personal_info.post = _personal_info.post;
					console.log('post'+personal_info.post)
				}   
				
				if(_personal_info.industry)
				{
					personal_info.industry = _personal_info.industry;
					console.log('industry'+personal_info.industry)
				} 
				/*
				if(_personal_info.industryN)
				{
					personal_info.industryN = _personal_info.industryN;
					console.log('industryN'+personal_info.industryN)
				} */
				if(_personal_info.salaryRange)
				{
					personal_info.salaryRange = _personal_info.salaryRange;
					console.log('salaryRange'+personal_info.salaryRange)
				} 
				/*
				if(_personal_info.salaryRangeN)
				{
					personal_info.salaryRangeN = _personal_info.salaryRangeN;
					console.log('salaryRangeN'+personal_info.salaryRangeN)
				} */
				if(_personal_info.housingSituation)
				{
					personal_info.housingSituation = _personal_info.housingSituation;
					console.log('housingSituation'+personal_info.housingSituation)
				} 
				/*
				if(_personal_info.housingSituationN)
				{
					personal_info.housingSituationN = _personal_info.housingSituationN;
					console.log('housingSituationN'+personal_info.housingSituationN)
				} */
				
				if(_personal_info.maritalStatus)
				{
					personal_info.maritalStatus = _personal_info.maritalStatus;
					console.log('maritalStatus'+personal_info.maritalStatus)
				} 
				/*
				if(_personal_info.maritalStatusN)
				{
					personal_info.maritalStatusN = _personal_info.maritalStatusN;
					console.log('maritalStatusN'+personal_info.maritalStatusN)
				} */
				if(_personal_info.childStatus)
				{
					personal_info.childStatus = _personal_info.childStatus;
					console.log('childStatus'+personal_info.childStatus)
				} 
				/*
				if(_personal_info.childStatusN)
				{
					personal_info.childStatusN = _personal_info.childStatusN;
					console.log('childStatusN'+personal_info.childStatusN)
				} */
				if(_personal_info.taIncomeRange)
				{
					personal_info.taIncomeRange = _personal_info.taIncomeRange;
					console.log('taIncomeRange'+personal_info.taIncomeRange)
				} 
				/*
				if(_personal_info.taIncomeRangeN)
				{
					personal_info.taIncomeRangeN = _personal_info.taIncomeRangeN;
					console.log('taIncomeRangeN'+personal_info.taIncomeRangeN)
				} */
				if(_personal_info.birthplace)
				{
					personal_info.birthplace = _personal_info.birthplace;
					console.log('birthplace'+personal_info.birthplace)
				} 
				/*
				if(_personal_info.birthplaceN)
				{
					personal_info.birthplaceN = _personal_info.birthplaceN;
					console.log('birthplaceN'+personal_info.birthplaceN)
				} */
				if(_personal_info.registeredResidence)
				{
					personal_info.registeredResidence = _personal_info.registeredResidence;
					console.log('registeredResidence'+personal_info.registeredResidence)
				} 
				/*
				if(_personal_info.registeredResidenceN)
				{
					personal_info.registeredResidenceN = _personal_info.registeredResidenceN;
					console.log('registeredResidenceN'+personal_info.registeredResidenceN)
				} */
				if(_personal_info.workplace)
				{
					personal_info.workplace = _personal_info.workplace;
					console.log('workplace'+personal_info.workplace)
				} 
				/*
				if(_personal_info.workplaceN)
				{
					personal_info.workplaceN = _personal_info.workplaceN;
					console.log('workplaceN'+personal_info.workplaceN)
				} */
				
				if(_personal_info.taWorkplace)
				{
					personal_info.taWorkplace = _personal_info.taWorkplace;
					console.log('taWorkplace'+personal_info.taWorkplace)
				} 
				/*
				if(_personal_info.taWorkplaceN)
				{
					personal_info.taWorkplaceN = _personal_info.taWorkplaceN;
					console.log('taWorkplaceN'+personal_info.taWorkplaceN)
				} */
				if(_personal_info.taAgeRange)
				{
					personal_info.taAgeRange = _personal_info.taAgeRange;
					console.log('taAgeRange'+personal_info.taAgeRange)
				} 
				/*
				if(_personal_info.taAgeRangeN)
				{
					personal_info.taAgeRangeN = _personal_info.taAgeRangeN;
					console.log('taAgeRangeN'+personal_info.taAgeRangeN)
				} */
				if(_personal_info.taEdu)
				{
					personal_info.taEdu = _personal_info.taEdu;
					console.log('taEdu'+personal_info.taEdu)
				} 
				/*
				if(_personal_info.taEduN)
				{
					personal_info.taEduN = _personal_info.taEduN;
					console.log('education'+personal_info.taEduN)
				} */
				
				if(_personal_info.taOccupation)
				{
					personal_info.taOccupation = _personal_info.taOccupation;
					console.log('taOccupation'+personal_info.taOccupation)
				} 
				/*
				if(_personal_info.taOccupationN)
				{
					personal_info.taOccupationN = _personal_info.taOccupationN;
					console.log('education'+personal_info.taOccupationN)
				} */
				if(_personal_info.taOther)
				{
					personal_info.taOther = _personal_info.taOther;
					console.log('taOther'+personal_info.taOther)
				} 
				/*
				if(_personal_info.taOccupationN)
				{
					personal_info.taOccupationN = _personal_info.taOccupationN;
					console.log('education'+personal_info.taOccupationN)
				} */
				console.log('xxxx')
				
				loginApi.save_personal_info(personal_info).then(function(data){
					console.log('保存成功'+JSON.stringify(data));
					if(data.result){
						if(data.data){
							_self.findByOpenId();
							uni.switchTab({
								url:'./index'
							}) 
							
						}
					}
					//_self.findByOpenId();
					/*uni.navigateTo({
						url:'../user/index'
					})*/
				},function(err){
					console.log('保存失败'+JSON.stringify(personal_info)+ JSON.stringify(err));
				});
			},
			updatePersonInfo(){
				
			},
			updatePersonPlusInfo(){
				
			},
			childrenConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.children_status = [this.base_dictionary.znqkList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.childStatusN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.childStatus = val.value;
					this.personal_info.childStatusN  += result;
				}) 
			},
			marriageConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.marriage_status = [this.base_dictionary.hyqkList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.maritalStatusN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					console.log('val'+JSON.stringify(val))
					_self.personal_info.maritalStatus =val.value;
					this.personal_info.maritalStatusN  += result;
				}) 
			},
			houseConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.house_status = [this.base_dictionary.zfqkList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.housingSituationN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.housingSituation = val.value;
					_self.personal_info.housingSituationN  += result;
				}) 
			},		
			educationConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.education = [this.base_dictionary.xlList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.educationN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.education = val.value;
					_self.personal_info.educationN  += result;
				}) 
			},
			professionConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.profession = [this.base_dictionary.hyList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.industryN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.industry = val.value;
					this.personal_info.industryN  += result;
				}) 
			},
			salaryConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.salary_range = [this.base_dictionary.yxList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.salaryRangeN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.salaryRange = val.value;
					this.personal_info.salaryRangeN  += result;
				}) 
			},
			taSalaryRangeConfirm(e){
				console.log('e111'+JSON.stringify(e))
				this.defaultData.ta_salary_range = [this.base_dictionary.yxList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.taIncomeRangeN = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					console.log('val'+val + 'index '+index)
					let result = val.label
					_self.personal_info.taIncomeRange = val.value;
					_self.personal_info.taIncomeRangeN  += result; 
				}) 
			},
			taAgeRangeConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.ta_age_range = [this.base_dictionary.nlfwList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.taAgeRangeN = '';
				e.map((val, index) => {
					console.log('val'+val + 'index '+index)
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.taAgeRange = val.value;
					_self.personal_info.taAgeRangeN  += result;
				}) 
			},
			taEducationConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.ta_education = [this.base_dictionary.xlList.findIndex(item => item.value === e[0].value)]
				
				this.personal_info.taEduN = '';
				e.map((val, index) => {
					console.log('val'+val + 'index '+index)
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.taEdu = val.value;
					_self.personal_info.taEduN  += result;
				}) 
			},
			/*
			educationSelect(e) {
				this.personal_info.education = e.value;
				this.personal_info.educationN = e.name;
				//this.$refs.uForm.validateField('personal_info.education')
			},
			salarySelect(e) {
				this.personal_info.salaryRange = e.value;
				this.personal_info.salaryRangeN = e.name;
				//this.$refs.uForm.validateField('personal_info.salaryRange')
			},
			professionSelect(e) {
				this.personal_info.industry = e.value;
				this.personal_info.industryN = e.name;
				//this.$refs.uForm.validateField('personal_info.industry')
			},
			houseSelect(e) {
				this.personal_info.housingSituation = e.value;
				this.personal_info.housingSituationN = e.name;
				//this.$refs.uForm.validateField('personal_info.housingSituation')
			},   
			childrenSelect(e) {
				this.personal_info.childStatus = e.value;
				this.personal_info.childStatusN = e.name;
				//this.$refs.uForm.validateField('personal_info.childStatus')
			},   
			marriageSelect(e) {
				this.personal_info.maritalStatus = e.value;
				this.personal_info.maritalStatusN = e.name;
				//this.$refs.uForm.validateField('personal_info.maritalStatus')
			},  
			taAgeRangeSelect(e) {
				this.personal_info.taAgeRange = e.value;
				this.personal_info.taAgeRangeN = e.name;
				//this.$refs.uForm.validateField('personal_info.taAgeRange')
			},   
			taEducationSelect(e) {
				this.personal_info.taEdu = e.value;
				this.personal_info.taEduN = e.name;
				//this.$refs.uForm.validateField('personal_info.taEdu')
			},   
			taSalarySelect(e) {
				this.personal_info.taIncomeRange = e.value;
				this.personal_info.taIncomeRangeN = e.name;
				//this.$refs.uForm.validateField('personal_info.taIncomeRange')
			},*/
			heightConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.height = [this.height_ranges.findIndex(item => item.value === e[0].value)]				
				this.form.height = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.height = val.value
					this.form.height  += result;
				}) 
			},
			weightConfirm(e){
				console.log('e'+JSON.stringify(e))
				this.defaultData.weight = [this.weight_ranges.findIndex(item => item.value === e[0].value)]				
				this.form.weight = '';
				e.map((val, index) => {
					// this.result += this.result == '' ? val.label : '-' + val.label;
					let result = val.label
					_self.personal_info.weight = val.value;
					this.form.weight  += result;
				}) 
			},
			uploadPhoto(){
			    // 上传图片
				//const ctx = uni.createCanvasContext('myCanvas');
				//console.log('url'+this.uploadUrl)
				//console.log(this.carhelp.getToken())
				let _this = this;
			    uni.chooseImage({
			        count: 1, //默认9
			        // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
			        sourceType: ['album','camera'], //从相册选择
			        success:(res)=> {
			            let imgFile = res.tempFilePaths;
						console.log(process.car.BASE_URL+"mobile/member/uploadBase64")
						console.log(imgFile)
							console.log(process.car.NODE_ENV)
						
							console.log()
						var token=this.carhelp.getToken()
						for(let i = 0;i < imgFile.length;i++)
						{
							 
							 wx.uploadFile({
								 url:process.car.BASE_URL+"uploadPicture",
								 
								// url:process.car.BASE_URL+"mobile/member/uploadBase64",
								 name: 'photoFile',
								     header: {
								 
								         //   'appId': process.car.VUE_APP_WXAPPID ,
								 
								             'Authorization':token ,
								 
								          //   'openId': "wxa8954f417fa7c32f" ,
								 
								 
								               'accept': 'application/json',
								 //#ifdef MP-WEIXIN
								                "Content-Type": "multipart/form-data",//记得设置
								 //#endif
								 
								       },
								  filePath: imgFile[0],
								    success: function(result) {
										let imgUrls = JSON.parse(result.data) //百度支持 this.site_url +'/' +
										//let image ={url: imgUrls.data};											  		 
										//_self.fileList.push(image); //微信
										_self.personal_info.faceImage = imgUrls.data;
									}
								  
								  
								  
							 })
							  
							
						}
			        },
			    }); 
			},
			findByOpenId(){
				var openId=this.carhelp.getOpenId()
				if(openId==""){
					console.log("------------------")
					setTimeout(()=>{
						this.findByOpenId()
					},1000)
					return
				}
				uni.request({
					method:'get',
					url: process.car.BASE_URL + "/mobile/regUser/findByOpenId",
					data: {
						openId:openId,			
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded',
						'X-Requested-With': 'XMLHttpRequest',
					}
				}).then((response) => {
//					console.log('findByOpenId' +JSON.stringify(response))
					let [error, res] = response;
				  
					if (res.data.code == 200&&res.data.result) {			
						var token = res ? res.data.data.token : '';					
						this.carhelp.setPersonInfo(res.data.data.memberInfo );
						this.carhelp.setToken(token);
						this.carhelp.setPersonInfoPlus(res.data.data);
						 
					
					}  
				}).catch(error => {
					 
				})
			}
		}
	}
</script>
<style>
	page{
		background-color: #f4f0f0;
	}
</style>
<style lang="scss" scoped>
	.edit-text{
		margin-top: 10px;
		color:#999;
	}
	.edit-row{
		padding: 12px 0;
		.edit-label{
			display: flex;
			margin-top: 10px;
			flex-wrap: wrap;
			span{
				margin-right: 8px;
				background-color: #E5E7EA ;
				padding: 4px 10px;
				border-radius: 4px;
				font-size: 12px;
				margin-bottom: 10px;
			}
			.active{
				background-color: #FFC1BC;
			}
		}
	}
	.edit-line{
		height: 12px;
		background-color:#f4f0f0 ;
		margin-left: -15px;
		margin-right: -15px;
	}
	.edit-title{
		padding:12px 0;
		padding-left: 15px;
		background-color:#f4f0f0 ;
		margin-left: -15px;
		margin-right: -15px;
	}
	.edit-head{
		display: flex;
		padding: 20px 0;
		justify-content: center;
	}
	.personal-btn{
		padding: 15px 50px;
	}
	.edit-form{
		padding: 0 15px;
		background-color: #fff;
	}
</style>
