<style>
	.editmaterial{
		width: 100%;
		height: 100vh;
		background: #FFF;
	}
	.editmaterial .box{
		width: 100%;
		padding:0 15px;
	}
	.editmaterial .title{
		font-size: 16px;
		color: #111111;
		font-weight: bold;
		margin-top: 15px;
	}
	.editmaterial .item{
		width: 100%;
		height: 52px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1px solid #E2E2E2;
	}
	.editmaterial .item-l{
		width: 164rpx;
		font-size: 24rpx;
		color: #666666;
	}
	.editmaterial .item-r{
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.editmaterial .text-o{
		font-size: 12px;
		color: #111111;
		font-weight: bold;
	}
	.editmaterial .inputsmart{
		width: 100%;
		height: 100px;
		margin-top: 10px;
		border-bottom: 1px solid #E2E2E2;
	}
	.editmaterial .slot-btn{
		width: 200rpx;
		height: 200rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		background: rgb(244, 245, 246);
		border-radius: 10rpx;
		margin-left: 5px;
	}
	.editmaterial .slot-btn .mian-title {
		font-size: 28rpx;
		color: #888;
		font-weight: 600;
		margin: 10rpx 0;
	}
	.editmaterial .save{
		width: 100%;
		height: 44px;
		border-radius: 22px;
		margin: 45px 0 30px;
		font-size: 16px;
		color: #FFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
<template>
	<view class="editmaterial">
		<view class="box">
			<view class="title">基础资料</view>
			<!-- <view class="item">
				<view class="item-l">性别</view>
				<view class="item-r">
					<u-radio-group v-model="addMsg.Sex" >
						<u-radio 
							shape="circle"
							v-for="(item, index) in xblist" :key="index" 
							:name="item.Id"
							:active-color="mainColor"
						>
							{{item.name}}
						</u-radio>
					</u-radio-group>
				</view>
			</view> -->
			<view class="item">
				<view class="item-l">出生日期</view>
				<view class="item-r" @click="showtime=true">
					<text>{{addMsg.Birthday}}</text>
					<u-icon name="arrow" color="#A5A4AC" size="30" style='margin-left: 5px;'></u-icon>
				</view>
			</view>
			<view class="item">
				<view class="item-l">身高</view>
				<view class="item-r text-o" >
					<input type="number" v-model="addMsg.Height" style="text-align: right;" placeholder="请输入身高">
					<text style='margin-left: 5px;'>cm</text>
				</view>
			</view>	
			<view class="item">
				<view class="item-l">体重</view>
				<view class="item-r text-o" >
					<input type="number" v-model="addMsg.Weight" style="text-align: right;" placeholder="请输入体重">
					<text style='margin-left: 5px;'>kg</text>
				</view>
			</view>	
			<view class="item">
				<view class="item-l">婚姻状态</view>
				<view class="item-r text-o" @click="showdan=true">
					<text>{{MarriageName}}</text>
					<u-icon name="arrow" color="#A5A4AC" size="30" style='margin-left: 5px;'></u-icon>
				</view>
			</view>	
			<view class="item">
				<view class="item-l">年收入(税后)</view>
				<view class="item-r text-o" >
					<input type="number" v-model="addMsg.YearMoney" style="text-align: right;" placeholder="请输入年收入">
					<text style='margin-left: 5px;'>万元</text>
				</view>
			</view>	
			<view class="title">其他资料</view>
			<view class="item">
				<view class="item-l">户口所在</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.HuKou" style="text-align: right;" placeholder="请输入户口所在">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">籍贯</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.NativePlace" style="text-align: right;" placeholder="请输入籍贯">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">买房情况</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.HouseInfo" style="text-align: right;" placeholder="请输入买房情况">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">毕业院校</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.SchoolInfo" style="text-align: right;" placeholder="请输入毕业院校">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">学历</view>
				<view class="item-r text-o" @click="showdan2=true">
					<text>{{EducationTypeName}}</text>
					<u-icon name="arrow" color="#A5A4AC" size="30" style='margin-left: 5px;'></u-icon>
				</view>
			</view>	
			<view class="item">
				<view class="item-l">专业</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.MajorInfo" style="text-align: right;" placeholder="请输入专业">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">职业</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.Job" style="text-align: right;" placeholder="请输入职业">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">买车情况</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.CarInfo" style="text-align: right;" placeholder="请输入买车情况">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">父亲职业</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.FatherInfo" style="text-align: right;" placeholder="请输入父亲职业">
				</view>
			</view>	
			<view class="item">
				<view class="item-l">母亲职业</view>
				<view class="item-r text-o" >
					<input type="text" v-model="addMsg.MotherInfo" style="text-align: right;" placeholder="请输入母亲职业">
				</view>
			</view>	
			<view class="title">关于我</view>
			<textarea
			  placeholder="谈谈自己"
			  placeholder-style="font-size:12px"
			  :value="addMsg.About"
			  @input='identifybtn'
			  class="inputsmart"
			/>
			<view class="title">理想中的爱情</view>
			<textarea
			  placeholder="请输入理想中的爱情"
			  placeholder-style="font-size:12px"
			  :value="addMsg.IdealLove"
			  @input='identifybtn2'
			  class="inputsmart"
			/>
			<view class="title">照片墙</view>
			<view style="width: 100%;margin-top: 15px;">
				<u-upload :action="action" :file-list="fileList" @on-remove="onRemove1"  :custom-btn="true"
				 @on-success="uploadSuccessHandler">
					<view slot="addBtn" class="slot-btn">
						<u-icon name="photograph" size="40" color="#888"></u-icon>
						<view class="mian-title">上传图片</view>
					</view>
				</u-upload>
			</view>
			<view class="save" :style="{background:mainColor}" @click="save()">
				保存
			</view>
		</view>
		<u-picker v-model="showtime" mode="time" :params="params" @confirm='btnStart' :default-time='addMsg.Birthday'></u-picker>
		<u-picker mode="selector" v-model="showdan"  :default-selector="[0]" :range="Marriage" @confirm='danmarr' range-key="Name"></u-picker>
		<u-picker mode="selector" v-model="showdan2"  :default-selector="[0]" :range="enumList" @confirm='danmarr2' range-key="Name"></u-picker>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				pageTitle: '资料编辑',
				mainColor: '',
				secondary: '',
				showtime:false,//时间弹出选择
				showdan:false,
				showdan2:false,
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},
				xblist:[
					{name:'男',Id:1},{name:'女',Id:2},
				],
				fileList:[],
				addMsg:{
					
				},
				MarriageName:'',
				EducationTypeName:'',
				UserId:120746,
				enumList:[],
				Marriage:[],
				action: this.host2 + "/api/File/UploadTencent",
			}
		},
		created() {
			this.mainColor = this.$uiConfig.mainColor;
			this.secondary = this.$uiConfig.secondary;
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
			
		},
		onLoad(options) {
			if(options && options.UserId){
				this.UserId = options.UserId
				this.init()
			}
			let MallBaseId = uni.getStorageSync("mall_UserInfo").MallBaseId ? uni.getStorageSync("mall_UserInfo").MallBaseId : 1;
			this.action = this.host2 + '/api/File/UploadTencent?MallBaseId=' + MallBaseId
			
			
			
		},
		methods:{
			init() {	
			  this.request2(
			  	{
			  		url: '/api/AppletMiai/GetMiAiBaseIfo',
			  		data: {UserId:this.UserId}
			  	},
			  	res => {
			  		if(res.resultCode==1){
						this.addMsg = res.data;
						if(this.addMsg.AlbumList==null){//判断为null转换下
							this.addMsg.AlbumList= []
						}
						if(this.addMsg.AlbumList.length>0){
							this.addMsg.AlbumList.forEach(x=>{
								let obj ={
									url:x
								}
								this.fileList.push(obj)
							})
						}
						this.getEnumList()//学历列表
						this.getMarriage()//婚姻列表
			  		}
			  	}
			  );
			},
			getEnumList(){
				this.request2(
					{
						url: '/api/AppletMiai/GetEducationTypeEnumList',
						data: {}
					},
					res => {
						if(res.resultCode==1){
							this.enumList = res.data;
							this.enumList.forEach(x=>{
								if(this.addMsg.EducationType==x.Name){
									this.addMsg.EducationType=x.Id
									this.EducationTypeName=x.Name
								}
							})
						}
					}
				);
			},
			getMarriage(){
				this.request2(
					{
						url: '/api/AppletMiai/GetMarriageEnumList',
						data: {}
					},
					res => {
						if(res.resultCode==1){
							this.Marriage = res.data;
							this.Marriage.forEach(x=>{
								if(this.addMsg.Marriage==x.Name){
									this.addMsg.Marriage=x.Id
									this.MarriageName=x.Name
								}
							})
						}
					}
				);
			},
			btnStart(val) {
				this.addMsg.Birthday = val.year + '-' + val.month + '-' + val.day;
			},
			danmarr(val){
				this.addMsg.Marriage = this.Marriage[val].Id
				this.MarriageName = this.Marriage[val].Name
				
			},
			danmarr2(val){
				this.addMsg.EducationType = this.enumList[val].Id
				this.EducationTypeName = this.enumList[val].Name
			},
			identifybtn(val){
				this.addMsg.About = val.detail.value
			},
			identifybtn2(val){
				this.addMsg.IdealLove = val.detail.value
			},
			onRemove1(index) {
				this.addMsg.AlbumList.splice(index, 1);
			},
			uploadSuccessHandler(data, index, lists) {
				let r = JSON.parse(data);
				this.addMsg.AlbumList.push(r.data);
			},
			save(){
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - 2]; // 前一个页面
				uni.showLoading({
					title: '修改中'
				});
				this.request2(
					{
						url: '/api/AppletMiai/GetSetMiAiBaseInfo',
						data: this.addMsg
					},
					res => {
						uni.hideLoading();
						if(res.resultCode==1){
							
						uni.showToast({
							title: res.message,
							icon: "none",
						});
						setTimeout(()=>{
							 uni.navigateBack({
								 success: function() {
									 beforePage.$vm.init(); // 执行前一个页面的方法
								 }
							 });
						},1000)
						}
					}
				);
			}
		}
	}
</script>


