From c6bef45940037941ea1bd8f98d7c2464cebe12a0 Mon Sep 17 00:00:00 2001 From: ws Date: Thu, 30 Apr 2026 12:17:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=92=8C=E9=87=8D=E8=AF=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 3 ++- pages/records/records.js | 45 ++++++++++++++++++++++++++++++++++---- pages/records/records.wxml | 11 ++++++++-- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/app.json b/app.json index 5411241..75ff8c8 100644 --- a/app.json +++ b/app.json @@ -1,8 +1,9 @@ { "pages": [ + "pages/records/records", "pages/index/index", "pages/appointment/appointment", - "pages/records/records", + "pages/scan/result/index" ], "window": { diff --git a/pages/records/records.js b/pages/records/records.js index 712a6c7..2a1289e 100644 --- a/pages/records/records.js +++ b/pages/records/records.js @@ -7,20 +7,57 @@ Page({ records: [], filteredRecords: [], currentTab: 'all', - loading: true + loading: true, + isLoggedIn: false, + loginFailed: false }, onLoad() { - this.loadRecords() + if (app.globalData.isLoggedIn) { + this.onLoginReady() + } else if (app.globalData.loginFailed) { + this.onLoginFailed() + } else { + app.loginReadyCallback = (userInfo) => { + app.loginReadyCallback = null + if (userInfo) { + this.onLoginReady() + } else { + this.onLoginFailed() + } + } + } }, onShow() { - // 仅从预约页返回时刷新,避免 onLoad + onShow 双重加载 - if (this.data._loaded) { + // 已加载过且已登录时刷新(从预约页返回等场景) + if (this.data._loaded && app.globalData.isLoggedIn) { this.loadRecords() } }, + onLoginReady() { + this.setData({ isLoggedIn: true, loginFailed: false }) + this.loadRecords() + }, + + onLoginFailed() { + this.setData({ isLoggedIn: false, loginFailed: true, loading: false }) + }, + + onRetry() { + this.setData({ loginFailed: false, loading: true }) + app.silentLogin() + app.loginReadyCallback = (userInfo) => { + app.loginReadyCallback = null + if (userInfo) { + this.onLoginReady() + } else { + this.onLoginFailed() + } + } + }, + async loadRecords() { this.setData({ loading: true }) try { diff --git a/pages/records/records.wxml b/pages/records/records.wxml index 80c8cb9..780e029 100644 --- a/pages/records/records.wxml +++ b/pages/records/records.wxml @@ -20,7 +20,7 @@ - + @@ -70,8 +70,15 @@ 加载中... + + + ⚠️ + 登录失败,请重试 + 重新登录 + + - + 📭 暂无预约记录 去预约