refactor: 统一使用 getUserProfile 获取用户信息并为获取失败增加错误处理
This commit is contained in:
parent
762c248ab1
commit
0f7255783a
@ -441,7 +441,7 @@ async function onGetPhoneNumber(e) {
|
|||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
try {
|
try {
|
||||||
const updatedUserInfo = await authRequest({ url: '/api/app/users/info', method: 'GET' })
|
const updatedUserInfo = await getUserProfile() // 使用 api/appUser.js 中的函数
|
||||||
if (updatedUserInfo) {
|
if (updatedUserInfo) {
|
||||||
uni.setStorageSync('user_info', updatedUserInfo)
|
uni.setStorageSync('user_info', updatedUserInfo)
|
||||||
}
|
}
|
||||||
@ -497,7 +497,7 @@ async function onGetPhoneNumber(e) {
|
|||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
try {
|
try {
|
||||||
const updatedUserInfo = await authRequest({ url: '/api/app/users/info', method: 'GET' })
|
const updatedUserInfo = await getUserProfile()
|
||||||
if (updatedUserInfo) {
|
if (updatedUserInfo) {
|
||||||
Object.assign(data, updatedUserInfo)
|
Object.assign(data, updatedUserInfo)
|
||||||
uni.setStorageSync('user_info', updatedUserInfo)
|
uni.setStorageSync('user_info', updatedUserInfo)
|
||||||
|
|||||||
@ -776,7 +776,12 @@ export default {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 优先使用新的 profile API
|
// 优先使用新的 profile API
|
||||||
const profile = await getUserProfile()
|
let profile = null
|
||||||
|
try {
|
||||||
|
profile = await getUserProfile()
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[Mine] getUserProfile 调用失败,将尝试降级逻辑:', err)
|
||||||
|
}
|
||||||
|
|
||||||
if (profile) {
|
if (profile) {
|
||||||
console.log('[Mine] 从 profile API 获取用户信息:', profile)
|
console.log('[Mine] 从 profile API 获取用户信息:', profile)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user