From 0d0b5ec14af5c489edd30f068e37215aa87c6314 Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Thu, 2 Apr 2026 14:25:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E9=9D=9E=E4=BB=A3=E7=90=86/?= =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/agent-system/home/index.vue | 6 ++-- src/pages/common/login/index.vue | 40 +++++++++++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) 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);