fix(login): noMobile 阶段后端将 openId 放 bindKey 字段返回,纳入兜底链
This commit is contained in:
parent
34a3887b2d
commit
10905df143
|
|
@ -36,8 +36,11 @@ export default function Login() {
|
||||||
const state = getLoginSubState(result)
|
const state = getLoginSubState(result)
|
||||||
if (state !== 'complete') {
|
if (state !== 'complete') {
|
||||||
console.log('[login-page] 注册未完成,推进到', state)
|
console.log('[login-page] 注册未完成,推进到', state)
|
||||||
// noMobile 响应可能不回传 openId(首次 needUserInfo 已缓存本地),从 storage 兜底
|
// openId 兜底链:noMobile 阶段后端把 openId 放在 bindKey 字段返回(联调实测);
|
||||||
const openIdNext = result.openId ?? storage.get<string>(WX_OPENID_STORAGE_KEY) ?? openId
|
// 其余阶段从本地缓存(needUserInfo 时已写入)兜底
|
||||||
|
const openIdNext =
|
||||||
|
result.openId ?? (state === 'noMobile' ? result.bindKey : undefined) ??
|
||||||
|
storage.get<string>(WX_OPENID_STORAGE_KEY) ?? openId
|
||||||
if (!openIdNext) throw new Error('响应缺少 openId,无法继续授权')
|
if (!openIdNext) throw new Error('响应缺少 openId,无法继续授权')
|
||||||
setOpenId(openIdNext)
|
setOpenId(openIdNext)
|
||||||
setSubState(state)
|
setSubState(state)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue