From 9fa19968f04de83a13041194b18f6aa2e0c38660 Mon Sep 17 00:00:00 2001 From: qx <1084500556@qq.com> Date: 星期二, 11 二月 2025 13:49:21 +0800 Subject: [PATCH] qx --- src/utils/request.js | 6 +++++- src/permission.js | 9 ++++++++- src/api/login.js | 8 +++++--- src/store/modules/user.js | 15 +++++++++++---- src/views/login.vue | 6 ++++++ src/router/index.js | 5 +++-- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/api/login.js b/src/api/login.js index 39e45ae..821f942 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -2,7 +2,7 @@ import { encrypt } from '@/utils/jsencrypt' // 鐧诲綍鏂规硶 -export function login(username, password, code, uuid,type, mobile) { +export function login(username, password, code, uuid,type, mobile,hospId) { password = encrypt(password); const data = { username, @@ -11,11 +11,13 @@ uuid, type, mobile, + hospId } return request({ url: '/login', headers: { - isToken: false + isToken: false, + hospId:hospId }, method: 'post', data: data @@ -32,7 +34,7 @@ return request({ url: '/cus/login', headers: { - isToken: false + isToken: false, }, method: 'post', params: data diff --git a/src/permission.js b/src/permission.js index 6bb0a1f..1537520 100644 --- a/src/permission.js +++ b/src/permission.js @@ -45,7 +45,14 @@ // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆 next() } else { - next(`/login?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤� + // next(`/login?redirect=${to.fullPath}&hospId=${to.meta.routerType}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤� + next({ + path:"/login", + query:{ + redirect:to.fullPath, + hospId:"xamjyy" + } + }) NProgress.done() } } diff --git a/src/router/index.js b/src/router/index.js index 4a05f71..1f5425c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -38,7 +38,7 @@ children: [ { path: '/redirect/:path(.*)', - component: () => import('@/views/redirect') + component: () => import('@/views/redirect'), }, { path: '/emer', @@ -203,7 +203,8 @@ path: 'index', component: () => import('@/views/index'), name: 'Index', - meta: { title: '棣栭〉', icon: 'dashboard', affix: true } + meta: { title: '棣栭〉', icon: 'dashboard', affix: true ,} + // routerType:"xamjyy", } ] }, diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 4c23e5e..73dcdb6 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -7,7 +7,8 @@ name: '', avatar: '', roles: [], - permissions: [] + permissions: [], + // routeId: null }, mutations: { @@ -25,7 +26,10 @@ }, SET_PERMISSIONS: (state, permissions) => { state.permissions = permissions - } + }, + // SET_ROUTE_ID(state, id) { + // state.routeId = id; + // } }, actions: { @@ -37,9 +41,10 @@ const uuid = userInfo.uuid const type = userInfo.type const mobile = userInfo.mobile + const hospId = userInfo.hospId return new Promise((resolve, reject) => { if(userInfo.username.length === 12){ - getlogin(username, password, code, uuid,type,mobile).then(res => { + getlogin(username, password, code, uuid,type,mobile,hospId).then(res => { setToken(res.token) commit('SET_TOKEN', res.token); resolve(res) @@ -47,9 +52,10 @@ reject(error) }) }else{ - login(username, password, code, uuid,type,mobile).then(res => { + login(username, password, code, uuid,type,mobile,hospId).then(res => { setToken(res.token) commit('SET_TOKEN', res.token) + // commit('SET_ROUTE_ID', hospId) resolve(res) }).catch(error => { reject(error) @@ -87,6 +93,7 @@ commit('SET_TOKEN', '') commit('SET_ROLES', []) commit('SET_PERMISSIONS', []) + // commit('SET_ROUTE_ID', []) removeToken() resolve() }).catch(error => { diff --git a/src/utils/request.js b/src/utils/request.js index f48f57e..06ed687 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -6,12 +6,14 @@ import { tansParams, blobValidate } from "@/utils/ruoyi"; import cache from '@/plugins/cache' import { saveAs } from 'file-saver' +import Cookies from "js-cookie" + let downloadLoadingInstance; // 鏄惁鏄剧ず閲嶆柊鐧诲綍 export let isRelogin = { show: false }; - axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' + // 鍒涘缓axios瀹炰緥 const service = axios.create({ // axios涓姹傞厤缃湁baseURL閫夐」锛岃〃绀鸿姹俇RL鍏叡閮ㄥ垎 @@ -26,6 +28,8 @@ const isRepeatSubmit = (config.headers || {}).repeatSubmit === false if (getToken() && !isToken) { config.headers['Authorization'] = 'Bearer ' + getToken() + console.log(store) + config.headers['hospId'] = Cookies.get("hospId"); } if (config.method === 'get' && config.params) { let url = config.url + '?' + tansParams(config.params); diff --git a/src/views/login.vue b/src/views/login.vue index af01c3d..559e1a0 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -78,6 +78,7 @@ username: "", password: "", mobile: false, + hospId:"", // username:"13800138008", // password:"888888", rememberMe: false, @@ -136,6 +137,7 @@ created() { this.getstate(); this.getCookie(); + this.loadAll(); }, methods: { getstate() { @@ -149,6 +151,10 @@ }) }, + loadAll(){ + this.loginForm.hospId = this.$route.query.hospId + Cookies.set("hospId", this.loginForm.hospId); + }, hide() { // this.loginForm.username = "10001"; -- Gitblit v1.8.0