|
@@ -1,6 +1,6 @@
|
|
import axios from 'axios';
|
|
import axios from 'axios';
|
|
import store from '@/store'
|
|
import store from '@/store'
|
|
-import { getToken } from '@/utils/token';
|
|
|
|
|
|
+import { getToken,getUserId,removeToken,removeUserId } from '@/utils/token';
|
|
import { DES3 } from '@/utils/3des';
|
|
import { DES3 } from '@/utils/3des';
|
|
import router from '@/router/index'
|
|
import router from '@/router/index'
|
|
import { ElMessage } from '../utils/message.js'
|
|
import { ElMessage } from '../utils/message.js'
|
|
@@ -61,42 +61,10 @@ axios.interceptors.response.use(res => {
|
|
if (data.returnCode == successCode) {
|
|
if (data.returnCode == successCode) {
|
|
return Promise.resolve(data)
|
|
return Promise.resolve(data)
|
|
} else {
|
|
} else {
|
|
- if (data.returnMsg === '系统没有登录或会话超时!') {
|
|
|
|
- store.dispatch('user/changeState', {
|
|
|
|
- key: 'token',
|
|
|
|
- value: ''
|
|
|
|
- })
|
|
|
|
- store.dispatch('user/changeState', {
|
|
|
|
- key: 'name',
|
|
|
|
- value: ''
|
|
|
|
- })
|
|
|
|
- store.dispatch('user/changeState', {
|
|
|
|
- key: 'userId',
|
|
|
|
- value: ''
|
|
|
|
- })
|
|
|
|
- store.dispatch('user/changeState', {
|
|
|
|
- key: 'loginStatus',
|
|
|
|
- value: false
|
|
|
|
- })
|
|
|
|
- MessageBox.confirm('系统没有登录或会话超时, 是否登录?', '提示', {
|
|
|
|
- confirmButtonText: '登录',
|
|
|
|
- cancelButtonText: '取消',
|
|
|
|
- type: 'warning'
|
|
|
|
- })
|
|
|
|
- .then(() => {
|
|
|
|
- MessageBox.close()
|
|
|
|
- // window.location.hash = "/login/index";
|
|
|
|
- // window.location.href = "#/login/index";
|
|
|
|
- // router.replace(`/login/index`)
|
|
|
|
- // this.$router.replace('/login/index')
|
|
|
|
- let logUrl = window.location.protocol+"//"+window.location.host+"/"+Caegw_LogUrl;
|
|
|
|
- // console.log(logUrl);
|
|
|
|
- window.location.href=logUrl
|
|
|
|
- })
|
|
|
|
- .catch(() => {
|
|
|
|
- Message.info('已取消!')
|
|
|
|
- MessageBox.close()
|
|
|
|
- })
|
|
|
|
|
|
+ if (data.returnMsg === '系统没有登录或会话超时!' || data.returnMsg === '用户验证失败!') {
|
|
|
|
+ removeToken();
|
|
|
|
+ removeUserId();
|
|
|
|
+ router.replace({ path: '/login' });
|
|
}
|
|
}
|
|
return Promise.reject(data)
|
|
return Promise.reject(data)
|
|
}
|
|
}
|
|
@@ -141,8 +109,8 @@ function getUrl(channelNo = 'service') {
|
|
//配置上行报文公共包头
|
|
//配置上行报文公共包头
|
|
function getParams(params, channelNo) {
|
|
function getParams(params, channelNo) {
|
|
// params['clientToken'] = "11112";
|
|
// params['clientToken'] = "11112";
|
|
- params['clientToken'] = "e47b87eec69545559d1e81e56626da68";
|
|
|
|
- let userId ='5f06c8bc77234f969d13e160b54c27e3';
|
|
|
|
|
|
+ params['clientToken'] = getToken()||"e47b87eec69545559d1e81e56626da68";
|
|
|
|
+ let userId =getUserId() ||'5f06c8bc77234f969d13e160b54c27e3';
|
|
// let userId = store.getters.userId;
|
|
// let userId = store.getters.userId;
|
|
// if (userId) {
|
|
// if (userId) {
|
|
params['userId'] = userId;
|
|
params['userId'] = userId;
|
|
@@ -223,7 +191,7 @@ const getImage = (id, channelNo = 'server') => {
|
|
|
|
|
|
//加密密码
|
|
//加密密码
|
|
const enPassword = (password) => {
|
|
const enPassword = (password) => {
|
|
- let token = store.getters.token || getToken();
|
|
|
|
|
|
+ let token = getToken() || store.token;
|
|
return DES3.encrypt(token, password);
|
|
return DES3.encrypt(token, password);
|
|
}
|
|
}
|
|
|
|
|