From 67f5dbbfb0a4cfa1e786f3a2795a3dbf5a5df11f Mon Sep 17 00:00:00 2001 From: Apcallover <1503963513@qq.com> Date: Tue, 9 Dec 2025 11:13:32 +0800 Subject: [PATCH] =?UTF-8?q?flat:=20=E6=BC=94=E7=A4=BA=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 25 +++++++------- common/globalFunction.js | 23 +++++++++++-- .../renderCompanysOutData.vue | 23 ++++++++++++- components/renderJobs/renderJobs.vue | 33 +++++++++++++++++-- config.js | 8 +++-- index.html | 4 +-- .../pages/newJobPosition/newJobPosition.vue | 11 ++++++- packageA/pages/tiktok/tiktok.vue | 4 ++- pages/careerfair/careerfair.vue | 13 ++++++-- pages/login/login.vue | 10 +++--- pages/mine/mine.vue | 29 ++++++++++++++-- pages/search/search.vue | 14 ++++++-- 12 files changed, 161 insertions(+), 36 deletions(-) diff --git a/App.vue b/App.vue index 951d4e5..ed0e18e 100644 --- a/App.vue +++ b/App.vue @@ -4,7 +4,7 @@ import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'; import useUserStore from './stores/useUserStore'; import usePageAnimation from './hook/usePageAnimation'; import useDictStore from './stores/useDictStore'; -const { $api, navTo, appendScriptTagElement, aes_Decrypt, sm2_Decrypt } = inject('globalFunction'); +const { $api, navTo, appendScriptTagElement, aes_Decrypt, sm2_Decrypt, safeReLaunch } = inject('globalFunction'); import config from '@/config.js'; usePageAnimation(); const appword = 'aKd20dbGdFvmuwrt'; // 固定值 @@ -27,9 +27,10 @@ onLaunch((options) => { $api.msg('登录成功'); }); } else { - uni.redirectTo({ - url: '/pages/login/login', - }); + safeReLaunch('/pages/login/login'); + // uni.redirectTo({ + // url: '/pages/login/login', + // }); } } }); @@ -110,13 +111,15 @@ function loginCallback(userInfo) { .then((resume) => { if (resume.data.jobTitleId) { useUserStore().initSeesionId(); - uni.reLaunch({ - url: '/pages/index/index', - }); + // uni.reLaunch({ + // url: '/pages/index/index', + // }); + safeReLaunch('/pages/index/index'); } else { - uni.redirectTo({ - url: '/pages/login/login', - }); + safeReLaunch('/pages/login/login'); + // uni.redirectTo({ + // url: '/pages/login/login', + // }); } }); }); @@ -187,4 +190,4 @@ uni-modal, body { font-family: 'PingFangSC-Regular', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif; } - + \ No newline at end of file diff --git a/common/globalFunction.js b/common/globalFunction.js index 4ae779c..7434ea6 100644 --- a/common/globalFunction.js +++ b/common/globalFunction.js @@ -51,6 +51,23 @@ const prePage = () => { } +export function safeReLaunch(url) { + const pages = getCurrentPages(); + const currentPage = pages[pages.length - 1]; + + // 移除传入url开头的斜杠用于对比 + const cleanUrl = url.startsWith('/') ? url.slice(1) : url; + + if (currentPage && currentPage.route === cleanUrl) { + console.log('已在当前页'); + return; + } + + uni.reLaunch({ + url + }); +} + /** @@ -627,7 +644,8 @@ export const $api = { sendingMiniProgramMessage, copyText, aes_Decrypt, - createRequestWithCache + createRequestWithCache, + safeReLaunch } @@ -660,5 +678,6 @@ export default { sm4Decrypt, aes_Decrypt, sm2_Decrypt, - sm2_Encrypt + sm2_Encrypt, + safeReLaunch } \ No newline at end of file diff --git a/components/renderCompanysOutData/renderCompanysOutData.vue b/components/renderCompanysOutData/renderCompanysOutData.vue index a27cc7b..2458829 100644 --- a/components/renderCompanysOutData/renderCompanysOutData.vue +++ b/components/renderCompanysOutData/renderCompanysOutData.vue @@ -70,8 +70,29 @@ watch( () => props.list, (newList) => { if (!Array.isArray(newList)) return; + + let shouldReset = false; + + if (dataSource.value.length > newList.length) { + shouldReset = true; + } else if (dataSource.value.length > 0 && newList.length > 0) { + // 注意:这里沿用你代码中使用的 item.id 作为唯一标识 + const oldId = dataSource.value[0].id; + const newId = newList[0].id; + if (oldId !== newId) { + shouldReset = true; + } + } + + if (shouldReset) { + dataSource.value = []; + processedIds.clear(); + } + const newItems = newList.filter((item) => !processedIds.has(item.id)); + if (newItems.length === 0) return; + newItems.forEach((item) => processedIds.add(item.id)); const delay = 50; newItems.forEach((item, index) => { @@ -80,7 +101,7 @@ watch( }, index * delay); }); }, - { immediate: true } + { immediate: true, deep: true } ); function nextDetail(company) { diff --git a/components/renderJobs/renderJobs.vue b/components/renderJobs/renderJobs.vue index 57a2d60..cc5566c 100644 --- a/components/renderJobs/renderJobs.vue +++ b/components/renderJobs/renderJobs.vue @@ -82,9 +82,36 @@ watch( () => props.list, (newList) => { if (!Array.isArray(newList)) return; - const newItems = newList.filter((item) => !processedIds.has(item.id)); + + // --- 新增逻辑开始 --- + // 判断是否需要重置数据 (例如:点击了搜索、切换了Tab、或下拉刷新) + let shouldReset = false; + + // 场景1: 新列表长度比当前渲染的列表短,说明发生了重置(如从20条变成了10条) + if (dataSource.value.length > newList.length) { + shouldReset = true; + } + // 场景2: 列表不为空,且第一条数据的ID发生了变化,说明是全新的搜索结果 + else if (dataSource.value.length > 0 && newList.length > 0) { + const oldId = dataSource.value[0].id || dataSource.value[0].jobId; + const newId = newList[0].id || newList[0].jobId; + if (oldId !== newId) { + shouldReset = true; + } + } + + // 如果判定为重置,则清空现有数据和ID记录 + if (shouldReset) { + dataSource.value = []; + processedIds.clear(); + } + // --- 新增逻辑结束 --- + + const newItems = newList.filter((item) => !processedIds.has(item.id || item.jobId)); + if (newItems.length === 0) return; - newItems.forEach((item) => processedIds.add(item.id)); + + newItems.forEach((item) => processedIds.add(item.id || item.jobId)); const delay = 50; newItems.forEach((item, index) => { setTimeout(() => { @@ -92,7 +119,7 @@ watch( }, index * delay); }); }, - { immediate: true } + { immediate: true, deep: true } // 建议加上 deep,虽然这里监听的是数组引用变化 ); function nextDetail(job) { diff --git a/config.js b/config.js index e688fff..5da92a2 100644 --- a/config.js +++ b/config.js @@ -14,11 +14,13 @@ export default { // 只使用本地缓寸的数据 OnlyUseCachedDB: false, // 素质测评URL - Quality_assessment_URL: 'https://web1.isdapp.shandong.gov.cn/jmopen_files/unzip/49ee8533b31b46238906b31c27c5dfc9/zycpvhyjw/index.html#/pages/evaluation_record/evaluation_record?uuid=2', + Quality_assessment_URL: 'https://web1.isdapp.shandong.gov.cn/jmopen_files/unzip/3511c4a8b32c468489ace780d40f6d92/zycpvhyjw/index.html#/pages/evaluation_record/evaluation_record?uuid=2f19e4d676df4650b6fb7edf87461571', // 职业指导 - Career_guidance: 'https://web1.isdapp.shandong.gov.cn/jmopen_files/unzip/2626f6e3c899445db8639a873d172d73/zyzd/index.html', + Career_guidance: 'https://web1.isdapp.shandong.gov.cn/jmopen_files/unzip/927b0032dfe3405ab0124fda9282ebdd/zyzd/index.html', // ai 模拟面试 - mock_interview: 'https://web1.isdapp.shandong.gov.cn/jmopen_files/unzip/08c660be20b74e15acd8763001db5fd1/szjx-rgzn-xnsc/#/pages/mine/interview/index', + mock_interview: 'https://web1.isdapp.shandong.gov.cn/jmopen_files/unzip/4a21b3b6efec4f8db2c3d3d5fa51edc9/szjx-rgzn-xnsc/#/pages/interview/schedule', + // VR虚拟招聘会 + virtualJobFair: 'https://web1.isdapp.shandong.gov.cn/jmopen_files/unzip/4a21b3b6efec4f8db2c3d3d5fa51edc9/szjx-rgzn-xnsc/#/pages/metaverse/job_fair', // 使用模拟定位 UsingSimulatedPositioning: true, // 应用信息 diff --git a/index.html b/index.html index 0ea9071..8502753 100644 --- a/index.html +++ b/index.html @@ -22,11 +22,11 @@ --> - + diff --git a/packageA/pages/newJobPosition/newJobPosition.vue b/packageA/pages/newJobPosition/newJobPosition.vue index c6c0b2c..753ee4d 100644 --- a/packageA/pages/newJobPosition/newJobPosition.vue +++ b/packageA/pages/newJobPosition/newJobPosition.vue @@ -42,7 +42,7 @@ const { $api, navTo, debounce, customSystem } = inject('globalFunction'); import { storeToRefs } from 'pinia'; import useLocationStore from '@/stores/useLocationStore'; import useUserStore from '@/stores/useUserStore'; -const { userInfo } = storeToRefs(useUserStore()); +const { userInfo, isMiniProgram } = storeToRefs(useUserStore()); const { longitudeVal, latitudeVal } = storeToRefs(useLocationStore()); const pageState = reactive({ @@ -58,6 +58,15 @@ const state = reactive({ tabIndex: 'all', }); +onMounted(() => { + // #ifdef H5 + if (!isMiniProgram.value) { + const a = document.getElementsByClassName('uni-page-head-hd')[0]; + a.style.display = 'none'; + } + // #endif +}); + onLoad(() => { getList('refresh'); }); diff --git a/packageA/pages/tiktok/tiktok.vue b/packageA/pages/tiktok/tiktok.vue index 2b52e7e..c18798a 100644 --- a/packageA/pages/tiktok/tiktok.vue +++ b/packageA/pages/tiktok/tiktok.vue @@ -1,6 +1,6 @@