<template>
	<view>
		<!-- #ifdef MP-WEIXIN -->
		<view class="bg" style="position: fixed;top: 0;left: 0;right: 0;z-index: 9;">
			<!-- #endif -->
			<!-- #ifndef MP-WEIXIN -->
			<view class="bg" style="position: fixed;top: 86rpx;left: 0;right: 0;z-index: 9;">
				<!-- #endif -->
				<u-dropdown ref="uDropdown" @open="open">
					<u-dropdown-item @change="change1" v-model="titles1" :title="title1" :options="filterData1">
					</u-dropdown-item>
					<u-dropdown-item @change="change2" v-model="titles2" :title="title2" :options="filterData2">
					</u-dropdown-item>
					<u-dropdown-item @change="change3" v-model="titles3" :title="title3" :options="filterData3">
					</u-dropdown-item>
					<u-dropdown-item @change="change4" v-model="titles4" :title="title4" :options="filterData4">
					</u-dropdown-item>
				</u-dropdown>
			</view>

			<!-- #ifdef MP-WEIXIN -->
			<view class="" v-if="list.length" style="margin-top: 100upx;">
				<!-- #endif -->
				<!-- #ifndef MP-WEIXIN -->
				<view class="" v-if="list.length" style="margin-top: 100upx;">
					<!-- #endif -->
					<view class="listbox" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
						<view class="flex align-center justify-between">
							<view>
								<view class="" style="color: #000;font-size: 34rpx; font-weight: 800;">{{getfomate(item.resumesName,item.resumesSex)}}</view>
								<view class="flex align-center margin-top-xs flex-wrap" style="color: #999999;">
									<text>{{item.resumesSex==1?'男':'女'}}</text>
									<text class="margin-lr-sm" style="width: 1rpx;height: 25rpx;background: #CCCCCC;">
									</text>
									<text>{{item.resumesAge}}岁</text>
									<text class="margin-lr-sm" style="width: 1rpx;height: 25rpx;background: #CCCCCC;">
									</text>
									<text>{{item.resumesWorkExperience}}</text>
									<text class="margin-lr-sm" style="width: 1rpx;height: 25rpx;background: #CCCCCC;">
									</text>
									<text>{{item.resumesEducation}}</text>
									<text class="margin-lr-sm" style="width: 1rpx;height: 25rpx;background: #CCCCCC;">
									</text>
									<text>{{item.resumesCompensation}}</text>
								</view>
							</view>
							<view>
								<image :src="item.avatar?item.avatar:'../../../static/logo.png'"
									style="width: 100upx;height: 100upx;border-radius: 55upx;">
								</image>
							</view>
						</view>
						<view class="margin-top" v-if="item.resumesCompanyList">
							<view class="flex align-center">
								<view class="margin-right-xs">
									<image src="../../../static/images/qi.png" style="width: 30upx;height: 32upx;">
									</image>
								</view>
								<view class="" style="color: #121212;">
									{{item.resumesCompanyList.length!=0?item.resumesCompanyList[0].resumesTitle:'暂无'}}
								</view>
							</view>
							<view class=" margin-left margin-top-xs padding-left-xs"
								style="color: #999999;font-size: 26upx;">
								{{item.resumesCompanyList.length!=0?item.resumesCompanyList[0].resumesPost:'暂无'}}
							</view>
						</view>
						<view class="margin-top-sm" v-if="item.resumesWorkList">
							<view class="flex">
								<view class="margin-right-xs" style="padding-top: 8rpx;">
									<image src="https://zhaopin.xianmaxiong.com/file/uploadPath/2022/09/20/15a1ea35392f86d2dc0f1dc2def0f2d9.png" style="width: 30upx;height:30upx;"></image>
								</view>
								<view style="color: #121212;">意向岗位<text class="text-sm" style="margin-left: 10rpx;color: #999999;">{{item.rulePostName}}</text></view>
							</view>
							<view class="text-sm margin-left margin-top-xs padding-left-xs" style="color: #999999;">
								{{item.resumesPost}}
							</view>
						</view>
						<!-- <view class="margin-top-sm" v-if="item.school">
							<view class="flex align-center">
								<view class="margin-right-xs">
									<image src="../../../static/images/geren.png" style="width: 35upx;height:26upx;">
									</image>
								</view>
								<view class="text-bold" style="color: #121212;">{{item.school?item.school:'暂无'}}</view>
							</view>
							<view class=" margin-left margin-top-xs padding-left-xs"
								style="color: #999999;font-size: 26upx;">
								{{item.rulePostName}}
							</view>
						</view> -->
						<view class="margin-top-sm" v-if="item.resumesIntention">
							<view class="flex">
								<view class="margin-right-xs" style="padding-top: 8rpx;">
									<image src="../../../static/images/index/add.png" style="width: 30upx;height:30upx;">
									</image>
								</view>
								<view class="" style="color: #121212;">意向城市(首选)</view>
							</view>
							<view class=" margin-left margin-top-xs padding-left-xs"
								style="color: #999999;font-size: 26upx;">
								{{item.resumesIntention}}
							</view>
						</view>
						<view class="margin-top-sm" v-if="item.city">
							<view class="flex ">
								<view class="margin-right-xs" style="padding-top: 8rpx;">
									<image src="../../../static/images/index/add.png" style="width: 30upx;height:30upx;">
									</image>
								</view>
								<view class="" style="color: #121212;">意向城市(备选)</view>
							</view>
							<view class=" margin-left margin-top-xs padding-left-xs"
								style="color: #999999;font-size: 26upx;">
								{{item.city}}
							</view>
						</view>
					</view>
				</view>
				<empty v-if="list.length == 0"></empty>
			</view>
</template>

<script>
	import citys from '../citys/citys.js';
	import empty from '@/components/empty.vue'
	export default {
		components: {
			empty
		},
		data() {
			return {
				titles1: '',
				title1: '岗位',
				titles2: '',
				title2: '专业',
				titles3: '',
				titles4: '',
				title4: '意向城市',
				title3: '工作经验',
				page: 1,
				limit: 10,
				gameId: '',
				gameName: '',
				resumesPost: '', //岗位
				resumesMajor: '', //专业 
				resumesWorkExperience: '',
				defaultIndex: [0, 0, 0],
				filterData1: [{
					label: '全部',
					value: '',
				}, ],
				filterData2: [{
					label: '全部',
					value: '',
				}, ],
				filterData3: [{
					label: '全部',
					value: '',
				}, ],
				filterData4: [{
					label: '全部',
					value: '',
				}],
				city: null,
				sex: null,
				order: null,
				latitude: null,
				longitude: null,
				token: '',
				isVip: false,
				myId: '',
				cont: '',
				list: [],
				resumesIntention:'',
				ruleClassifyId:'',
			}
		},
		onLoad(option) {
			this.filterData4 = [...this.filterData4,...citys]
			//岗位
			this.getruleList();
			//工作经验
			this.getdictList2();

			//获取简历列表
			this.getorderList();
		},
		methods: {
			//格式化姓名
			getfomate(data,sex){
				let housex = ''
				if(sex==1){ //先生
					housex = '先生'
				}else{ //女士
					housex = '女士'
				}
				return data.substring(0,1)+housex
			},
			open(e){
				console.log(e)
				if(e==0){
					this.title2 = '专业'
					this.resumesMajor = ''
				}else if(e==1){
					if(this.resumesPost==''){
						this.$refs.uDropdown.close();
						uni.showToast({
							title:'请先选择岗位',
							icon:'none'
						})
					}
				}
				
			},
			//岗位
			change1(e) {
				this.filterData1.map(res => {
					if (res.value == this.titles1) {
						if (res.label == '全部') {
							this.title1 = '岗位'
							this.page = 1
							this.resumesPost = res.value
							this.getorderList(2)
						} else {
							this.title1 = res.label
							this.page = 1
							this.resumesPost = res.label
							this.ruleClassifyId = res.value
							this.getorderList(2)
							this.getPostList();
						}
					}
				})
			},
			//专业
			change2(e) {
				this.filterData2.map(res => {
					if (res.value == this.titles2) {
						if (res.label == '全部') {
							this.title2 = '专业'
							this.page = 1
							this.resumesMajor = res.label
							this.getorderList(2)
						} else {
							this.title2 = res.label
							this.page = 1
							this.resumesMajor = res.label
							this.getorderList(2)
						}
					}
				})
			},
			//工作经验
			change3(e) {
				this.filterData3.map(res => {
					if (res.value == this.titles3) {
						if (res.label == '全部') {
							this.title3 = '工作经验'
							this.page = 1
							this.resumesWorkExperience = res.value
							this.getorderList(2)
						} else {
							this.title3 = res.label
							this.page = 1
							this.resumesWorkExperience = res.value
							this.getorderList(2)
						}
					}
				})
			},
			//意向城市
			change4(e) {
				this.filterData4.map(res => {
					if (res.value == this.titles4) {
						if (res.label == '全部') {
							this.title4 = '意向城市'
							this.page = 1
							this.resumesIntention = res.value
							this.getorderList(2)
						} else {
							this.title4 = res.label
							this.page = 1
							this.resumesIntention = res.label
							this.getorderList(2)
						}
					}
				})
			},
			//查询工作经验
			getdictList2() {
				this.$Request.get("/app/dict/list", {
					type: '工作经验'
				}).then(res => {
					if (res.code == 0) {
						let arr = res.data
						arr = JSON.parse(JSON.stringify(arr).replace(/code/g, 'label'))
						this.filterData3 = [{
							label: '全部',
							value: ''
						}]
						this.filterData3 = [...this.filterData3, ...arr]
					}

				})
			},
			//获取专业
			getPostList() {
				let data = {
					ruleClassifyId: this.ruleClassifyId
				}
				this.$Request.post('/app/rule/selectRulePostList', data).then(res => {
					if (res.code == 0) {
						let arr = res.data
						arr = JSON.parse(JSON.stringify(arr).replace(/rulePostName/g, 'label'))
						arr = JSON.parse(JSON.stringify(arr).replace(/rulePostId/g, 'value'))
						this.filterData2 = arr
					}
				})
			},
			//查询岗位
			getruleList() {
				this.$Request.get("/app/rule/selectRuleClassifyList", {
					status: 1
				}).then(res => {
					if (res.code == 0) {
						let arr = res.data
						arr = JSON.parse(JSON.stringify(arr).replace(/ruleClassifyName/g, 'label'))
						arr = JSON.parse(JSON.stringify(arr).replace(/ruleClassifyId/g, 'value'))
						this.filterData1 = [{
							label: '全部',
							value: ''
						}]
						this.filterData1 = [...this.filterData1, ...arr]
					}

				})
			},
			//简历详情
			goDetail(e) {
				console.log(1)
				uni.navigateTo({
					url: '/pages/index/game/orderDet?resumesId=' + e.resumesId
				});
			},
			//简历列表
			getorderList() {
				let data = {
					page: this.page,
					limit: this.limit,
					status: 2,
					resumesPost: this.resumesPost, //岗位
					isRecommend: 2,
					resumesIntention:this.resumesIntention,//意向位置
					rulePostName: this.resumesMajor, //专业 
					resumesWorkExperience: this.resumesWorkExperience //工作经验
				}
				this.$Request.get("/app/resumes/selectResumesList", data).then(res => {
					if (res.code == 0) {
						this.cont = res.data.totalPage
						if (this.page == 1) {
							this.list = res.data.list
						} else {
							this.list = [...this.list, ...res.data.list]
						}
					}
					uni.stopPullDownRefresh();
				})
			}
		},
		onReachBottom: function() {
			if (this.page == this.cont) {
				uni.showToast({
					title: '已经到底了',
					icon: 'none'
				})

			} else {
				this.page += 1;
				this.getorderList();
			}
		},
		onPullDownRefresh: function() {
			this.page = 1;
			this.getorderList();
		},
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}

	.bg {
		background: #ffffff;
	}

	/deep/.navs {
		background: #FFFFFF !important;
	}

	.listbox {
		background: #FFFFFF;
		border-radius: 24upx;
		margin: 20upx 30upx;
		padding: 30upx;
	}

	.argrtn {
		background: #F6F6F6;
		color: #666666;
		font-size: 24upx;
		border-radius: 8upx;
		padding: 5upx 20upx;
		margin-right: 20upx;
	}
</style>
