<template>
	<view>
		<!-- #ifdef H5 -->
		<u-sticky h5-nav-height="0">
		<!-- #endif -->
			<!-- #ifndef H5 -->
			<u-sticky>
			<!-- #endif -->
				<u-tabs :list="list" active-color="#00b78f" :is-scroll="false" :current="current"
					@change="change"></u-tabs>
			</u-sticky>
			<!-- 简历列表 -->
			<view class="qyList flex justify-center">
				<view class="qyList-box">
					<view class="qyList-box-item flex justify-center" v-for="(item,index) in datasList" :key="index"
						@click="goNav(item,index)">
						<view class="qyList-box-item-box">
							<view v-if="item.isSee == 1" class="flex align-center justify-end"
								style="margin-top: 40rpx;color: #00b78f;">
								已读
							</view>
							<view class="qyList-box-item-info flex justify-between align-center">
								<view class="qyList-box-item-info-l">
									<view class="" style="color: #212121;font-size: 38rpx;font-weight: 800;">
										{{item.resumesName?item.resumesName:''}}
									</view>
									<view class="flex align-center flex-wrap"
										style="color: #999999;font-size: 26rpx;margin-top: 10rpx;">
										<text>{{item.resumesAge?item.resumesAge:''}}岁</text>
										<text style="margin-left: 20rpx;margin-right: 20rpx;">|</text>
										<text>{{item.resumesWorkExperience?item.resumesWorkExperience:''}}</text>
										<text style="margin-left: 20rpx;margin-right: 20rpx;">|</text>
										<text>{{item.school?item.school:''}}</text>
										<text style="margin-left: 20rpx;margin-right: 20rpx;">|</text>
										<text>期望{{item.resumesCompensation?item.resumesCompensation:''}}</text>
									</view>
								</view>
								<view class="qyList-box-item-info-r">
									<image :src="item.avatar?item.avatar:'../../static/logo.png'"
										style="width: 95rpx;height: 95rpx;border-radius: 50%;" mode=""></image>
								</view>
							</view>
							<view class="qyList-box-item-job flex align-center">
								<u-icon name="heart-fill" color="#016BF6" size="30" style="margin-right: 16rpx;">
								</u-icon>
								期望岗位:{{item.resumesPost?item.resumesPost:''}}
							</view>
							<view class="qyList-box-item-job flex align-center"
								v-if="item.resumesCompanyList && item.resumesCompanyList.length>0">
								<image src="../../static/images/qi.png"
									style="width: 30rpx;height: 32rpx;margin-right: 16rpx;" mode=""></image>
								{{item.resumesCompanyList[0].resumesTitle}}
								/
								{{item.resumesCompanyList[0].resumesPost}}
							</view>
							<view class="qyList-box-item-rem" v-if="item.resumesDetails">
								优势:{{item.resumesDetails}}
							</view>
							<view class="line"></view>
							<view class="qyList-box-item-box-ti flex justify-between align-center">
								<text>投递岗位</text>
								<text>{{item.stationName?item.stationName:''}}--{{item.ruleClassifyName?item.ruleClassifyName:''}}</text>
							</view>
						</view>
					</view>
					<empty v-if="datasList.length==0" />
				</view>
			</view>
			<!-- 筛选悬浮 -->
			<view class="filterSe" @click="goScreen()">
				<image src="../../static/images/my/filterSe.png" mode=""></image>
			</view>
	</view>
</template>

<script>
	import empty from '../../components/empty.vue'
	export default {
		components: {
			empty
		},
		data() {
			return {
				list: [{
					name: '全部',
					isSee: '',
				}, {
					name: '已读',
					isSee: 1
				}, {
					name: '未读',
					isSee: 0
				}],
				current: 0,
				datasList: [],
				page: 1,
				limit: 10,
				totlo: 0,
				filter: {
					resumesCompensation: '', //薪资
					resumesEducation: '', //学历
					resumesWorkExperience: '', //经验
					industryName: '', //行业
				}
			};
		},
		onLoad() {
			this.getDataList()
		},
		onReachBottom() {
			if (this.page < this.totlo) {
				this.page += 1
				this.getDataList()
			}
		},
		onPullDownRefresh() {
			this.page = 1
			this.getDataList()
		},
		onShow() {
			if (uni.getStorageSync('isCompyHistory') && (uni.getStorageSync('isCompyHistory')).length > 0) {
				let isCompyHistory = uni.getStorageSync('isCompyHistory')
				isCompyHistory.map(item => {
					let arr = []
					item.list.map(ite => {
						if (ite.value != '不限') {
							arr.push(ite.value)
						}
					})
					switch (item.name) {
						case '学历':
							this.filter.resumesEducation = arr.join(',')
							break;
						case '薪资':
							this.filter.resumesCompensation = arr.join(',')
							break;
						case '经验':
							this.filter.resumesWorkExperience = arr.join(',')
							break;
						case '行业':
							this.filter.industryName = arr.join(',')
							break;
					}

				})
			} else {
				this.filter.resumesEducation = '' //学历
				this.filter.resumesWorkExperience = '' //经验
				this.filter.industryName = '' //行业
				this.filter.resumesCompensation = '' //薪资
			}
		},
		watch: {
			filter: {
				handler() {
					this.page = 1
					this.getDataList()
				},
				deep: true,
				immediate: true
			}
		},
		onUnload() {
			uni.removeStorageSync('isCompyHistory')
		},
		methods: {
			change(index) {
				this.current = index;
				this.page = 1
				this.getDataList()
			},
			// 去筛选
			goScreen() {
				uni.navigateTo({
					url: '/package/screen/screen?isCompyHistory=1'
				})
			},
			// 标记为已读
			setIsSee(recordId, index) {
				let data = {
					recordId: recordId
				}
				this.$Request.getT('/app/sendRecord/seeRecord', data).then(res => {
					if (res.code == 0) {
						this.datasList[index].isSee = 1
					}
				})
			},
			goNav(item, index) {
				if (item.resumesId) {
					this.setIsSee(item.recordId, index)
					uni.navigateTo({
						url: '/pages/index/game/orderDet?resumesId=' + item.resumesId + '&isSee=' + item.isSee
					})
				} else {
					uni.showToast({
						title: '该用户简历不存在',
						icon: 'none'
					})
				}
				console.log(url, '1111')

			},
			//获取已投递简历的列表
			getDataList() {
				let data = {
					page: this.page,
					limit: this.limit,
					resumesCompensation: this.filter.resumesCompensation, //薪资
					resumesEducation: this.filter.resumesEducation, //学历
					resumesWorkExperience: this.filter.resumesWorkExperience, //经验
					industryName: this.filter.industryName, //行业
					isSee: this.list[this.current].isSee
				}
				this.$Request.getT('/app/sendRecord/getCompanyRecordListV2', data).then(res => {
					if (res.code == 0) {
						this.totlo = res.data.pages //记录总页数
						if (this.page == 1) {
							this.datasList = res.data.records
						} else {
							this.datasList = [...this.datasList, ...res.data.records]
						}
					}
				})
			},
		}
	}
</script>

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

	.filterSe {
		position: fixed;
		bottom: 10vh;
		right: 30rpx;

		image {
			width: 100rpx;
			height: 100rpx;
			// border-radius: 50%;
		}
	}

	.qyList {
		width: 100%;
		height: auto;
		margin-top: 20rpx;

		.qyList-box {
			width: 686rpx;
			height: 100%;

			.qyList-box-item {
				width: 100%;
				// height: 400rpx;
				padding-bottom: 40rpx;
				background-color: #ffffff;
				border-radius: 24rpx;
				margin-bottom: 20rpx;

				.qyList-box-item-box {
					width: 626rpx;
					height: 100%;
				}

				.line {
					width: 100%;
					border-bottom: 1rpx solid #F2F2F7;
					margin-top: 20rpx;
				}

				.qyList-box-item-box-ti {
					margin-top: 20rpx;
				}

				.qyList-box-item-info {
					margin-top: 20rpx;
					// margin-top: 40rpx;
				}

				.qyList-box-item-job {
					color: #121212;
					font-size: 28rpx;
					font-weight: 500;
					margin-top: 20rpx;
				}

				.qyList-box-item-rem {
					color: #999999;
					font-size: 26rpx;
					margin-top: 20rpx;
				}
			}
		}
	}
</style>