<template>
	<view class="talent-search-page">
		<!-- 搜索框 -->
		<view class="search flex align-center justify-center">
			<view class="search-box">
				<view class="dropdown-btn" @click="showDropdown">
					<text class="dropdown-text">{{ positionOptions[selectedPosition] }}</text>
					<u-icon name="arrow-down" color="#016BF6" size="16"></u-icon>
				</view>
				<view class="separator"></view>
				<input 
					class="search-input"
					v-model="searchKeyword"
					placeholder="通过职位关键词查询"
					@confirm="custom"
				/>
			</view>
			<view class="search-btn" @click="custom">搜索</view>
		</view>
		
		<!-- 人才列表 -->
		<view class="talent-list">
			<view 
				class="talent-card" 
				v-for="(talent, index) in talentList" 
				:key="index"
				@click="goToTalentDetail(talent)"
			>
				<view class="talent-content">
					<!-- 头像和基本信息 -->
					<view class="talent-header">
						<image :src="talent.avatar" class="talent-avatar" mode="aspectFill"></image>
						<view class="talent-info">
							<view class="talent-name-section">
								<view class="talent-name">{{ talent.name }}</view>
								<view class="talent-tags">
									<view class="status-tag online" v-if="talent.isOnline">在线</view>
									<view class="status-tag hot" v-if="talent.isHot">热门搜索</view>
									<view class="status-tag active" v-if="talent.lastActive">{{ talent.lastActive }}</view>
								</view>
							</view>
							<!-- 经验和薪资 -->
							<view class="talent-experience">
								<text class="experience-text">{{ talent.experience }}</text>
								<text class="education-salary">{{ talent.education }} {{ talent.salary }}</text>
								<text class="status-text">{{ talent.jobStatus }}</text>
							</view>
						</view>
					</view>
					
					<!-- 当前职位 -->
					<view class="current-job" v-if="talent.currentJob">
						<image src="../../static/images/aixin.svg" class="job-icon" mode="aspectFit"></image>
						<text class="job-text">{{ talent.currentJob }}</text>
					</view>
					
					<!-- 求职期望 -->
					<view class="job-expectation">
						<image src="../../static/images/xiangzi.svg" class="job-icon" mode="aspectFit"></image>
						<text class="expectation-text">求职期望: {{ talent.jobExpectation }}</text>
					</view>
					
					<!-- 技能标签 -->
					<view class="skill-tags">
						<view 
							class="skill-tag" 
							v-for="(skill, skillIndex) in talent.skills" 
							:key="skillIndex"
						>
							{{ skill }}
						</view>
					</view>
					
					<!-- 工作描述 -->
					<view class="job-description">
						<text class="description-text">{{ talent.description }}</text>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 职位选择弹窗 -->
		<view class="position-modal" v-if="showPositionModal" @click="hidePositionModal">
			<view class="position-modal-content" @click.stop>
				<!-- 拖拽条 -->
				<view class="position-modal-handle"></view>
				
				<!-- 标题 -->
				<view class="position-modal-title">选择职位</view>
				
				<!-- 职位选项 -->
				<view class="position-options">
					<view 
						class="position-option" 
						:class="selectedPosition === index ? 'active' : ''"
						@click="selectPosition(index)"
						v-for="(option, index) in positionOptions" 
						:key="index"
					>
						<view class="position-option-icon">
							<view class="check-icon" v-if="selectedPosition === index">✓</view>
						</view>
						<text class="position-option-text">{{ option }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			searchKeyword: '',
			currentSx: 0,
			sxTypeList: [
				{
					id: 1,
					name: '推荐',
				},
				{
					id: 2,
					name: '最新',
				}
			],
			city: '深圳',
			county: '',
			showSortModalFlag: false,
			selectedSort: 0,
			sortOptions: ['综合排序', '最新优先', '距离优先'],
			showPositionModal: false,
			selectedPosition: 0,
			positionOptions: ['亚马逊运营', 'TikTok运营', '采购经理', '不限职位'],
			talentList: [
				{
					id: 1,
					name: '刘**',
					avatar: '../../static/images/avator.png',
					isOnline: true,
					isHot: true,
					experience: '8年',
					education: '本科',
					salary: '10-15K',
					jobStatus: '在职&考虑机会',
					currentJob: '通拓集团·店铺运营',
					jobExpectation: '亚马逊运营',
					skills: ['精品', '铺货', 'TikTok', '平台运营', '投放策略', '3C数码'],
					description: '负责Amazon英国、欧洲站、制定推广与销售计划,达成团队要求的销售业绩;做好数据的统计分析工作,收集、分析...',
					workPeriod: '2021-2024'
				},
				{
					id: 2,
					name: '李**',
					avatar: '../../static/images/avator.png',
					lastActive: '5分钟前活跃',
					experience: '25年应届生',
					education: '本科',
					salary: '8-12K',
					jobStatus: '离职&随时到岗',
					currentJob: '大连海事学院·法学',
					jobExpectation: '亚马逊运营',
					skills: ['精品', '铺货', 'TikTok', '平台运营', '投放策略', '3C数码'],
					description: '负责Amazon英国、欧洲站、制定推广与销售计划,达成团队要求的销售业绩;做好数据的统计分析工作,收集、分析...',
					workPeriod: ''
				},
				{
					id: 3,
					name: '李**',
					avatar: '../../static/images/avator.png',
					lastActive: '刚刚活跃',
					experience: '25年应届生',
					education: '本科',
					salary: '8-12K',
					jobStatus: '离职&随时到岗',
					currentJob: '臣美科技·小红书运营',
					jobExpectation: '亚马逊运营',
					skills: ['精品', '铺货', 'TikTok', '平台运营', '投放策略', '3C数码'],
					description: '负责Amazon英国、欧洲站、制定推广与销售计划,达成团队要求的销售业绩;做好数据的统计分析工作,收集、分析...',
					workPeriod: '2021-2025'
				},
				{
					id: 4,
					name: '李**',
					avatar: '../../static/images/avator.png',
					lastActive: '刚刚活跃',
					experience: '25年应届生',
					education: '本科',
					salary: '8-12K',
					jobStatus: '离职&随时到岗',
					currentJob: '臣美科技·小红书运营',
					jobExpectation: '亚马逊运营',
					skills: ['精品', '铺货', 'TikTok', '平台运营', '投放策略', '3C数码'],
					description: '负责Amazon英国、欧洲站、制定推广与销售计划,达成团队要求的销售业绩;做好数据的统计分析工作,收集、分析...',
					workPeriod: ''
				}
			]
		}
	},
	methods: {
		// 返回上一页
		goBack() {
			uni.navigateBack()
		},
		
		// 显示下拉菜单
		showDropdown() {
			this.showPositionModal = true
		},
		
		// 隐藏职位选择弹窗
		hidePositionModal() {
			this.showPositionModal = false
		},
		
		// 选择职位
		selectPosition(index) {
			this.selectedPosition = index
			// 更新下拉按钮显示的文字
			const selectedText = this.positionOptions[index]
			// 这里可以更新下拉按钮的显示文字
			uni.showToast({
				title: `已选择: ${selectedText}`,
				icon: 'none'
			})
			this.hidePositionModal()
		},
		
		// 搜索
		custom() {
			console.log('搜索关键词:', this.searchKeyword)
			// 这里可以添加搜索逻辑
		},
		
		// 清空搜索
		clear() {
			this.searchKeyword = ''
		},
		
		// 跳转页面
		goNav(url) {
			if (uni.getStorageSync('token')) {
				uni.navigateTo({
					url: url
				})
			} else {
				this.noLogin()
			}
		},
		
		// 未登录提示
		noLogin() {
			uni.showModal({
				title: '提示',
				content: '您还未登录,请先登录',
				confirmColor: '#00B88F',
				success: function(res) {
					if (res.confirm) {
						uni.navigateTo({
							url: '/pages/public/login'
						})
					}
				}
			})
		},
		
		// 显示排序弹窗
		showSortModal() {
			this.showSortModalFlag = true
		},
		
		// 隐藏排序弹窗
		hideSortModal() {
			this.showSortModalFlag = false
		},
		
		// 选择排序选项
		selectSort(index) {
			this.selectedSort = index
			uni.showToast({
				title: `已选择: ${this.sortOptions[index]}`,
				icon: 'none'
			})
			this.hideSortModal()
		},
		
		// 跳转到人才详情
		goToTalentDetail(talent) {
			console.log('查看人才详情:', talent)
			// 这里可以跳转到人才详情页面
		}
	}
}
</script>

<style lang="scss" scoped>
// 激活状态样式
.active3 {
	flex-direction: row;
	justify-content: center;
	align-items: center;
	padding: 12rpx;
	border-radius: 12rpx;
	background: #FFFFFF !important;
	margin-right: 12rpx;
	border: 0.5px solid rgba(1, 107, 246, 1);

	color: rgba(1, 107, 246, 1) !important;
	font-family: DM Sans;
	font-size: 22rpx;
	font-weight: 400;
	line-height: 20rpx;
	letter-spacing: 0px;
	text-align: left;
}

.talent-search-page {
	min-height: 100vh;
	background-color: #f5f5f5;
}


// 搜索框
.search {
	position: fixed;
	top: 0;
	width: 100%;
	padding: 80rpx 20rpx 20rpx 20rpx;
	background: linear-gradient(180.00deg, rgba(255, 102, 0, 1),rgba(255, 89, 89, 1) 83%);
	z-index: 99;

	.search-box {
		flex: 1;
		box-sizing: border-box;
		border: 1px solid rgba(227, 231, 236, 1);
		border-radius: 24px;
		background: rgba(241, 241, 241, 1);
		overflow: hidden;
		display: flex;
		align-items: center;
		padding: 0 32rpx;
		height: 60rpx;
	}

	.dropdown-btn {
		display: flex;
		align-items: center;
		padding: 8rpx 16rpx;
		background-color: #F1F1F1;
		border: 1rpx solid #016BF6;
		border-radius: 8rpx;
		margin-right: 12rpx;
		
		.dropdown-text {
			color: rgba(1, 107, 246, 1);
			font-family: DM Sans;
			font-size: 20rpx;
			font-weight: 400;
			line-height: 20rpx;
			letter-spacing: -0.5px;
			text-align: left;
			margin-right: 8rpx;
		}
	}

	.separator {
		width: 4rpx;
		height: 30rpx;
		background-color: rgba(153, 153, 153, 1);
		margin-right: 12rpx;
	}

	.search-input {
		flex: 1;
		height: 100%;
		background: transparent;
		color: #333;
		font-family: DM Sans;
		font-size: 20rpx;
		font-weight: 400;
		line-height: 48rpx;
		letter-spacing: 0.5%;
		text-align: left;
		
		&::placeholder {
			color: rgba(182, 182, 182, 1);
			font-family: DM Sans;
			font-size: 20rpx;
			font-weight: 400;
			line-height: 48rpx;
			letter-spacing: 0.5%;
			text-align: left;
		}
	}

	.search-btn {
		width: 80rpx;
		color: rgba(255, 255, 255, 1);
		font-family: DM Sans;
		font-size: 20rpx;
		font-weight: 500;
		line-height: 48rpx;
		letter-spacing: 0.5%;
		text-align: center;
	}
}


.search-bar {
	display: flex;
	align-items: center;
	margin-bottom: 20rpx;
	
	.search-input {
		flex: 1;
		height: 80rpx;
		background-color: #f8f8f8;
		border-radius: 40rpx;
		padding: 0 30rpx;
		font-size: 28rpx;
		color: #333;
		margin-right: 20rpx;
	}
	
	.search-btn {
		width: 120rpx;
		height: 80rpx;
		background-color: #016BF6;
		color: #ffffff;
		border-radius: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
	}
}

.filter-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 16rpx;
	
	.filter-tag {
		padding: 12rpx 24rpx;
		background-color: #ffffff;
		border: 1rpx solid #e5e5e5;
		border-radius: 20rpx;
		font-size: 24rpx;
		color: #666;
	}
}

.talent-list {
	margin-top: 160rpx;
	padding: 20rpx;
}

.talent-card {
	background-color: #ffffff;
	border-radius: 16rpx;
	margin-bottom: 20rpx;
	padding: 30rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}

.talent-content {
	.talent-header {
		display: flex;
		align-items: flex-start;
		
		.talent-avatar {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			margin-right: 20rpx;
		}
		
		.talent-info {
			flex: 1;
			
			.talent-name-section {
				display: flex;
				align-items: center;
				justify-content: flex-start;
				width: 100%;
				margin-bottom: 6rpx;
			}
			
			.talent-name {
				color: rgba(51, 51, 51, 1);
				font-family: DM Sans;
				font-size: 28rpx;
				font-weight: 500;
				line-height: 36rx;
				letter-spacing: 0.5%;
				text-align: left;
				margin-right: 16rpx;
			}
			
			.talent-tags {
				display: flex;
				flex-wrap: wrap;
				gap: 10rpx;
				
				.status-tag {
					padding: 8rpx;
					border-radius: 12rpx;
					font-size: 18rpx;
					font-family: DM Sans;
					font-weight: 400;
					line-height: 20rpx;
					letter-spacing: -0.5px;
					text-align: left;
					
					&.online {
						background: rgba(213, 255, 231, 1);
						color: rgba(29, 209, 104, 1);
					}
					
					&.hot {
						background: rgba(252, 233, 220, 1);
						color: rgba(1, 107, 246, 1);
					}
					
					&.active {
						color: rgba(153, 153, 153, 1);
					}
				}
			}
		}
	}
	
	.talent-experience {
		display: flex;
		align-items: center;
		margin-bottom: 12rpx;
		gap: 16rpx;
		color: rgba(156, 164, 171, 1);
		font-family: DM Sans;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 32rpx;
		letter-spacing: 0.5%;
		text-align: left;
	}
	
	.current-job {
		display: flex;
		align-items: center;
		margin-bottom: 12rpx;
		
		.job-icon {
			width: 40rpx;
			height: 40rpx;
			margin-right: 8rpx;
		}
		
		.job-text {
			color: rgba(156, 164, 171, 1);
			font-family: DM Sans;
			font-size: 24rpx;
			font-weight: 400;
			line-height: 40rpx;
			letter-spacing: 0.5%;
			text-align: left;
		}
	}
	
	.job-expectation {
		display: flex;
		align-items: center;
		margin-bottom: 16rpx;

		.job-icon {
			width: 40rpx;
			height: 40rpx;
			margin-right: 8rpx;
		}
		
		.expectation-text {
			color: rgba(156, 164, 171, 1);
			font-family: DM Sans;
			font-size: 24rpx;
			font-weight: 400;
			line-height: 40rpx;
			letter-spacing: 0.5%;
			text-align: left;
		}
	}
	
	.skill-tags {
		display: flex;
		flex-wrap: wrap;
		gap: 10rpx;
		margin-bottom: 16rpx;
		
		.skill-tag {
			padding: 8rpx;
			background: rgba(198, 198, 198, 0.1);
			border-radius: 12rpx;
			color: rgba(153, 153, 153, 1);
			font-family: DM Sans;
			font-size: 20rpx;
			font-weight: 400;
			line-height: 20rpx;
			letter-spacing: -0.5px;
			text-align: left;
		}
	}
	
	.job-description {
		margin-bottom: 12rpx;
		
		.description-text {
			color: rgba(97, 110, 124, 1);
			font-family: DM Sans;
			font-size: 24rpx;
			font-weight: 400;
			line-height: 32rpx;
			letter-spacing: 0px;
			text-align: left;
		}
	}
	
	.work-period {
		text-align: right;
		
		.period-text {
			font-size: 22rpx;
			color: #999;
		}
		}
	}

	// 职位选择弹窗样式
	.position-modal {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.5);
		z-index: 10001;
		display: flex;
		align-items: flex-end;
		
		.position-modal-content {
			width: 100%;
			background: #ffffff;
			border-radius: 24rpx 24rpx 0 0;
			padding: 20rpx 40rpx 40rpx 40rpx;
			max-height: 60vh;
			
			.position-modal-handle {
				width: 80rpx;
				height: 8rpx;
				background: #E5E5E5;
				border-radius: 4rpx;
				margin: 0 auto 30rpx auto;
			}
			
			.position-modal-title {
				font-size: 32rpx;
				font-weight: 600;
				color: #333333;
				text-align: center;
				padding-bottom: 30rpx;
				margin-bottom: 30rpx;
				border-bottom: 1px solid rgba(153, 153, 153, 0.25);
			}
			
			.position-options {
				.position-option {
					display: flex;
					align-items: center;
					padding: 24rpx 32rpx;
					margin-bottom: 16rpx;
					border-radius: 42rpx;
					border: 2rpx solid rgba(227, 231, 236, 1);
					
					&.active {
						background: #F0F8FF;
						border-color: #007AFF;
						
						.position-option-icon {
							background: #007AFF;
							border-color: #007AFF;
							
							.check-icon {
								color: #ffffff;
							}
						}
						
						.position-option-text {
							color: #007AFF;
							font-weight: 500;
						}
					}
					
					.position-option-icon {
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
						border: 2rpx solid #E5E5E5;
						background: #ffffff;
						display: flex;
						align-items: center;
						justify-content: center;
						margin-right: 24rpx;
						
						.check-icon {
							font-size: 24rpx;
							color: #ffffff;
							font-weight: bold;
						}
					}
					
					.position-option-text {
						font-size: 28rpx;
						color: #333333;
						flex: 1;
					}
				}
			}
		}
	}
</style>
