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){ getIntoProject(row){
window.location.href = `http://39.108.250.202/Projectmanagement/#/?userId=${this.userId}&systemId=${row.systemId}&systemName=${row.systemName}` 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){ getIntoJudgement(row){
this.setCookie("userId",this.userId) this.setCookie("userId",this.userId)

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

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

@ -1,6 +1,6 @@
import axios from 'axios'; import axios from 'axios';
import QS from 'qs'; import QS from 'qs';
// import store from '../store/index' import store from '../store/index'
import { Message } from 'element-ui' import { Message } from 'element-ui'
import router from '../router/index' 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.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
// 请求拦截器 // 请求拦截器
// axios.interceptors.request.use(config => { axios.interceptors.request.use(config => {
// if (sessionStorage.getItem('token')) { let token = store.state.loginToken
// // 存在将token写入 request header if(token){
// config.headers.Authorization = `${sessionStorage.getItem('token')}`; config.headers.token = token
// } }
// return config; return config;
// }, err => { }, err => {
// Message.error({ Message.error({
// message: '退出登陆', message: '退出登陆',
// onClose: function () { onClose: function () {
// router.push({name: 'login'}); router.push({name: 'login'});
// } }
// }) })
// return Promise.reject(err); return Promise.reject(err);
// }) })
// 响应拦截器 // 响应拦截器
// axios.interceptors.response.use( // 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请求 * get方法对应get请求
*/ */
@ -108,6 +119,11 @@ export function get(url, params){
params: params params: params
}) })
.then(res => { .then(res => {
if(typeof res.data == 'number'){
this.$message.error(tokenStatus[res.data])
setTimeout(logouts,1500)
return false
}
if (res.data.status) { if (res.data.status) {
switch (res.data.status) { switch (res.data.status) {
case 200: case 200:

Loading…
Cancel
Save