fix: 开发模式运行直接进门票列表,不再弹登录页
问题:全新运行(无登录态)时,列表页的登录门槛会把人弹到登录页, 本地开发每次都要手动输手机号,体验差。 改法:requireLogin 在开发模式下无登录态时静默用首个测试手机号假登录, 直接进业务页,不跳登录页;正式流程不变(公众号入口已透明登录, 登录页仅在外链冷启动等无身份场景出现)。 顺手修掉 redirect 参数的双重编码(URL 里难看的 %252F)。 已实测:清空登录态直接打开列表页,URL 停留在 scenic,列表正常渲染。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
73be4f7d73
commit
ded90fd423
+8
-2
@@ -10,11 +10,17 @@ const isLogin = () => {
|
||||
return !!uni.getStorageSync('phone')
|
||||
}
|
||||
|
||||
// xuchao: 登录校验 —— 未登录则跳登录页,登录成功后回跳 redirect 指定的页面
|
||||
// xuchao: 登录校验
|
||||
// - 开发模式:无登录态时静默用首个测试手机号假登录,不跳登录页(本地直接进业务页)
|
||||
// - 正式流程:跳登录页;登录成功后回跳 redirect 指定的页面
|
||||
const requireLogin = (redirect) => {
|
||||
if (isLogin()) return true
|
||||
if (config.devMode) {
|
||||
loginByMock(config.testPhones[0])
|
||||
return true
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/index/authorization' + (redirect ? '?redirect=' + encodeURIComponent(redirect) : '')
|
||||
url: '/pages/index/authorization' + (redirect ? '?redirect=' + redirect : '')
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
onLoad(options) {
|
||||
// xuchao: 记录登录前的页面,登录成功后回跳
|
||||
if (options.redirect) {
|
||||
this.redirect = decodeURIComponent(options.redirect)
|
||||
this.redirect = options.redirect
|
||||
}
|
||||
// xuchao: 正式流程 —— 公众号网页授权重定向回来时 URL 带 code,用它换用户信息
|
||||
if (options.code && !config.devMode) {
|
||||
|
||||
Reference in New Issue
Block a user