refactor(member pages): unify onShow login redirect logic

1. extract common onShow login check to dedicated method redirectTologinOnShowLifecycle
2. add fallback callback for login failure to navigate back on wechat mini program
3. update all page login redirect calls to use the new unified method
4. add debug logs for redirect and auth flow tracing
This commit is contained in:
2026-06-27 18:25:53 +08:00
parent 0b760e41a3
commit 2e535b9d93
19 changed files with 69 additions and 36 deletions

View File

@@ -8,9 +8,11 @@ export default {
/**
* 获取用户登录凭证code
*/
getCode(callback) {
getCode(callback, fallbackFunc) {
console.log(`-----> auth.js getCode`)
// 微信小程序
// #ifdef MP-WEIXIN
console.log(`微信小程序登录`)
uni.login({
provider: 'weixin',
timeout: 3000,
@@ -29,12 +31,15 @@ export default {
.unionid;
typeof callback == 'function' && callback(this.authInfo);
} else {
fallbackFunc && fallbackFunc(res);
this.$util.showToast({
title: res.message ? res.message : '小程序配置错误'
});
}
}
})
} else {
fallbackFunc && fallbackFunc(res);
}
},
fail: (res) => {
@@ -46,6 +51,7 @@ export default {
});
}
// #endif
fallbackFunc && fallbackFunc(res);
}
})
// #endif
@@ -66,6 +72,7 @@ export default {
.user_id;
typeof callback == 'function' && callback(this.authInfo);
} else {
fallbackFunc && fallbackFunc(res);
this.$util.showToast({
title: res.message ? res.message : '小程序配置错误'
});
@@ -94,6 +101,9 @@ export default {
if (res.code >= 0) {
location.href = res.data;
}
},
fail: err => {
fallbackFunc && fallbackFunc(err);
}
});
}