提交 c472f4d4 authored 作者: 钟是志's avatar 钟是志

[全版本] 架构改变

上级 d4ae5ff0
/* import fetch from 'fetch'; */ /* import fetch from 'fetch'; */
import { stringify } from 'qs'; import { stringify } from 'qs';
import { Toast, Modal } from 'antd-mobile'; import { Toast, Modal } from 'antd-mobile';
import router from 'umi/router';
import { routerRedux } from 'dva/router'; import { routerRedux } from 'dva/router';
import store from 'dva'; import store from 'dva';
import FormdataWrapper from './object-to-formdata-custom'; import FormdataWrapper from './object-to-formdata-custom';
...@@ -103,24 +104,25 @@ export default function request(url, options) { ...@@ -103,24 +104,25 @@ export default function request(url, options) {
return response; return response;
}) })
.catch(e => { .catch(e => {
const { dispatch } = store;
const status = e.name; const status = e.name;
if (status === 401) { if (status === 401) {
Toast.hide(); Toast.hide();
Toast.info('登录信息已过期,请重新登录') Toast.info('登录信息已过期,请重新登录');
dispatch(routerRedux.push('/')); router.push({
pathname: '/',
});
return; return;
} }
if (status === 403) { if (status === 403) {
dispatch(routerRedux.push('/exception/403')); Toast.info('请求错误,请联系管理员' + status, 2);
return; return;
} }
if (status <= 504 && status >= 500) { if (status <= 504 && status >= 500) {
dispatch(routerRedux.push('/exception/500')); Toast.info('请求错误,请联系管理员' + status, 2);
return; return;
} }
if (status >= 404 && status < 422) { if (status >= 404 && status < 422) {
dispatch(routerRedux.push('/exception/404')); Toast.info('请求错误,请联系管理员' + status, 2);
return; return;
} }
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论