fix(passport): 优化邀请码接受失败的用户提示和处理

- 针对“用户不存在”、“用户创建失败”及“请先登录”提示,改为弹窗提示需登录
- 在弹窗中增加“去登录”按钮,点击后跳转到登录页面,并携带重定向token参数
- 其他错误仍使用原Toast提示方式展示错误信息
- 保留错误日志打印,便于排查异常情况
This commit is contained in:
2026-04-11 23:21:39 +08:00
parent 7d6c4ea3c6
commit 371b478e33
2 changed files with 22 additions and 2 deletions

View File

@@ -24,5 +24,5 @@
} }
] ]
}, },
"lastUpdated": 1775909724804 "lastUpdated": 1775910071224
} }

View File

@@ -171,7 +171,27 @@ const InvitePage: React.FC = () => {
}, 1500); }, 1500);
} else { } else {
console.error('接受邀请失败:', res.data.message, 'code:', res.data.code); console.error('接受邀请失败:', res.data.message, 'code:', res.data.code);
Taro.showToast({ title: res.data.message || '加入失败', icon: 'none' }); const errorMsg = res.data.message || '';
// 用户不存在,引导去登录注册
if (errorMsg.includes('用户不存在') || errorMsg.includes('用户创建失败') || errorMsg.includes('请先登录')) {
Taro.showModal({
title: '需要登录',
content: '您尚未注册,请先完成登录或注册后再加入应用',
confirmText: '去登录',
cancelText: '取消',
success: (modalRes) => {
if (modalRes.confirm) {
// 跳转到登录页面携带token参数以便登录后返回
Taro.navigateTo({
url: `/passport/login/index?redirect=${encodeURIComponent('/passport/invite/index?token=' + token)}`
});
}
}
});
} else {
Taro.showToast({ title: errorMsg || '加入失败', icon: 'none' });
}
} }
} catch (err: any) { } catch (err: any) {
console.error('接受邀请异常:', err); console.error('接受邀请异常:', err);