一体机和小程序样式错乱问题修复。
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
<template>
|
||||
<view v-if="show" class="filter-container">
|
||||
<!-- 头部 -->
|
||||
<view class="filter-header">
|
||||
<view class="header-title">筛选</view>
|
||||
<view class="header-close" @click="handleClose">
|
||||
<view class="close-icon"></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 主体内容 -->
|
||||
<view class="filter-body">
|
||||
<!-- 左侧标签页 -->
|
||||
<view class="filter-tabs">
|
||||
<view
|
||||
@@ -89,22 +98,22 @@
|
||||
</radio-group>
|
||||
</view>
|
||||
|
||||
<!-- 地区 -->
|
||||
<!-- 地区(多选) -->
|
||||
<view v-if="activeTab === 'area'" class="content-section">
|
||||
<radio-group @change="(e) => handleSelect('area', e)">
|
||||
<checkbox-group @change="(e) => handleCheckboxSelect('area', e)">
|
||||
<label
|
||||
v-for="option in areaOptions"
|
||||
:key="option.value"
|
||||
class="radio-item"
|
||||
:class="{ checked: selectedValues['area'] === String(option.value) }"
|
||||
:class="{ checked: isAreaSelected(String(option.value)) }"
|
||||
>
|
||||
<radio
|
||||
<checkbox
|
||||
:value="String(option.value)"
|
||||
:checked="selectedValues['area'] === String(option.value)"
|
||||
:checked="isAreaSelected(String(option.value))"
|
||||
/>
|
||||
<text class="option-label">{{ option.label }}</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
|
||||
<!-- 岗位类型 -->
|
||||
@@ -132,6 +141,7 @@
|
||||
<button class="footer-btn confirm-btn" @click="handleConfirm">确认</button>
|
||||
</view>
|
||||
</view>
|
||||
</view><!-- end filter-body -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -176,7 +186,7 @@ const selectedValues = reactive({
|
||||
experience: '',
|
||||
salary: '',
|
||||
scale: '',
|
||||
area: '',
|
||||
area: [],
|
||||
jobType: ''
|
||||
});
|
||||
|
||||
@@ -218,21 +228,60 @@ onBeforeMount(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
// 处理选项选择
|
||||
// 处理单选选项选择
|
||||
const handleSelect = (key, e) => {
|
||||
selectedValues[key] = e.detail.value;
|
||||
};
|
||||
|
||||
// 处理多选选项选择(地区)
|
||||
// 兼容不同平台:H5 可能返回逗号分隔字符串,小程序返回数组
|
||||
const handleCheckboxSelect = (key, e) => {
|
||||
let val = e.detail.value;
|
||||
if (typeof val === 'string') {
|
||||
selectedValues[key] = val ? val.split(',').map((s) => s.trim()) : [];
|
||||
} else if (Array.isArray(val)) {
|
||||
selectedValues[key] = val.map((v) => String(v));
|
||||
} else {
|
||||
selectedValues[key] = [];
|
||||
}
|
||||
};
|
||||
|
||||
// 判断地区选项是否被选中(兼容数组和字符串)
|
||||
const isAreaSelected = (value) => {
|
||||
const areaVal = selectedValues.area;
|
||||
if (Array.isArray(areaVal)) {
|
||||
return areaVal.includes(value);
|
||||
}
|
||||
if (typeof areaVal === 'string' && areaVal) {
|
||||
return areaVal.split(',').includes(value);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 清除所有选择
|
||||
const handleClear = () => {
|
||||
Object.keys(selectedValues).forEach((key) => {
|
||||
selectedValues[key] = '';
|
||||
if (key === 'area') {
|
||||
selectedValues[key] = [];
|
||||
} else {
|
||||
selectedValues[key] = '';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 确认筛选
|
||||
const handleConfirm = () => {
|
||||
const payload = { ...selectedValues };
|
||||
// 将多选的地区数组转为逗号分隔字符串(兼容各种格式)
|
||||
if (Array.isArray(payload.area) && payload.area.length > 0) {
|
||||
payload.area = payload.area.map((v) => String(v)).join(',');
|
||||
} else if (typeof payload.area === 'string' && payload.area) {
|
||||
// 如果已经是逗号分隔字符串,保持原样
|
||||
payload.area = payload.area;
|
||||
} else {
|
||||
payload.area = '';
|
||||
}
|
||||
console.log('[new-filter-page] area value to emit:', payload.area);
|
||||
// 将选中的薪资区间转换为 minSalary / maxSalary 参数
|
||||
// 始终带上 minSalary / maxSalary(含空值),便于父组件在清除时移除旧值
|
||||
let minSalary = '';
|
||||
@@ -269,22 +318,33 @@ const handleClose = () => {
|
||||
background-color: #fff;
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.filter-header {
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
justify-content: center;
|
||||
padding: 0 32rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
|
||||
.back-btn {
|
||||
font-size: 36rpx;
|
||||
.header-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.header-close {
|
||||
position: absolute;
|
||||
right: 32rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -295,15 +355,42 @@ const handleClose = () => {
|
||||
&:active {
|
||||
background-color: rgba(37, 107, 250, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.filter-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
.close-icon {
|
||||
position: relative;
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 4rpx;
|
||||
height: 28rpx;
|
||||
border-radius: 2rpx;
|
||||
background: #5A5A68;
|
||||
}
|
||||
|
||||
&::before {
|
||||
transform: translate(-50%, -50%) rotate(45deg);
|
||||
}
|
||||
|
||||
&::after {
|
||||
transform: translate(-50%, -50%) rotate(-45deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.filter-body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.filter-tabs {
|
||||
width: 200rpx;
|
||||
border-right: 1rpx solid #eee;
|
||||
|
||||
Reference in New Issue
Block a user