Bläddra i källkod

fix:pad的用户id修改

chenzhen2 1 år sedan
förälder
incheckning
80c3375e7b
4 ändrade filer med 21 tillägg och 7 borttagningar
  1. 3 3
      src/store/modules/user/actions.ts
  2. 4 4
      src/store/modules/user/state.ts
  3. 13 0
      src/utils/cookies.ts
  4. 1 0
      src/utils/https.ts

+ 3 - 3
src/store/modules/user/actions.ts

@@ -4,7 +4,7 @@ import { UserState } from './state'
 import { Mutations } from './mutations'
 import { UserMutationTypes } from './mutation-types'
 import { UserActionTypes } from './action-types'
-import { getCookieMac, removeToken, setSessionUserInfo, setToken } from '@/utils/cookies'
+import { getCookieMac, getCookieMacNew, removeToken, setSessionUserInfo, setToken } from '@/utils/cookies'
 import { PermissionActionType } from '../permission/action-types'
 import router, { resetRouter } from '@/router'
 import { useRoute, useRouter } from 'vue-router'
@@ -76,11 +76,11 @@ export const actions: ActionTree<UserState, RootState> & Actions = {
     // let nowProjectId: any = 'Pj1101080259'
     const userInfo: any = {
       // userName: '陈珍',
-      userName: 'admin',
+      userName: getCookieMacNew() ? getCookieMacNew() : 'admin',
       // userPhone: 15321277745,
       userPhone: 11111111111,
       // userId: '602ef709beb64a1f9a4b6af2196d0af7',
-      userId:'admin'
+      userId: getCookieMac() ? getCookieMac() : 'admin',
       // userId: '9a1ecfbacb6b4f249bf2dd3ec7793ead'
       // userId: '1302990695845462811'
     }

+ 4 - 4
src/store/modules/user/state.ts

@@ -1,5 +1,5 @@
 import Keys from '@/constant/key'
-import { getToken, getProjectId, getCookieUserInfo, getSessionUserInfo, getCookieMac } from '@/utils/cookies'
+import { getToken, getProjectId, getCookieUserInfo, getSessionUserInfo, getCookieMac, getCookieMacNew } from '@/utils/cookies'
 
 export interface UserState {
   token: string
@@ -16,10 +16,10 @@ export interface UserState {
 export const state: UserState = {
   token: getToken() || '',
   openid: Keys.openid,
-  userName: getSessionUserInfo() ? getSessionUserInfo().name : '',
-  userId: getSessionUserInfo() ? getSessionUserInfo().id : '',
+  userName: getCookieMacNew() ? getCookieMacNew() : 'admin',
+  userId: getCookieMac() ? getCookieMac() : 'admin',
   userPhone: getSessionUserInfo() ? getSessionUserInfo().phone : 0,
-  projectId: getProjectId()?getProjectId():'',
+  projectId: getProjectId() ? getProjectId() : '',
   companyId: '',
   mac: getCookieMac() ? getCookieMac() : '',
   remoteControl: false

+ 13 - 0
src/utils/cookies.ts

@@ -18,6 +18,19 @@ export const getCookieMac = () => {
   }
   return mac
 }
+
+// mac地址去掉冒号
+export const getCookieMacNew = () => {
+  // debugger
+  let mac: any = Cookies.get(Keys.macKey)
+  if (!mac) {
+    mac = localStorage.getItem('mac')
+  }
+  if (mac) {
+    mac = mac.replace(/:/g, '')
+  }
+  return mac
+}
 export const getCookieUserInfo = () => {
   let userInfo: any = Cookies.get(Keys.userInfoKey)
   if (userInfo) {

+ 1 - 0
src/utils/https.ts

@@ -22,6 +22,7 @@ export const https = (configobj: any = { timeout: '' }) => {
   }
   const https = new HttpClient(config)
   https.httpClient.interceptors.request.use(function (request) {
+    // debugger
     let comInfo = getUserInfo()
     // comInfo.projectId="Pj1101080255"
     const comParams: string = setQueryConfig(comInfo)