From c6ad4d573b43ab6e10437d8cf18171393767a18b Mon Sep 17 00:00:00 2001 From: wangxia <779219182@qq.com> Date: Mon, 30 Mar 2026 17:59:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index.vue | 76 +++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/pages/home/index.vue b/pages/home/index.vue index 0c65746..c77f32a 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -255,7 +255,7 @@ export default { that.query.page = 1; this.isLogin = uni.getStorageSync("apply-userinfo") ? true : false; this.query.size = this.isLogin ? 50 : 20; - + // 如果没有携带城市信息,则在获取完城市定位后重新触发获取城市职位 if (!sceneInfo.query.cityInfo) { uni.$on("setCity", () => { that.G.startAbort(1); @@ -263,7 +263,7 @@ export default { that.isCheckShare(() => { that.getList().then(() => { that.showNotic = "paused"; - // console.log("that.showNotic1", that.showNotic); + console.log("that.showNotic1", that.showNotic); that.getJobNum(); setTimeout(() => { if (uni.getStorageSync("miniApp-info").notice) { @@ -283,6 +283,39 @@ export default { }); } }, + onShow() { + let that = this; + that.loadSelectedCityFromCache().then(() => { + this.getList(); + }); + + // 尝试从缓存获取miniApp-info,如果不存在则请求API获取 + let miniAppInfo = uni.getStorageSync("miniApp-info"); + if (!miniAppInfo || Object.keys(miniAppInfo).length === 0) { + // 如果缓存中没有数据,则请求API获取 + this.G.Get("/yishoudan/agency/getInfo", {}, (res) => { + let obj = { ...res.agency, ...res.weixinConfig }; + for (let key in obj) { + if (typeof obj[key] == "string" && obj[key].indexOf("http://") > -1) { + obj[key] = obj[key].replace("http:", "https:"); + } + } + uni.setStorageSync("miniApp-info", obj); + this.appInfo = obj; + + uni.setStorageSync("pgy-agency-id", res.agency.id); + uni.setStorageSync("ai-name", res.agency.aiRobotName); + uni.setStorageSync("ai-logo", res.agency.aiLogo); + }); + } else { + // 如果缓存中有数据,则直接使用 + this.appInfo = miniAppInfo; + } + + // setTimeout(() => { + // that.appInfo = uni.getStorageSync("miniApp-info"); + // }, 100); + }, data() { return { hrtext: 2, @@ -420,37 +453,7 @@ export default { isshowskit: false, }; }, - onShow() { - let that = this; - that.loadSelectedCityFromCache(); - - // 尝试从缓存获取miniApp-info,如果不存在则请求API获取 - let miniAppInfo = uni.getStorageSync("miniApp-info"); - if (!miniAppInfo || Object.keys(miniAppInfo).length === 0) { - // 如果缓存中没有数据,则请求API获取 - this.G.Get("/yishoudan/agency/getInfo", {}, (res) => { - let obj = { ...res.agency, ...res.weixinConfig }; - for (let key in obj) { - if (typeof obj[key] == "string" && obj[key].indexOf("http://") > -1) { - obj[key] = obj[key].replace("http:", "https:"); - } - } - uni.setStorageSync("miniApp-info", obj); - this.appInfo = obj; - - uni.setStorageSync("pgy-agency-id", res.agency.id); - uni.setStorageSync("ai-name", res.agency.aiRobotName); - uni.setStorageSync("ai-logo", res.agency.aiLogo); - }); - } else { - // 如果缓存中有数据,则直接使用 - this.appInfo = miniAppInfo; - } - // setTimeout(() => { - // that.appInfo = uni.getStorageSync("miniApp-info"); - // }, 100); - }, onReachBottom() { let that = this; if (!uni.getStorageSync("apply-token") && that.tabInfo.active == 1) { @@ -465,10 +468,14 @@ export default { loadSelectedCityFromCache() { // 假设缓存中的键名为 'selectedCity' const cachedCity = uni.getStorageSync("selectedCity"); + console.log("this.selectedCity", this.selectedCity); + console.log("this.selectedCity", cachedCity); if (cachedCity && this.selectedCity != cachedCity) { this.selectedCity = cachedCity; - this.getList(); } + return new Promise((reso, rej) => { + reso(); + }); }, checkScroll() { let that = this; @@ -617,7 +624,7 @@ export default { } else { that.tabInfo.active = 1; } - console.log('that.tabInfo.active',that.tabInfo.active); + console.log("that.tabInfo.active", that.tabInfo.active); callback(); }); }, @@ -663,6 +670,7 @@ export default { if ($type == "initall") { _url = that.api.yi_job_list; } else { + console.log(" that.useshare", that.useshare); if (that.tabInfo.active == 1 && that.useshare) { _url = that.api.job_share; } else {