From 745e0078e696783c940ca6abd036449754eb25db Mon Sep 17 00:00:00 2001 From: SwTt29 <2055018491@qq.com> Date: Thu, 25 Dec 2025 10:07:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B5=E9=9D=A2=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E6=97=B6=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E5=9C=B0=E5=9D=80=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/profile/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pages/profile/index.js b/pages/profile/index.js index 8ec9eae..ce4b0d8 100644 --- a/pages/profile/index.js +++ b/pages/profile/index.js @@ -11,11 +11,13 @@ Page({ onLoad() { this.loadUserInfo(); + this.loadLocationInfo(); this.checkLocationAuth(); }, onShow() { this.loadUserInfo(); + this.loadLocationInfo(); this.checkLocationAuth(); // 更新自定义tabBar状态 if (typeof this.getTabBar === 'function' && this.getTabBar()) { @@ -28,6 +30,27 @@ Page({ app.updateCurrentTab('profile'); }, + // 加载位置信息 + loadLocationInfo() { + // 首先从本地存储获取保存的地址信息 + const savedAddress = wx.getStorageSync('locationInfo'); + if (savedAddress) { + this.setData({ locationInfo: savedAddress }); + console.log('从本地存储加载地址信息:', savedAddress); + return; + } + + // 如果本地没有,检查是否有经纬度信息可以进行逆地理编码 + const savedLocation = wx.getStorageSync('userLocation'); + if (savedLocation && savedLocation.latitude && savedLocation.longitude) { + console.log('从本地存储加载经纬度信息:', savedLocation); + this.reverseGeocode(savedLocation.latitude, savedLocation.longitude); + return; + } + + console.log('没有保存的位置信息'); + }, + // 加载用户信息 loadUserInfo() { console.log('开始加载用户信息')