Commit 1f647aaf by hank

bug

parent 081ee4bd
......@@ -35,15 +35,15 @@ axios.interceptors.request.use(
// respone拦截器
axios.interceptors.response.use(
response => {
if (response.data.code === '0000' || response.data.code === '4010' || response.data.code === '1041') {
if (response.data.code === '0000' || response.data.code === '4010' || response.data.code === 0) {
// 1041 公司存在报错
return response
} else {
response.status = 400
Toast({
message: response.data.message,
message: response.data.msg,
position: 'center',
duration: 3 * 1000
duration: 2 * 1000
})
return Promise.reject(response)
throw new Error({
......@@ -60,17 +60,20 @@ axios.interceptors.response.use(
*/
err => {
if (err && err.response) {
if(err.response.data.code == 1001000 || err.response.data.code == 101) {
store.dispatch('getAuth').then()
}
switch (err.response.status) {
case 400:
err.message = `${err.response.data.message}`
err.message = `${err.response.data.msg}`
break
case 401:
err.message = `${err.response.data.message}`
err.message = `${err.response.data.msg}`
break
case 403:
err.message = `${err.response.data.message}`
err.message = `${err.response.data.msg}`
break
case 404:
......@@ -78,7 +81,7 @@ axios.interceptors.response.use(
break
case 405:
err.message = `方法错误: ${err.response.data.message}`
err.message = `方法错误: ${err.response.data.msg}`
break
case 408:
......
......@@ -50,7 +50,7 @@ export default {
if(localStorage.getItem('token')) {
store.commit('getUserInfo')
} else {
// store.dispatch('getAuth').then()
store.dispatch('getAuth').then()
}
if(this.getQuery('code')) {
store.dispatch('getToken', this.getQuery('code')).then()
......@@ -82,7 +82,7 @@ export default {
var theRequest = new Object();
if (url.indexOf('?') != -1) {
var str = url.substr(1);
strs = str.split('&');
var strs = str.split('&');
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
}
......
......@@ -56,6 +56,22 @@ var _hmt = _hmt || [];
router.beforeEach((to, from, next) => {
function getQuery (key) {
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf('?') != -1) {
var str = url.substr(1);
strs = str.split('&');
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
}
}
if (key) {
return theRequest[key];
} else {
return theRequest;
}
}
const list = ['/', '/detail', '/imgup'] // 将需要切换效果的路由名称组成一个数组
const toName = to.path // 即将进入的路由名字
const fromName = from.path // 即将离开的路由名字
......@@ -78,8 +94,14 @@ router.beforeEach((to, from, next) => {
_hmt.push(['_trackPageview', '/#' + to.fullPath]);
}
}
return next()
if(getQuery('code') && !store.state.token) {
store.dispatch('getToken', getQuery('code')).then(res => {
next()
})
} else {
next()
}
// return next()
})
......
......@@ -84,7 +84,7 @@ export default {
var theRequest = new Object();
if (url.indexOf('?') != -1) {
var str = url.substr(1);
strs = str.split('&');
var strs = str.split('&');
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment