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

@@ -253,16 +253,11 @@ export default {
},
// 打开弹窗
open(url = '', mode = 'navigateTo') {
open(url = '', mode = 'navigateTo', callback = ()=>{}) {
console.log(`------> ns-login.open`, url);
if (url) this.url = url;
// #ifdef MP-WEIXIN
this.getCode(authData => {
this.authLogin(authData, 'authOnlyLogin');
});
// #endif
// #ifdef H5
// #ifdef H5 || MP-HARMONY
if (this.$util.isWeChatMiniProgram()) {
// 微信小程序环境,使用微信授权登录
let authData = uni.getStorageSync('authInfo');
@@ -275,20 +270,26 @@ export default {
}
} else if (this.$util.isWeiXin()) {
// 微信浏览器环境,显示登录页面
this.toLogin(mode);
this.toLoginH5Page(mode);
} else {
// 其他浏览器环境,显示登录页面
this.toLogin(mode);
this.toLoginH5Page(mode);
}
return;
// #endif
// #ifndef MP-WEIXIN || H5
this.toLogin(mode);
// #ifdef MP-WEIXIN
this.getCode(authData => {
this.authLogin(authData, 'authOnlyLogin');
}, (err) => {
callback && callback(err);
});
// #endif
},
// 跳转去登录页
toLogin(mode = 'navigateTo') {
toLoginH5Page(mode = 'navigateTo') {
if (this.url) this.$util.redirectTo(this.$util.LOGIN_PAGE_URL, {
back: encodeURIComponent(this.url)
}, mode);
@@ -631,7 +632,7 @@ export default {
if (this.registerConfig.third_party == 1 && this.registerConfig.bind_mobile == 1) {
this.openCompleteInfoPop();
} else if (this.registerConfig.third_party == 0) {
this.toLogin();
this.toLoginH5Page();
} else {
this.openCompleteInfoPop();
}