refactor: 统一使用 getUserProfile 获取用户信息并为获取失败增加错误处理

This commit is contained in:
邹方成 2026-01-04 11:01:31 +08:00
parent 762c248ab1
commit 0f7255783a
2 changed files with 8 additions and 3 deletions

View File

@ -441,7 +441,7 @@ async function onGetPhoneNumber(e) {
//
try {
const updatedUserInfo = await authRequest({ url: '/api/app/users/info', method: 'GET' })
const updatedUserInfo = await getUserProfile() // 使 api/appUser.js
if (updatedUserInfo) {
uni.setStorageSync('user_info', updatedUserInfo)
}
@ -497,7 +497,7 @@ async function onGetPhoneNumber(e) {
//
try {
const updatedUserInfo = await authRequest({ url: '/api/app/users/info', method: 'GET' })
const updatedUserInfo = await getUserProfile()
if (updatedUserInfo) {
Object.assign(data, updatedUserInfo)
uni.setStorageSync('user_info', updatedUserInfo)

View File

@ -776,7 +776,12 @@ export default {
}
try {
// 使 profile API
const profile = await getUserProfile()
let profile = null
try {
profile = await getUserProfile()
} catch (err) {
console.warn('[Mine] getUserProfile 调用失败,将尝试降级逻辑:', err)
}
if (profile) {
console.log('[Mine] 从 profile API 获取用户信息:', profile)