From 57e3227af0ead826ed726b15cd0869b848a87ba2 Mon Sep 17 00:00:00 2001 From: richarjiang Date: Fri, 10 Apr 2026 09:04:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(app):=20=E7=A7=BB=E9=99=A4=E5=B7=B2?= =?UTF-8?q?=E5=BA=9F=E5=BC=83=E7=9A=84=20uni.getUserProfile=20=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=BF=AE=E5=A4=8D=E9=A6=96=E6=AC=A1=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit uni.getUserProfile 在微信基础库 2.27.1+ 已被移除,调用时抛出 TypeError 导致整个登录流程中断。新用户昵称由后端默认生成,用户可在资料页修改。 Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/app/src/utils/auth.ts | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/packages/app/src/utils/auth.ts b/packages/app/src/utils/auth.ts index 2acc6ae..a02b692 100644 --- a/packages/app/src/utils/auth.ts +++ b/packages/app/src/utils/auth.ts @@ -14,29 +14,11 @@ export async function wxLogin(): Promise { provider: 'weixin', success: async (loginRes) => { try { - // Step 2: 获取用户微信头像和昵称 - let nickname: string | undefined - let avatarUrl: string | undefined - await new Promise((res) => { - uni.getUserProfile({ - desc: '用于完善个人资料', - success: (profileRes) => { - nickname = profileRes.userInfo.nickName - avatarUrl = profileRes.userInfo.avatarUrl - res() - }, - fail: () => { - // 用户拒绝授权,仍可继续登录 - res() - }, - }) - }) - - // Step 3: 发送登录请求 + // Step 2: 发送登录请求 + // 注:uni.getUserProfile 已被微信废弃(基础库 2.27.1+), + // 新用户的昵称/头像由后端生成默认值,用户可在个人资料页修改 const result = await post('/auth/login', { code: loginRes.code, - nickname, - avatarUrl, }) uni.setStorageSync('token', result.token) resolve(result)