flat: bug修复

This commit is contained in:
Apcallover
2025-12-25 12:52:54 +08:00
parent ef669f23be
commit 8280cc9fae
5 changed files with 305 additions and 55 deletions

View File

@@ -1,6 +1,6 @@
<template>
<view class="container">
<view v-show="searchFocus" class="search-mask" ></view>
<view v-show="searchFocus" class="search-mask"></view>
<view>
<view class="top">
<image
@@ -12,15 +12,15 @@
<view class="search-box">
<!-- 修改为左右布局的切换按钮 -->
<view class="search-type-tabs">
<view
class="type-tab button-click"
<view
class="type-tab button-click"
:class="{ active: searchType === 'job' }"
@click="setSearchType('job')"
>
职位
</view>
<view
class="type-tab button-click"
<view
class="type-tab button-click"
:class="{ active: searchType === 'major' }"
@click="setSearchType('major')"
>
@@ -40,8 +40,12 @@
@confirm="searchBtn"
/>
<!-- 联想搜索下拉列表 -->
<scroll-view scroll-y class="search-suggestions" v-show="showSuggestions && filteredSuggestions.length">
<view
<scroll-view
scroll-y
class="search-suggestions"
v-show="showSuggestions && filteredSuggestions.length"
>
<view
class="suggestion-item"
v-for="(item, index) in filteredSuggestions"
:key="index"
@@ -144,13 +148,10 @@ const filteredSuggestions = computed(() => {
const searchText = searchValue.value.toLowerCase();
try {
return majorDataSource.value.filter(item =>
item.toLowerCase().includes(searchText)
);
return majorDataSource.value.filter((item) => item.toLowerCase().includes(searchText));
} catch (error) {
return []
return [];
}
});
const pageState = reactive({
@@ -207,48 +208,50 @@ const { columnCount, columnSpace } = useColumnCount(() => {
});
onLoad((options) => {
if(options.keyWord){
searchValue.value = decodeURIComponent(options.keyWord)
searchBtn()
if (options.keyWord) {
searchValue.value = decodeURIComponent(options.keyWord);
searchBtn();
}
let arr = uni.getStorageSync('searchList');
if (arr) {
historyList.value = uni.getStorageSync('searchList');
}
getMajorDataSource()
getMajorDataSource();
});
function getMajorDataSource() {
const LoadCache = (resData) => {
if (resData.code === 200) {
majorDataSource.value = resData.data;
console.log(majorDataSource.value)
console.log(majorDataSource.value);
}
};
$api.createRequestWithCache('/app/common/majorManagement/getMajorList', {}, 'GET', false, LoadCache).then(LoadCache);
$api.createRequestWithCache('/app/common/majorManagement/getMajorList', {}, 'GET', false, LoadCache).then(
LoadCache
);
}
// 设置搜索类型并触发搜索
function setSearchType(type) {
if (searchType.value === type) return;
searchType.value = type;
// 如果输入框有值且当前是专业搜索,显示联想列表
if (searchValue.value && searchType.value === 'major' && searchFocus.value) {
showSuggestions.value = true;
} else {
showSuggestions.value = false;
}
// 如果有搜索值,触发搜索
if (searchValue.value) {
// 重置页码
pageState.page = 0;
// 触发搜索
playTextDirectly('正在为您查找岗位')
playTextDirectly('正在为您查找岗位');
// 根据搜索类型设置不同的参数
if (searchType.value === 'job') {
searchParams.value = {
@@ -259,14 +262,14 @@ function setSearchType(type) {
majorTitle: searchValue.value,
};
}
if (currentTab.value === 0) {
getJobList('refresh');
} else {
refresh();
waterfallsFlowRef.value?.refresh?.();
}
// 隐藏联想列表
showSuggestions.value = false;
}
@@ -295,7 +298,7 @@ function searchFn(item) {
function handleInputChange(e) {
const val = e.detail.value;
searchValue.value = val;
// 如果是专业搜索且输入框有值,显示联想列表
if (searchType.value === 'major' && val && searchFocus.value) {
showSuggestions.value = true;
@@ -332,13 +335,13 @@ function searchBtn() {
if (!searchValue.value) {
return;
}
playTextDirectly('正在为您查找岗位')
playTextDirectly('正在为您查找岗位');
// 保存到历史记录(仅当搜索成功时保存)
historyList.value.unshift(searchValue.value);
historyList.value = unique(historyList.value);
uni.setStorageSync('searchList', historyList.value);
// 根据搜索类型设置不同的参数
if (searchType.value === 'job') {
// 职位搜索
@@ -351,17 +354,17 @@ function searchBtn() {
majorTitle: searchValue.value,
};
}
// 重置页码
pageState.page = 0;
if (currentTab.value === 0) {
getJobList('refresh');
} else {
refresh();
waterfallsFlowRef.value?.refresh?.();
}
// 隐藏联想列表
showSuggestions.value = false;
}
@@ -414,14 +417,14 @@ function getJobList(type = 'add') {
pageState.page = 1;
pageState.maxPage = 2;
}
// 根据搜索类型构建参数
let params = {
current: pageState.page,
pageSize: pageState.pageSize,
...pageState.search,
};
// 移除之前的搜索参数,根据当前搜索类型添加
if (searchType.value === 'job') {
params.jobTitle = searchValue.value;
@@ -443,6 +446,16 @@ function getJobList(type = 'add') {
listCom.value = [...listCom.value, ...reslist];
} else {
listCom.value = [...rows];
// 一体机语音提示
if (searchType.value === 'major') {
if (rows.length) {
$api.msg('为您找到相关专业的职位');
playTextDirectly(`为您找到相关专业的职位`);
} else {
$api.msg('未找到相关专业的职位,请尝试其他关键词');
playTextDirectly(`未找到相关专业的职位,请尝试其他关键词`);
}
}
}
pageState.total = resData.total;
pageState.maxPage = Math.ceil(pageState.total / pageState.pageSize);
@@ -589,13 +602,13 @@ function dataToImg(data) {
font-weight: 400;
line-height: 36rpx;
color: #666666;
padding: 0 30rpx 0 230rpx;
padding: 0 30rpx 0 230rpx;
box-sizing: border-box;
height: 80rpx;
background: #F5F5F5;
border-radius: 73rpx;
}
.search-suggestions {
position: absolute;
top: 105%;
@@ -614,18 +627,18 @@ function dataToImg(data) {
align-items: center;
justify-items: flex-start;
border-top: 2rpx dashed #e3e3e3;
.item-txt {
font-size: 28rpx;
color: #333333;
width: 100%;
}
}
.suggestion-item:hover {
background: #e5e5e5;
}
.suggestion-item:first-child {
border-top: none;
}