From 4ac98a30fb71e2ee57983f2909ed95360749bfea Mon Sep 17 00:00:00 2001 From: jacobxu666 Date: Wed, 2 Sep 2026 22:43:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=98=E6=89=A3=E9=A1=B5=E6=97=A0?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E7=BC=93=E5=AD=98=E6=97=B6=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=9A=E4=BD=8D=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E5=95=86=E9=93=BA=E8=B7=9D=E7=A6=BB=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/discount/discount.vue | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pages/discount/discount.vue b/pages/discount/discount.vue index 3b2d182..7f57d56 100644 --- a/pages/discount/discount.vue +++ b/pages/discount/discount.vue @@ -56,14 +56,21 @@ export default { } }, onLoad() { - const loc = uni.getStorageSync('lng') && uni.getStorageSync('lat') - ? { lng: uni.getStorageSync('lng'), lat: uni.getStorageSync('lat') } - : null - if (loc) { - this.lng = loc.lng - this.lat = loc.lat + const hasLoc = uni.getStorageSync('lng') && uni.getStorageSync('lat') + if (hasLoc) { + this.lng = uni.getStorageSync('lng') + this.lat = uni.getStorageSync('lat') + this.loadList() + } else { + // xuchao: 定位仅在首页触发过,直接进本页无缓存时主动获取一次,保证距离列可展示 + import('@/common/location.js').then(module => module.default.getLocation()) + .then(({ lng, lat }) => { + this.lng = lng + this.lat = lat + }) + .catch(() => {}) + .finally(() => this.loadList()) } - this.loadList() }, methods: { loadList() {