Ver código fonte

header增加sessionid

chenjun 1 ano atrás
pai
commit
532048dbdc
4 arquivos alterados com 19 adições e 4 exclusões
  1. 8 0
      src/utils/auth.js
  2. 4 1
      src/utils/request-new.js
  3. 4 1
      src/utils/request.js
  4. 3 2
      src/views/login/index.vue

+ 8 - 0
src/utils/auth.js

@@ -29,3 +29,11 @@ export function setUserId (id) {
 export function getUserId () {
   return sessionStorage.getItem("User_Id")
 }
+
+export function setSessionid (name = "sessionid",sessionid) {
+  return Cookies.set(name,sessionid)
+}
+
+export function getSessionid (name = "sessionid") {
+  return Cookies.get(name)
+}

+ 4 - 1
src/utils/request-new.js

@@ -1,6 +1,6 @@
 import axios from 'axios'
 import { MessageBox, Message } from 'element-ui'
-import { getToken, getCodeToken, TokenKey } from '@/utils/auth'
+import { getToken, getCodeToken, TokenKey ,getSessionid} from '@/utils/auth'
 import store from '@/store'
 let isMttoken
 // create an axios instance
@@ -26,6 +26,9 @@ service.interceptors.request.use(
     } else if (getToken()) {
       config.headers["token"] = getToken();
     }
+    if (getSessionid('sessionid')) {
+      config.headers["sessionid"] = getSessionid('sessionid');
+    }
     return config
   },
   error => {

+ 4 - 1
src/utils/request.js

@@ -2,7 +2,7 @@ import axios from "axios";
 import { MessageBox, Message } from "element-ui";
 import store from "@/store";
 import router, { resetRouter } from "@/router";
-import { getToken, TokenKey, removeToken } from "@/utils/auth";
+import { getToken, TokenKey, removeToken,getSessionid } from "@/utils/auth";
 // create an axios instance
 // let baseURL
 // if (process.env.NODE_ENV === "development") {
@@ -26,6 +26,9 @@ service.interceptors.request.use(
     if (getToken('usertoken')) {
       config.headers["usertoken"] = getToken('usertoken');
     }
+    if (getSessionid('sessionid')) {
+      config.headers["sessionid"] = getSessionid('sessionid');
+    }
     return config;
   },
   (error) => {

+ 3 - 2
src/views/login/index.vue

@@ -38,7 +38,7 @@
 <script>
 import { isValue } from "@/utils/validate";
 import { getVCode, getToken, getKey, forceLogin } from "@/api/login";
-import { setToken, TokenKey, getUserId, setCodeToken } from '@/utils/auth';
+import { setToken, TokenKey, getUserId, setCodeToken,setSessionid } from '@/utils/auth';
 import MD5 from 'blueimp-md5'
 import JSEncrypt from "jsencrypt";
 const defaultBgImg = require('@/assets/loginpage/bg.jpg')
@@ -81,12 +81,13 @@ export default {
         'appsecret': PLATFROM_CONFIG.appKeyString
       })
       if (code == 0 && isValue(returnData)) {
-        const { appname, backgroundimage, applogo, securitycoderule, smalllogo, token } = returnData;
+        const { appname, backgroundimage, applogo, securitycoderule, smalllogo, token,sessionid } = returnData;
         this.imgSrc = smalllogo
         this.pageTitle = appname ?? '行李全流程跟踪系统'
         this.isCode = securitycoderule
         this.backgroundImg = backgroundimage
         setToken(TokenKey, token);
+        setSessionid("sessionid", sessionid);
         sessionStorage.setItem('appConfig', JSON.stringify({ ...returnData }))
         // setToken('active_duration', active_duration);
         sessionStorage.setItem('appLogo', applogo)