diff --git a/src/pages/agent-system/home/index.vue b/src/pages/agent-system/home/index.vue
index 5716605..810b7c0 100644
--- a/src/pages/agent-system/home/index.vue
+++ b/src/pages/agent-system/home/index.vue
@@ -47,8 +47,8 @@ const menuItems = computed(() => {
},
]
- // 企业端显示授权卡和授权设备
- if (userInfo.value?.user_type !== 3) {
+ // 企业端显示授权卡和授权设备 (仅 user_type === 4)
+ if (userInfo.value?.user_type === 4) {
menus.push(
{
title: '授权卡列表',
@@ -201,7 +201,7 @@ onMounted(() => {
代理
企业
diff --git a/src/pages/common/login/index.vue b/src/pages/common/login/index.vue
index 3a39e40..d26f6ac 100644
--- a/src/pages/common/login/index.vue
+++ b/src/pages/common/login/index.vue
@@ -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 = {
+ 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);