<template>
	<view class="recruitment-card">
		<!-- 卡片头部信息 -->
		<view class="card-head">
			<div class="factory-info">
				<h3 class="factory-name">{{dataSource.factoryName || '默认工厂'}}</h3>
				<span class="factory-type">{{dataSource.factoryType || '电子厂'}}</span>
			</div>
			<div class="card-actions">
				<!-- <view class="favorite-btn" @click="toggleFavorite">
					<text class="heart-icon">{{isFavorite ? '♥' : '♡'}}</text>
				</view> -->
				<button class="call-btn" @click="makeCall">拨打电话</button>
				<button class="review-btn" @click.stop="handleGoToDetail">查看详情</button>
				<view class="more-btn" @click.stop>
					<text>···</text>
				</view>
			</div>
		</view>
		
		<!-- 工作时间和内容 -->
		<view class="work-info">
			<text class="work-time">{{dataSource.workTime || '8:00-20:00'}}</text>
			<text class="work-type">{{dataSource.workType || '两班倒'}}</text>
			<text class="work-content">{{dataSource.workContent || '主营汽车线束'}}</text>
			<span class="distance">{{dataSource.distance || '距你2.5km'}}</span>
		</view>

		<view class="card-bm">
			<template v-for="(item, index) in processedCompanyData" :key="item.label">
				<view class="item-info-swiper">
					<view class="label">{{item.label}}</view>
					<view class="value">
						{{item.value}}<text class="label-two">{{item.unit}}</text>
					</view>
					<view class="label-two">
						{{item.exLabel}}
					</view>
				</view>
				<view v-if="index < processedCompanyData.length - 1" class="divider"></view>
			</template>

		</view>
	</view>
</template>

<script>
	export default {
		name: "recruitment",
		props: {
			dataSource: {
				type: Object,
				default: () => ({})
			}
		},
		data() {
			return {
				isFavorite: false,
				companyData: [{
						label: '薪资',
						value: '20',
						unit: '',
						exLabel: '元/小时'
					},
					{
						label: '年龄',
						value: '20-42',
						unit: '',
						exLabel: '元/小时'
					},
					{
						label: '吃饭',
						value: '2',
						unit: '餐',
						exLabel: '白-夜'
					},
					{
						label: '住宿',
						value: '20',
						unit: '',
						exLabel: '人间'
					},
				],

			};
		},
		computed: {
			processedCompanyData() {
				return this.dataSource.companyData || this.companyData;
			}
		},
		methods: {
			// 拨打电话
			makeCall(e) {
				e.stopPropagation();
				uni.makePhoneCall({
					phoneNumber: '400-123-4567'
				});
			},
			// 切换收藏状态
			toggleFavorite(e) {
				e.stopPropagation();
				this.isFavorite = !this.isFavorite;
			},
			handleGoToDetail(e) {
				uni.navigateTo({
					url: '/pages/positionDetail/positionDetail'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.recruitment-card {
		background-color: #fff;
		padding: 8px 16px;
		z-index: 10;
		
		.card-head {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 8px;
			flex-wrap: wrap;
			.factory-info {
				width: 100%;
				display: flex;
				align-items: center;
				gap: 8px;
				margin-bottom: 8px;
				.factory-name {
					font-size: 18px;
					font-weight: 700;
					color: #333;
					margin: 0;
				}
				
				.factory-type {
					background-color: #f0f0f0;
					color: #666;
					padding: 2px 8px;
					border-radius: 4px;
					font-size: 12px;
				}
				
				.distance {
					color: #999;
					font-size: 12px;
				}
			}
			
			.card-actions {
				display: flex;
				align-items: center;
				gap: 8px;
				
				.favorite-btn {
					font-size: 20px;
					color: #ff4757;
					padding: 4px;
					cursor: pointer;
				}
				
				.call-btn {
					background-color: #ff4757;
					color: white;
					border: none;
					padding: 6px 12px;
					border-radius: 4px;
					font-size: 14px;
					line-height: 1.4;
				}
				
				.review-btn {
					background-color: transparent;
					color: #666;
					border: 1px solid #ddd;
					padding: 6px 12px;
					border-radius: 4px;
					font-size: 14px;
					line-height: 1.4;
				}
				
				.more-btn {
					color: #999;
					font-size: 18px;
					cursor: pointer;
					padding: 4px;
				}
			}
		}
		
		.work-info {
			display: flex;
			gap: 12px;
			font-size: 12px;
			color: #666;
			margin-bottom: 12px;
		}
		
		.card-bm {
			display: flex;
			padding: 0;
			justify-content: space-around;
			
			.item-wrapper {
				display: flex;
				align-items: center;
				flex: 1;
			}
			
			.item-info-swiper {
				padding: 0;
				display: inline-block;
				text-align: center;
				flex: 1;
				
				.label {
					font-weight: 700;
					font-size: 14px;
					color: #333;
				}
				
				.value {
					font-size: 24px;
					margin-top: 4px;
					margin-bottom: 4px;
					color: $uni-color-primary;
				}
				
				.label-two {
					font-size: 12px;
					color: #666;
				}
			}
			
			.divider {
				width: 1px;
				height: 60px;
				background-color: #e5e5e5;
				margin: 0;
			}
		}
	}
</style>