<template>
	<view>
		<view class="cityItem">
			<view class="cityItem-box flex justify-center">
				<view class="cityItem-box-con flex justify-between align-center">
					<view class="" style="color: #333333;font-size: 28rpx;font-weight: 800;width: 200rpx;">
						意向地址(首选)
					</view>
					<view class="flex align-center">
						<u-input v-model="resumesIntention" @click="getCity(1)" :disabled="true" type="text"
							:border="false" placeholder="选择意向位置" />
						<u-icon name="arrow-right" style="margin-left: 10rpx;" color="#c0c4cc" size="28"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<view class="cityItem" style="margin-top: 20rpx;">
			<view class="cityItem-box flex justify-center">
				<view class="cityItem-box-con flex justify-between align-center">
					<view class="" style="color: #333333;font-size: 28rpx;font-weight: 800;width: 200rpx;">
						意向地址(备选)
					</view>
					<view class="flex align-center">
						<u-input v-model="city" @click="getCity(2)" :disabled="true" type="text" :border="false"
							placeholder="选择意向位置" />
						<u-icon name="arrow-right" style="margin-left: 10rpx;" color="#c0c4cc" size="28"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<view class="sumbitBtn flex justify-center">
			<view class="sumbitBtn-box" style="background-color: #ffffff;border-radius: 24rpx;padding: 20rpx 20rpx 20rpx 50rpx;height: auto;">
				<view class="" style="color: black;color:#333333;font-size:14px;font-weight:800;margin-left: -20rpx;margin-bottom: 20rpx;">
					本人其他专业描述(多选)
				</view>
				<u-checkbox-group size="30rpx"  @change="checkboxGroupChange">
					<u-checkbox label-size="20rpx" @change="checkboxChange" v-model="item.checked" v-for="(item, index) in list"
						:key="index" :name="item.value">{{item.value}}</u-checkbox>
				</u-checkbox-group>
			</view>
		</view>
		<view class="sumbitBtn flex justify-center" style="height: 88rpx;">
			<view class="sumbitBtn-box flex align-center justify-center" @click="submit()">
				保存
			</view>
		</view>

		<!-- 选择城市1 -->
		<u-picker mode="region" v-model="show" :params="params" @confirm="confirm"></u-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				params: {
					province: true,
					city: true,
					area: false
				},
				resumesIntention: '',
				city: '',
				type: '',
				resumesId: '',
				list: [],
				status:'',
			};
		},
		onLoad() {
			this.getdictList();
			
			
			
		},
		methods: {
			getdictList() {
				this.$Request.get("/app/dict/list", {
					type: '其他专业'
				}).then(res => {
					if (res.code == 0) {
						let arr = res.data
						arr.map(item=>{
							item.checked = false
							item.disabled = false
						})
						this.list = arr
						this.getDetails();
					}
			
				})
			},
			//保存
			submit() {
				let ruleMajor = []
				this.list.map(item=>{
					if(item.checked==true){
						ruleMajor.push(item.value)
					}
				})
				this.$Request.postJson("/app/resumes/updateResumess", {
					resumesIntention: this.resumesIntention,
					city: this.city,
					resumesId: this.resumesId,
					ruleMajor:ruleMajor.join(','),
					status:this.status
				}).then(res => {
					if (res.code == 0) {
						let that = this
						uni.showModal({
							title:'提交成功',
							content:'请耐心等待客服审核',
							showCancel:false,
							confirmText:'确认',
							complete(ret) {
								if(ret.confirm){
									uni.navigateBack()
								}
							}
						})
						// let that = this
						// uni.showModal({
						// 	title:'提交成功',
						// 	content:'请联系客服核定大致薪资区间及岗位',
						// 	showCancel:false,
						// 	confirmText:'联系客服',
						// 	complete(ret) {
						// 		if(ret.confirm){
						// 			// #ifdef MP-WEIXIN
						// 			wx.openCustomerServiceChat({
						// 				extInfo: {
						// 					url: that.$queue.getData('kefu')
						// 				},
						// 				corpId: that.$queue.getData('kefuAppid'),
						// 				success(res) {
						// 					console.log(res)
						// 				},
						// 			})
						// 			// #endif
						// 			// #ifdef H5
						// 			window.location.href = that.$queue.getData('kefu');
						// 			// #endif
						// 			// #ifdef APP
						// 			let kefu = that.$queue.getData('kefu')
						// 			console.log(kefu)
						// 			plus.runtime.openURL(kefu, function(res) {});
						// 			// #endif
						// 		}
						// 	}
						// })
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				});
			},
			//获取简历数据
			getDetails() {
				this.$Request.get('/app/resumes/selectResumesByUserId').then(res => {
					if (res.code == 0) {
						this.resumesIntention = res.data.resumesIntention
						this.city = res.data.city
						this.status = res.data.status
						this.resumesId = res.data.resumesId
						let arr = (res.data.ruleMajor).split(',')
						this.list.map(item=>{
							arr.map(ite=>{
								if(ite==item.value){
									item.checked = true
								}
							})
						})
					}
				})
			},
			//选择城市
			getCity(type) { //type:  1:意向城市1  2:意向城市2
				this.type = type
				this.show = true
			},
			confirm(value) {
				console.log(value)
				switch (this.type) {
					case 1:
						this.resumesIntention = value.city.label
						break;
					case 2:
						this.city = value.city.label
						break;
					default:
						break;
				}
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F2F2F7;
	}

	.cityItem {
		width: 100%;
		height: 120rpx;
		margin-top: 30rpx;
		display: flex;
		justify-content: center;

		.cityItem-box {
			width: 686rpx;
			height: 100%;
			background-color: #FFFFFF;
			border-radius: 24rpx;

			.cityItem-box-con {
				width: 626rpx;
			}
		}
	}

	.sumbitBtn {
		width: 100%;
		margin-top: 20rpx;

		.sumbitBtn-box {
			width: 686rpx;
			height: 100%;
			border-radius: 8rpx;
			background: #82A9FE;
			color: #FFFFFF;
			font-size: 32rpx;
			font-weight: bold;
		}
	}
</style>
