From fba8fd83a9612225ce726a7ff443a9e4167c8b33 Mon Sep 17 00:00:00 2001 From: yzw <2431960323@qq.com> Date: Tue, 20 Dec 2022 20:57:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=BD=95=E5=90=8Evu?= =?UTF-8?q?ex=E4=B8=AD=E5=AD=98=E5=82=A8=E7=94=A8=E6=88=B7=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/person.js | 4 ++-- src/store/modules/user.js | 11 ++++++++++- vue.config.js | 3 +-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/api/person.js b/src/api/person.js index 73da75b..a72ce11 100644 --- a/src/api/person.js +++ b/src/api/person.js @@ -2,7 +2,7 @@ import request from '@/utils/request' export function getPersonData(params) { return request({ - url: '/person/person-information2', + url: '/person/information2', method: 'get', params }) @@ -10,7 +10,7 @@ export function getPersonData(params) { export function getPersonTag(params) { return request({ - url: '/person/person_tag', + url: '/person/tag', method: 'get', params }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 8a06aea..4b805e3 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -4,7 +4,8 @@ import { resetRouter } from '@/router' const getDefaultState = () => { return { token: '', - id_card: '' + id_card: '', + role: '' } } @@ -19,6 +20,9 @@ const mutations = { }, SET_ID_CARD: (state, id_card) => { state.id_card = id_card; + }, + SET_ROLE: (state, role) => { + state.role = role } } @@ -30,6 +34,11 @@ const actions = { login({ user_num: username.trim(), password: password }).then(response => { commit('SET_TOKEN', response.token) commit('SET_ID_CARD', username) + // 解码jwt 获得role + let payload = response.token.split('.')[1] + let data = JSON.parse(decodeURIComponent(escape(window.atob(payload)))); + let role = data.role + commit('SET_ROLE', role) // 存储到本地 关闭页面后,自动登录的功能还在考虑 // if (response.code == 0) { // sessionStorage['zssr_token'] = response.token; diff --git a/vue.config.js b/vue.config.js index 99c8caa..7329422 100644 --- a/vue.config.js +++ b/vue.config.js @@ -39,9 +39,8 @@ module.exports = { proxy: { '/': { // target: 'http://127.0.0.1:4523/m1/1256020-0-default/', - target: 'http://127.0.0.1:8000', - // target: 'http://192.168.31.102:8000', // target: 'http://222.20.95.239:8000', + target: 'http://127.0.0.1:8123', changeOrigin: true, pathRewrite: { }