From afcc8d12dee1ee2ba242d13cb336532693fa9468 Mon Sep 17 00:00:00 2001 From: Guoguo Date: Mon, 18 May 2026 06:04:25 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20index=20page=20=E2=80=94=20no=20loading?= =?UTF-8?q?=20flash=20on=20tab=20switch,=20subscription=20always=20tappabl?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Loading animation only shows on first visit, subsequent onShow updates silently - Subscription row always navigates to plans page (was no-op when active) - Move devMode init to onLoad (only needs to run once) --- miniprogram/pages/index/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index e2c707e..9a7ec4e 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -18,8 +18,11 @@ Page({ loading: true }, - onShow: function () { + onLoad: function () { this.setData({ devMode: config.__DEV__ || false }) + }, + + onShow: function () { this.checkState() this._onStatus = this.onBleStatus.bind(this) ble.on('status', this._onStatus) @@ -48,7 +51,8 @@ Page({ return } - self.setData({ connected: ble.isConnected(), loading: true }) + var isFirstLoad = self.data.loading + self.setData({ connected: ble.isConnected() }) var p1 = api.getDevices().then(function (data) { var devices = data.devices || [] @@ -74,7 +78,7 @@ Page({ }) Promise.all([p1, p2]).then(function () { - self.setData({ loading: false }) + if (isFirstLoad) self.setData({ loading: false }) }) }, @@ -180,8 +184,6 @@ Page({ }, onViewSubscription: function () { - if (!this.data.subscription || this.data.subscription.status !== 'active') { - wx.navigateTo({ url: '/pages/subscribe-plans/subscribe-plans' }) - } + wx.navigateTo({ url: '/pages/subscribe-plans/subscribe-plans' }) } })