fix(passport): 解决扫码登录手机号绑定逻辑问题
- 增加用户是否绑定手机号的判断逻辑 - 未绑定手机号时展示授权界面,避免直接登录 - 已绑定手机号时继续确认登录流程 - 优化用户信息保存时机和条件 - 调整控制台日志输出,明确用户状态反馈
This commit is contained in:
@@ -13,5 +13,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"lastUpdated": 1775584636978
|
"lastUpdated": 1775585206027
|
||||||
}
|
}
|
||||||
@@ -137,13 +137,25 @@ const QRConfirmPage: React.FC = () => {
|
|||||||
console.log('[QRConfirm] loginByOpenId 结果:', wxLoginResult);
|
console.log('[QRConfirm] loginByOpenId 结果:', wxLoginResult);
|
||||||
|
|
||||||
// 3. 判断用户是否存在
|
// 3. 判断用户是否存在
|
||||||
if (wxLoginResult.success && wxLoginResult.data) {
|
if (wxLoginResult.success && wxLoginResult.data && wxLoginResult.data.user) {
|
||||||
// 用户已注册,保存用户信息并继续确认登录
|
// 用户已注册,检查是否绑定手机号
|
||||||
console.log('[QRConfirm] 用户已注册,开始确认登录...');
|
const user = wxLoginResult.data.user;
|
||||||
setUserInfo(wxLoginResult.data.user);
|
console.log('[QRConfirm] 用户已注册:', user);
|
||||||
|
|
||||||
|
// 如果用户没有手机号,需要授权绑定
|
||||||
|
if (!user.phone || user.phone === '') {
|
||||||
|
console.log('[QRConfirm] 用户未绑定手机号,显示授权界面');
|
||||||
|
setNeedAuth(true);
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户已绑定手机号,保存用户信息并继续确认登录
|
||||||
|
console.log('[QRConfirm] 用户已绑定手机号,开始确认登录...');
|
||||||
|
setUserInfo(user);
|
||||||
|
|
||||||
// 调用确认登录
|
// 调用确认登录
|
||||||
await handleConfirmLogin(loginToken, wxLoginResult.data.user);
|
await handleConfirmLogin(loginToken, user);
|
||||||
} else {
|
} else {
|
||||||
// 用户未注册,显示手机号授权界面
|
// 用户未注册,显示手机号授权界面
|
||||||
console.log('[QRConfirm] 用户未注册,显示手机号授权界面');
|
console.log('[QRConfirm] 用户未注册,显示手机号授权界面');
|
||||||
|
|||||||
Reference in New Issue
Block a user