Browse Source

修改

master
huxinglu 4 years ago
parent
commit
3b74a857d7
5 changed files with 10 additions and 10 deletions
  1. +1
    -1
      src/api/api.js
  2. +2
    -2
      src/api/system/lscity.js
  3. +1
    -1
      src/router/index.js
  4. +1
    -1
      src/views/login/index.vue
  5. +5
    -5
      src/vuex/modules/user.js

+ 1
- 1
src/api/api.js View File

axios.interceptors.request.use( axios.interceptors.request.use(
config => { config => {
config.headers['Content-Type'] = 'application/json;charset=UTF-8' config.headers['Content-Type'] = 'application/json;charset=UTF-8'
config.headers['Authorization'] = Cookies.get('token') ? Cookies.get('token') : ''
config.headers['Authorization'] = Cookies.get(location.host+'-token') ? Cookies.get(location.host+'-token') : ''
return config; return config;
}, },
err => { err => {

+ 2
- 2
src/api/system/lscity.js View File



getCityList(){ getCityList(){
return axios({ return axios({
method: "POST",
url: '/api/lscity/getCityList',
method: "GET",
url: '/api/syscity/getCityList',
data: {} data: {}
}) })
}, },

+ 1
- 1
src/router/index.js View File

next() next()
return return
} }
let token = Cookies.get('token')
let token = Cookies.get(location.host+'-token')
if (!token) { if (!token) {
if (to.name != 'login') { if (to.name != 'login') {
next({ next({

+ 1
- 1
src/views/login/index.vue View File

.login(this.form) .login(this.form)
.then(res => { .then(res => {
const { token } = res.data; const { token } = res.data;
Cookies.set("token", token);
Cookies.set(location.host+'-token', token);
let redirect = this.$route.query.redirect; let redirect = this.$route.query.redirect;
if (redirect) { if (redirect) {
this.$router.push({ path: redirect }); this.$router.push({ path: redirect });

+ 5
- 5
src/vuex/modules/user.js View File

// get user info // get user info
getInfo({ commit, state }) { getInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
api.getInfo({token:Cookies.get('token')}).then(res => {
api.getInfo({token:Cookies.get(location.host+'-token')}).then(res => {
commit('SET_INFO', res.data.info?res.data.info:{}) commit('SET_INFO', res.data.info?res.data.info:{})
commit('SET_PERMISSION', res.data.permission?res.data.permission:[]) commit('SET_PERMISSION', res.data.permission?res.data.permission:[])
if(res.data.permission.length>0){ if(res.data.permission.length>0){
} }
resolve(res.data.info) resolve(res.data.info)
}).catch(e => { }).catch(e => {
Cookies.set('token','')
Cookies.set(location.host+'-token','')
commit('SET_INFO', null) commit('SET_INFO', null)
commit('SET_MENU', []) commit('SET_MENU', [])
commit('SET_ROLES', null) commit('SET_ROLES', null)
// user logout // user logout
logout({ commit, state }) { logout({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
api.logout(Cookies.get('token')).then(res => {
Cookies.set('token','')
api.logout(Cookies.get(location.host+'-token')).then(res => {
Cookies.set(location.host+'-token','')
commit('SET_INFO', null) commit('SET_INFO', null)
commit('SET_MENU', []) commit('SET_MENU', [])
commit('SET_ROLES', null) commit('SET_ROLES', null)
// remove token // remove token
resetToken({ commit }) { resetToken({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
Cookies.set('token','')
Cookies.set(location.host+'-token','')
commit('SET_INFO', null) commit('SET_INFO', null)
commit('SET_MENU', []) commit('SET_MENU', [])
commit('SET_ROLES', null) commit('SET_ROLES', null)

Loading…
Cancel
Save