diff --git a/src/api/passport/qr-login/index.ts b/src/api/passport/qr-login/index.ts index 1a52c9f..306026f 100644 --- a/src/api/passport/qr-login/index.ts +++ b/src/api/passport/qr-login/index.ts @@ -78,19 +78,36 @@ export interface ConfirmLoginParam { deviceInfo?: string; } -// 确认登录响应 +// 确认登录响应(适配后端 QrLoginStatusResponse) export interface ConfirmLoginResult { - // 是否成功 - success: boolean; - // 消息 - message: string; - // 登录用户信息 + // 状态: pending-等待扫码, scanned-已扫码, confirmed-已确认, bind_phone-待绑定手机号, expired-已过期 + status: string; + // JWT访问令牌(仅在confirmed状态时返回) + accessToken?: string; + // 用户信息 userInfo?: { userId: number; + username?: string; nickname?: string; avatar?: string; phone?: string; }; + // 剩余过期时间(秒) + expiresIn?: number; + // 租户ID + tenantId?: number; + // 是否需要绑定手机号 + needBindPhone?: boolean; + // 状态提示信息 + message?: string; + // 下一步操作:bind_phone-绑定手机号, redirect-跳转, wait-等待 + nextAction?: string; + // 跳转URL(当nextAction为redirect时使用) + redirectUrl?: string; + // 成功消息 + successMessage?: string; + // 兼容字段:如果后端返回 success + success?: boolean; } /** diff --git a/src/passport/qr-confirm/index.tsx b/src/passport/qr-confirm/index.tsx index 7bffdf5..3632df9 100644 --- a/src/passport/qr-confirm/index.tsx +++ b/src/passport/qr-confirm/index.tsx @@ -140,10 +140,13 @@ const QRConfirmPage: React.FC = () => { } }); - if (result.success) { + // 根据 status 判断成功:confirmed 表示登录成功 + const isConfirmed = result.status === 'confirmed' || result.success === true; + + if (isConfirmed) { setConfirmed(true); Taro.showToast({ - title: '登录确认成功', + title: result.successMessage || result.message || '登录确认成功', icon: 'success', duration: 2000 }); @@ -164,6 +167,15 @@ const QRConfirmPage: React.FC = () => { }); } }, 3000); + } else if (result.status === 'bind_phone' || result.needBindPhone) { + // 需要绑定手机号 + Taro.showToast({ + title: '请先绑定手机号', + icon: 'none' + }); + setTimeout(() => { + Taro.redirectTo({ url: '/passport/sms-login' }); + }, 1500); } else { setError(result.message || '登录确认失败'); }