diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index 572c11b..0237384 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -36,8 +36,11 @@ export default function Login() { const state = getLoginSubState(result) if (state !== 'complete') { console.log('[login-page] 注册未完成,推进到', state) - // noMobile 响应可能不回传 openId(首次 needUserInfo 已缓存本地),从 storage 兜底 - const openIdNext = result.openId ?? storage.get(WX_OPENID_STORAGE_KEY) ?? openId + // openId 兜底链:noMobile 阶段后端把 openId 放在 bindKey 字段返回(联调实测); + // 其余阶段从本地缓存(needUserInfo 时已写入)兜底 + const openIdNext = + result.openId ?? (state === 'noMobile' ? result.bindKey : undefined) ?? + storage.get(WX_OPENID_STORAGE_KEY) ?? openId if (!openIdNext) throw new Error('响应缺少 openId,无法继续授权') setOpenId(openIdNext) setSubState(state)