From f75d6075769aea17c77e81f79626bfbf74174d61 Mon Sep 17 00:00:00 2001 From: xiebing Date: Tue, 23 Dec 2025 17:08:20 +0800 Subject: [PATCH] =?UTF-8?q?feat=20:=20=E6=96=B0=E5=A2=9E=20=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E5=B2=97=E4=BD=8D=E7=A1=AE=E8=AE=A4=E5=90=8E,?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E6=89=A7=E8=A1=8C=E6=9F=A5=E8=AF=A2=E5=92=8C?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/components/index-refactor.vue | 61 +++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/pages/index/components/index-refactor.vue b/pages/index/components/index-refactor.vue index 9bd0d5e..cffebc6 100644 --- a/pages/index/components/index-refactor.vue +++ b/pages/index/components/index-refactor.vue @@ -534,6 +534,67 @@ function findJob(job) { conditionSearch.value[nameAttr] = val; } } + if (state.tabIndex === 'all') { + // 调用推荐接口 + getJobRecommendWithNewSearch(job.index); + } else { + // 调用普通列表接口 + getJobListWithNewSearch(job.index); + } + } +} +// 立即查询新的数据替换现有数据 +function getJobRecommendWithNewSearch(index) { + const params = { + pageSize: pageState.pageSize, + sessionId: useUserStore().seesionId, + ...pageState.search, + ...conditionSearch.value, + }; + + $api.createRequest('/app/job/recommend', params).then((resData) => { + const { data } = resData; + const newData = dataToImg(data); + //替换点击项以后的数据 + list.value.splice(index, list.value?.length - 1, newData) + // 更新加载状态 + updateLoadmoreStatus(newData); + }); +} + +// 立即查询新的数据替换现有数据 +function getJobListWithPreservedData(preservedData) { + // 重置分页参数 + pageState.page = 1; + pageState.maxPage = 2; + + const params = { + current: pageState.page, + pageSize: pageState.pageSize, + ...pageState.search, + ...conditionSearch.value, + }; + + $api.createRequest('/app/job/list', params).then((resData) => { + const { rows, total } = resData; + // 将新数据转换为图片格式 + const newData = dataToImg(rows); + //替换点击项以后的数据 + list.value.splice(index, list.value?.length - 1, newData) + // 更新分页和加载状态 + pageState.total = total; + pageState.maxPage = Math.ceil(total / pageState.pageSize); + updateLoadmoreStatus(newData); + }); +} + +function updateLoadmoreStatus(newData) { + if (loadmoreRef.value && typeof loadmoreRef.value.change === 'function') { + if (newData.length < pageState.pageSize) { + loadmoreRef.value.change('noMore'); + } else { + loadmoreRef.value.change('more'); + } } }