限制非代理/企业用户登录
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 1m1s

This commit is contained in:
sexygoat
2026-04-02 14:25:03 +08:00
parent 2c6011bd4a
commit 0d0b5ec14a
2 changed files with 28 additions and 18 deletions

View File

@@ -119,6 +119,26 @@ async function submit() {
// 调试日志:查看用户信息
console.log('登录成功,用户信息:', res.user);
// 验证用户类型 (只允许 3=代理 和 4=企业 登录)
if (res.user.user_type !== 3 && res.user.user_type !== 4) {
const typeNames: Record<number, string> = {
1: '超级管理员',
2: '平台用户',
};
const typeName = typeNames[res.user.user_type] || '未知';
uni.showToast({
title: `${typeName}账号无法登录此系统`,
icon: 'none',
duration: 2500,
});
// 清除已保存的 token
setToken('');
uni.removeStorageSync('refresh_token');
uni.removeStorageSync('user_info');
return;
}
uni.showToast({
title: '登录成功',
icon: 'success',
@@ -126,21 +146,11 @@ async function submit() {
});
setTimeout(() => {
// 根据用户类型跳转到不同页面
// user_type: 1=超级管理员 2=平台 3=代理 4=企业
if (res.user.user_type === 3 || res.user.user_type === 4) {
// 代理商和企业用户都跳转到首页(首页会根据用户类型显示不同功能)
uni.$u.route({
type: 'redirectTo',
url: '/pages/agent-system/home/index',
});
} else {
// 其他用户(超级管理员、平台)跳转到默认页面
uni.$u.route({
type: 'redirectTo',
url: redirect,
});
}
// 代理商和企业用户都跳转到首页(首页会根据用户类型显示不同功能)
uni.$u.route({
type: 'redirectTo',
url: '/pages/agent-system/home/index',
});
}, 1500);
} catch (error: any) {
console.error('登录失败:', error);