fix: SplashFragment 绑定检查时正确存入用户数据到 UserPrefs
API返回Success时解析用户信息并存入,而不是直接跳首页。 userId<=0时视为未绑定,导航到二维码页。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -84,10 +84,22 @@ class SplashFragment : Fragment() {
|
||||
|
||||
when (result) {
|
||||
is ApiResult.Success -> {
|
||||
// API 返回数据 → 已绑定
|
||||
Timber.d("Splash: API 返回已绑定")
|
||||
// TODO: 解析返回数据更新 UserPrefs(等确认实际字段后完善)
|
||||
navigateToHome()
|
||||
// API 返回数据 → 已绑定,存入 UserPrefs
|
||||
val data = result.data
|
||||
if (data != null && data.userId > 0) {
|
||||
Timber.d("Splash: API 返回已绑定 userId=${data.userId}")
|
||||
userPrefs.saveUser(
|
||||
userId = data.userId,
|
||||
mobile = data.mobile,
|
||||
userName = data.userName,
|
||||
headUrl = data.headUrl
|
||||
)
|
||||
navigateToHome()
|
||||
} else {
|
||||
// 返回数据无效,视为未绑定
|
||||
Timber.d("Splash: API 返回数据无效,视为未绑定")
|
||||
navigateToBind()
|
||||
}
|
||||
}
|
||||
is ApiResult.Error -> {
|
||||
if (result.code == 1) {
|
||||
|
||||
Reference in New Issue
Block a user