choose-my-job.vue 9.9 KB
<template>
	<view style=" width: 100%;height: 100%; display: flex;background-color: #F7F7F7;" :style="vuex_theme">
		<view class="wrap_box">
			<view style="padding: 0 20rpx;">
				<u-form :model="form" :error-type="errorType" ref="uForm">
					<view class="" style="margin: 50rpx 0;display: flex;align-items: center;">
						<view class="event_box" @click="choosePosition">
							<text class="text1">期望职位</text>
							<text v-if='expectJob_category' class="text2">{{expectJob_category}}</text>
							<text v-else class="text3">请选择</text>
						</view>
						<image src="/static/img/common/arrow_right.png"
							style="width: 20rpx;height: 32rpx;float: right;margin-top: 20rpx;"></image>
					</view>
					<view style="width: 100%;height: 1rpx;background-color: #e4e7ed;"></view>
					<view class="" style="margin: 50rpx 0;display: flex;align-items: center;">
						<view class="event_box" @click="selectShow = true">
							<text class="text1">期望薪资</text>
							<text v-if='expect_lower_salary != ""' class="text2">{{`${expect_lower_salary} - ${expect_upper_salary}`}}</text>
							<text v-else class="text3">请选择</text>
						</view>
						<image src="/static/img/common/arrow_right.png"
							style="width: 20rpx;height: 32rpx;float: right;margin-top: 20rpx;"></image>
					</view>
					<view style="width: 100%;height: 1rpx;background-color: #e4e7ed;"></view>
					<!-- <c-input-item label="期望薪资" type="select1" name="salary" v-model="form.salary"
						:options="selectOptions" :rightIcon="true">
					</c-input-item> -->
					<c-input-item label="工作区域" type="area1" name="expect_workplace" v-model="form.expect_workplace"
						:options="area" :rightIcon="true">
					</c-input-item>
				</u-form>
			</view>
		</view>
		<view class="footer">
			<view style="width: 100%;height: 1rpx;border: 1rpx solid #f7f7f7;"></view>
			<view style="padding: 20rpx 40rpx 70rpx 40rpx;" >
				<view class="confirm" @click="confirm">确认</view>
			</view>
		</view>
		<u-select v-model="selectShow" :mode="selectMode" :list="selectOptions" confirm-color='var(--primary-color)'
			@confirm="selectConfirm"></u-select>
	</view>
</template>

<script>
	import area from '@/common/area';
	import {
		salaryOptions
	} from '@/common/util.js'
	import {
		parseInt
	} from 'lodash';
	export default {
		data() {
			return {
				area,
				salaryOptions,
				expect_lower_salary: "",
				expect_upper_salary: "",
				expect_workplaces: [],
				form: {
					expect_job: "",
					salary: "",
					expect_workplace: {},
				},
				fromType: "",
				selectMode: "",
				selectShow: false,
				selectOptions: [],
				position_category: '',
				sub_category: '',
				expectJob_category: '',
			}
		},

		onLoad(option) {
			console.log(option)
			this.fromType = option ? option.type : ""
			if (option.position_category && option.expect_lower_salary) {
				this.position_category = option.position_category;
				this.sub_category = option.sub_category;
				this.expectJob_category = option.expectJob_category;
				this.expect_lower_salary = option.expect_lower_salary
				this.expect_upper_salary = option.expect_upper_salary
				this.expect_workplaces = option.expect_workplaces ? JSON.parse(option.expect_workplaces) : {},
					console.log("--", this.expect_workplaces)
				this.form.expect_workplace = this.expect_workplaces[0]
			}
			// if(this.salaryOptions&&this.salaryOptions[0].label.indexOf('不限')!=-1){
			// 	this.salaryOptions.splice(0, 1)
			// }
			this.selectMode = "mutil-column-auto"
			this.xzload()
		},
		
		onShow() {
			console.log('job_category',this.position_category)
		},
		
		// onUnload() {
		// 	if(this.salaryOptions&&this.salaryOptions[0].label.indexOf('不限')==-1){
		// 		this.salaryOptions.splice(0,0,{
		// 			label: '薪酬不限',
		// 			value: '0'
		// 		})
		// 	}
		// 	console.log('onUnload--', this.salaryOptions)
		// },

		methods: {

			choosePosition() {
				this.$u.route({
					url: '/pages/common/filters-hy/filters-hy',
					params: {
						firstCategoryName: this.position_category,
						secondCategoryName: this.sub_category,
						expectJobName: this.expectJob_category,
						fromType: '1'
					}
				})
			},

			handleSalary() {
				return new Promise((resolve, reject) => {
					console.log(this.form.salary)
					if (this.form.salary == 0) {
						this.expect_lower_salary = null
						this.expect_upper_salary = null
					} else if (this.form.salary == 1) {
						this.expect_lower_salary = 0
						this.expect_upper_salary = 2000
					} else if (this.form.salary == 2) {
						this.expect_lower_salary = 2000
						this.expect_upper_salary = 5000
					} else if (this.form.salary == 3) {
						this.expect_lower_salary = 5000
						this.expect_upper_salary = 8000
					} else if (this.form.salary == 4) {
						this.expect_lower_salary = 8000
						this.expect_upper_salary = 12000
					} else if (this.form.salary == 5) {
						this.expect_lower_salary = 12000
						this.expect_upper_salary = null
					} else {
						this.showToast("请选择期望薪资!")
					}
					console.log("salary--", this.expect_lower_salary, this.expect_upper_salary)
					resolve()
				})
			},
			
			getSalary(){
				
			},

			handleArea() {
				return new Promise((resolve, reject) => {
					if (this.form.expect_workplace) {
						this.expect_workplaces = []
						this.expect_workplaces.push(this.form.expect_workplace)
					} else {
						this.showToast("请选择工作区域!")
					}
					console.log("area--", this.form.expect_workplace, this.expect_workplaces)
					resolve()
				})
			},

			async confirm() {
				// if (this.form.salary) {
				// 	await this.handleSalary()
				// } else {
				// 	this.showToast("请完善信息!")
				// }
				// if (this.expect_upper_salary == '' && this.expect_lower_salary == '') {
				// 	this.showToast("请完善信息!")
				// }
				await this.handleArea()
				console.log("confirm--", this.expectJob_category, this.expect_upper_salary,this.expect_workplaces)
				if (this.expectJob_category && this.expect_upper_salary && this.expect_lower_salary && this.expect_workplaces && this.expect_workplaces.length >0) {
					let pages = getCurrentPages();
					let prevPage = pages[pages.length - 2];
					
					let cateObj = {
						first_category: this.position_category,
						second_category: this.sub_category,
						expect_job: this.expectJob_category
					}

					if (this.fromType == "from_edit") {
						// prevPage.$vm.detailObj.first_category = this.position_category
						// prevPage.$vm.detailObj.second_category = this.sub_category
						// prevPage.$vm.detailObj.expectJob_category = this.expectJob_category
						// prevPage.$vm.detailObj.salary = this.form.salary + ""
						
						prevPage.$vm.detailObj.expect_job = [cateObj]
						prevPage.$vm.detailObj.expect_lower_salary = Number(this.expect_lower_salary)
						prevPage.$vm.detailObj.expect_upper_salary = Number(this.expect_upper_salary)
						prevPage.$vm.detailObj.expect_workplaces = this.expect_workplaces
						prevPage.$vm.expectJob_category = this.expectJob_category
					} else {
						let salaryIdx = parseInt(this.form.salary) -1
						console.log("sallary--",salaryIdx,this.salaryOptions[salaryIdx].label)
						prevPage.$vm.form.expect_job = this.sub_category
						prevPage.$vm.my_expect = this.sub_category + "," + this.salaryOptions[salaryIdx].label +
							"," + this.form.expect_workplace.province +'/'+ this.form.expect_workplace.city +'/'+
							this.form.expect_workplace.district;
						prevPage.$vm.form.salary = this.form.salary + ""
						prevPage.$vm.form.expect_lower_salary = this.expect_lower_salary
						prevPage.$vm.form.expect_upper_salary = this.expect_upper_salary
						prevPage.$vm.form.expect_workplaces = this.expect_workplaces
						prevPage.$vm.form.job_category = this.position_category?this.position_category:""
					}
					uni.navigateBack({
						delta: 1
					})
				} else {
					this.showToast("请完善信息!")
				}
			},
			
			showToast(msg){
				uni.showToast({
					title:msg,
					icon:'none'
				})
			},	
			
			xzload() {
				let list1 = []
				for (var i = 1; i < 50; i++) {
					let list2 = []
					for (var j = 1; j < 10; j++) {
						list2.push({
							label: (i + j) + '000',
							value: (i + j) + '000',
						})
					}
					list1.push({
						label: i + '000',
						value: i + '000',
						children: list2
					});
				}
				this.selectOptions = list1
			},
			
			selectConfirm(e) {
				this.expect_lower_salary = e[0].value
				this.expect_upper_salary = e[1].value
			},
		}
	}
</script>

<style lang="scss" scoped>
	.wrap_box {
		padding: 40rpx;
		background-color: #fff;
		margin: 20rpx 20rpx 0 20rpx;
		width: 100%;

		.text_black_30 {
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #000000;
		}

		.text_gray_26 {
			font-size: 26rpx;
			font-family: PingFangSC-Light, PingFang SC;
			font-weight: 300;
			color: rgba(0, 0, 0, 0.65);
			margin-top: 16rpx;
		}

		.text_gray_30 {
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.45);
		}
	}

	.event_box {
		display: flex;
		flex-direction: column;
		width: 100%;
	
		.text1 {
			font-size: 26rpx;
			font-weight: 400;
			line-height: 26rpx;
			color: #000000;
		}
	
		.text2 {
			font-size: 30rpx;
			font-family:' PingFangSC-Regular, PingFang SC';
			font-weight: 500;
			color: #000000;
			line-height: 30rpx;
			margin-top: 40rpx;
		}
		
		.text3{
			font-size: 30rpx;
			color:rgba(0,0,0,0.45);
			line-height: 30rpx;
			margin-top: 40rpx;
		}
	
	}

	.footer {
		width: 100%;
		background-color: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 99;
	
		.confirm {
			background: linear-gradient(180deg, var(--primary-color000) 0%, var(--primary-color) 100%);
			box-shadow: 0px 2px 20px 0px var(--primary-color03);
			border-radius: 24px;
			padding: 24rpx;
			text-align: center;
			font-size: 34rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>