yujialong 4 years ago
parent f54b67d21a
commit ccf44dc223
  1. 2
      src/components/page/Configure.vue
  2. 1
      src/components/page/Login.vue
  3. 8
      src/store/index.js
  4. 48
      src/utils/http.js

@ -145,7 +145,7 @@ export default {
},
getIntoProject(row){
window.location.href = `http://39.108.250.202/Projectmanagement/#/?userId=${this.userId}&systemId=${row.systemId}&systemName=${row.systemName}`
// window.location.href = `http://192.168.31.154:8081/#/?userId=${this.userId}&systemId=${row.systemId}&systemName=${row.systemName}`
// window.location.href = `http://192.168.31.154:8083/#/?userId=${this.userId}&systemId=${row.systemId}&systemName=${row.systemName}`
},
getIntoJudgement(row){
this.setCookie("userId",this.userId)

@ -66,6 +66,7 @@ export default {
this.$message.success('登录成功');
localStorage.setItem('ms_username', this.param.username);
this.$store.commit("userLoginData", { userLogin_id : res.message.retvalue.userId});
this.$store.commit("tokenData", {loginToken: res.message.retvalue.loginToken})
this.$router.push('/dashboard');
}else{
this.$message.error('该用户没有权限');

@ -12,7 +12,8 @@ const store = new Vuex.Store({
configId: '',
systemId: '',
orderId: '',
userLoginId: ''
userLoginId: '',
loginToken: ''
},
mutations:{
userData (state, payload) {
@ -39,7 +40,10 @@ const store = new Vuex.Store({
},
userLoginData (state, payload) {
state.userLoginId = payload.userLogin_id
}
},
tokenData (state, payload) {
state.loginToken = payload.loginToken
},
}
});

@ -1,6 +1,6 @@
import axios from 'axios';
import QS from 'qs';
// import store from '../store/index'
import store from '../store/index'
import { Message } from 'element-ui'
import router from '../router/index'
@ -20,21 +20,21 @@ axios.defaults.timeout = 30000;
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
// 请求拦截器
// axios.interceptors.request.use(config => {
// if (sessionStorage.getItem('token')) {
// // 存在将token写入 request header
// config.headers.Authorization = `${sessionStorage.getItem('token')}`;
// }
// return config;
// }, err => {
// Message.error({
// message: '退出登陆',
// onClose: function () {
// router.push({name: 'login'});
// }
// })
// return Promise.reject(err);
// })
axios.interceptors.request.use(config => {
let token = store.state.loginToken
if(token){
config.headers.token = token
}
return config;
}, err => {
Message.error({
message: '退出登陆',
onClose: function () {
router.push({name: 'login'});
}
})
return Promise.reject(err);
})
// 响应拦截器
// axios.interceptors.response.use(
@ -99,6 +99,17 @@ axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
// }
// );
function logouts(){
store.replaceState({})
localStorage.removeItem('ms_username')
location.reload()
}
let tokenStatus = {
0: '用户未登录,请登录后操作!',
1: 'token错误,请重新登录!'
}
/**
* get方法对应get请求
*/
@ -108,6 +119,11 @@ export function get(url, params){
params: params
})
.then(res => {
if(typeof res.data == 'number'){
this.$message.error(tokenStatus[res.data])
setTimeout(logouts,1500)
return false
}
if (res.data.status) {
switch (res.data.status) {
case 200:

Loading…
Cancel
Save