From 178f5c87b4cd17cbc73aaaa64dabf7bda4783650 Mon Sep 17 00:00:00 2001
From: gonghaoxing <478185430@qq.com>
Date: Wed, 29 Oct 2025 10:26:18 +0800
Subject: [PATCH] =?UTF-8?q?'=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E5=92=8C=E5=8E=BB=E9=99=A4=E8=AE=A2=E5=8D=95=E6=94=AF?=
=?UTF-8?q?=E4=BB=98=E6=96=B9=E5=BC=8F=E6=98=BE=E7=A4=BA'?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/App.vue | 37 +++++++++++---------------
frontend/pages/order/detail.vue | 4 +--
frontend/pages/public/setting.vue | 44 ++++---------------------------
3 files changed, 23 insertions(+), 62 deletions(-)
diff --git a/frontend/App.vue b/frontend/App.vue
index 9cfc9a6..91911f0 100644
--- a/frontend/App.vue
+++ b/frontend/App.vue
@@ -129,9 +129,9 @@
*
* 逻辑:
* 1. 解析URL参数获取ccbParamSJ
- * 2. 与本地存储的lastCcbParamSJ比较
- * 3. 如果一致则无需重新登录
- * 4. 如果不一致则需要切换用户(退出当前用户后重新登录)
+ * 2. 检查上次登录时间
+ * 3. 如果在3小时内则跳过登录
+ * 4. 超过3小时则重新登录并更新时间戳
*/
const checkCCBLogin = () => {
// #ifdef H5
@@ -159,24 +159,23 @@
}
}
- // 获取上次保存的ccbParamSJ
- const lastCcbParamSJ = uni.getStorageSync('lastCcbParamSJ') || null;
-
- // 判断参数是否变化
- const isParamChanged = ccbParamSJ && lastCcbParamSJ !== ccbParamSJ;
- const isFirstTime = ccbParamSJ && !lastCcbParamSJ;
-
// 如果有建行参数(固定建行生活环境,只要有ccbParamSJ就执行登录)
if (ccbParamSJ) {
- // 如果参数未变化,无需重新登录
- if (!isParamChanged && !isFirstTime) {
- console.log('[CCB] 参数未变化,跳过登录');
+ // 获取上次登录时间
+ const lastLoginTime = uni.getStorageSync('lastCcbLoginTime') || 0;
+ const currentTime = Date.now();
+ const threeHoursInMs = 3 * 60 * 60 * 1000; // 3小时的毫秒数
+
+ // 检查是否在3小时内
+ if (lastLoginTime && currentTime - lastLoginTime < threeHoursInMs) {
+ const remainingMinutes = Math.ceil((threeHoursInMs - (currentTime - lastLoginTime)) / 1000 / 60);
+ console.log(`[CCB] 距离上次登录未满3小时(剩余${remainingMinutes}分钟),跳过登录`);
const cleanUrl = window.location.origin + '/pages/index/index';
window.history.replaceState({}, '', cleanUrl);
return;
}
- console.log(`[CCB] ${isParamChanged ? '切换用户' : '首次登录'}`);
+ console.log(`[CCB] ${lastLoginTime ? '超过3小时,重新登录' : '首次登录'}`);
// 防止重复调用
if (isLoggingIn) {
@@ -189,13 +188,8 @@
// 延迟执行登录,确保依赖已初始化
setTimeout(async () => {
try {
- // 如果是切换用户,先退出当前用户
+ // 直接覆盖登录,无需退出(建行生活场景)
const userStore = sheep.$store('user');
- if (isParamChanged && userStore && userStore.isLogin) {
- await userStore.logout();
- uni.removeStorageSync('token');
- uni.removeStorageSync('userInfo');
- }
// 调用建行登录API(静默登录,不显示loading)
const result = await sheep.$api.third.ccbLogin({
@@ -224,7 +218,8 @@
// 保存到本地存储
uni.setStorageSync('userInfo', result.data.user_info);
- uni.setStorageSync('lastCcbParamSJ', ccbParamSJ);
+ // 保存登录时间戳
+ uni.setStorageSync('lastCcbLoginTime', Date.now());
// 设置token(这会触发loginAfter异步加载完整数据)
// 注意:不使用await,让它在后台加载,不阻塞UI
diff --git a/frontend/pages/order/detail.vue b/frontend/pages/order/detail.vue
index c658a59..d2b4042 100644
--- a/frontend/pages/order/detail.vue
+++ b/frontend/pages/order/detail.vue
@@ -165,10 +165,10 @@
支付时间:
{{ state.orderInfo.paid_time || '-' }}
-
+
diff --git a/frontend/pages/public/setting.vue b/frontend/pages/public/setting.vue
index a1dc0de..6071432 100644
--- a/frontend/pages/public/setting.vue
+++ b/frontend/pages/public/setting.vue
@@ -93,31 +93,16 @@
{{ appInfo.copyright }}
{{ appInfo.copytime }}
-
-
-
-
-
-