From 398794afbbe0696e763aa002313dcf4c3b82420c Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: Tue, 30 Jun 2026 08:35:44 +0800
Subject: [PATCH] 中科大支线—用户导入
---
src/store/modules/user.js | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 4451a04..af5ac68 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -3,6 +3,8 @@
import defAva from '@/assets/images/profile.jpg'
import Cookies from "js-cookie";
import {getUserById} from "@/api/hazardousChemicals/user";
+import {getConfigById} from "@/api/hazardousChemicals/config";
+import {ElMessage} from "element-plus";
const useUserStore = defineStore(
'user',
{
@@ -21,14 +23,27 @@
const password = userInfo.password
const code = userInfo.code
const uuid = userInfo.uuid
- const identity = userInfo.identity
return new Promise( (resolve, reject) => {
- login(username, password, code, uuid, identity).then( async res => {
+ login(username, password, code, uuid).then( async res => {
setToken(res.data.token)
if(res.data && res.data.id){
const info = await getUserById(res.data.id);
- if(info.data.code === 200){}
- Cookies.set('userInfo',JSON.stringify(info.data))
+ if(info.code === 200){
+ Cookies.set('userInfo',JSON.stringify(info.data))
+ }
+ if(info.data.userType == 3){
+ ElMessage.warning('监管部门账号不可登录')
+ loading.value = false
+ return
+ }
+ if(info.data.userType != 0){
+ const con = await getConfigById(res.data.companyId);
+ if(con.code === 200){
+ Cookies.set('configInfo',JSON.stringify(con.data))
+ }
+ }else {
+ Cookies.set('configInfo',null)
+ }
}
this.token = res.data.token
resolve()
@@ -41,12 +56,14 @@
getInfo() {
return new Promise((resolve, reject) => {
getInfo().then(res => {
- const user = res.user
+
+ const user = res.data.user
+
const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import.meta.env.VITE_APP_BASE_API + user.avatar;
- if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
- this.roles = res.roles
- this.permissions = res.permissions
+ if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
+ this.roles = res.data.roles
+ this.permissions = res.data.permissions
} else {
this.roles = ['ROLE_DEFAULT']
}
--
Gitblit v1.9.2