From f46786f11c5c08ead7501a82e5a71430ad69b782 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期日, 27 四月 2025 17:39:24 +0800 Subject: [PATCH] 修复线索问题定位错误问题 --- pages/home/supervision-proxy.js | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 39 insertions(+), 16 deletions(-) diff --git a/pages/home/supervision-proxy.js b/pages/home/supervision-proxy.js index ba39bdc..24823c8 100644 --- a/pages/home/supervision-proxy.js +++ b/pages/home/supervision-proxy.js @@ -13,6 +13,8 @@ riskRes: [], creditPeriod: '', creditRes: [], + // 鍙栨秷缃戠粶璇锋眰鏍囧織 + cancelFetch: [], }, lifetimes: { attached: function () {}, @@ -22,33 +24,53 @@ * 绾夸笂鐩戠缁熻淇℃伅 */ fetchSupervision(page) { + const { provinceName, cityName, districtName, townName, sceneTypeValue } = this.data; + const params = { provinceName, cityName, districtName, townName, sceneTypes: sceneTypeValue }; + this._fetchSupervision(page, params); + }, + + _fetchSupervision(page, params) { + // 鍙栨秷姝e湪杩涜涓殑涓婁竴娆¤姹� + let { cancelFetch } = this.data; + if (cancelFetch.length > 0) { + cancelFetch[0] = true; + cancelFetch = []; + } + let abort = false; + cancelFetch.push(abort); + this.setData({ cancelFetch }); this.setData({ supervisionLoading: true }); // 浼佷笟鏁伴噺 - const { provinceName, cityName, districtName, townName, sceneTypeValue } = this.data; const f1 = fetchEnterpriseCount({ - data: { provinceName, cityName, districtName, townName, sceneTypes: sceneTypeValue }, + data: params, }).then(res => { - this.setData({ - enterpriseCountRes: res.data, - }); + if (!abort) { + this.setData({ + enterpriseCountRes: res.data, + }); + } }); // 缁煎悎椋庨櫓 const f2 = fetchRiskCount({ - data: { provinceName, cityName, districtName, townName, sceneTypes: sceneTypeValue }, + data: params, }).then(res => { - this.setData({ - riskPeriod: res.data.period, - riskRes: res.data.count, - }); + if (!abort) { + this.setData({ + riskPeriod: res.data.period, + riskRes: res.data.count, + }); + } }); // 鐜俊鐮� const f3 = fetchCreditCodeCount({ - data: { provinceName, cityName, districtName, townName, sceneTypes: sceneTypeValue }, + data: params, }).then(res => { - this.setData({ - creditPeriod: res.data.period, - creditRes: res.data.count, - }); + if (!abort) { + this.setData({ + creditPeriod: res.data.period, + creditRes: res.data.count, + }); + } }); Promise.all([f1, f2, f3]).finally(() => { @@ -87,7 +109,8 @@ }, _navParams() { - const { provinceName, cityName, districtName, townName, sceneTypeValue, locationValue } = this.data; + const { provinceName, cityName, districtName, townName, sceneTypeValue, locationValue } = + this.data; let url = `?sceneType=${sceneTypeValue[0]}`; if (provinceName) url += `&province=${provinceName}`; if (cityName) url += `&city=${cityName}`; -- Gitblit v1.9.3