Commit 01205811 authored by yyh's avatar yyh

允许多个toast

parent 54767591
......@@ -6,6 +6,7 @@ import axios from 'axios';
import router from '../router';
import store from '../store/index';
import { Toast } from 'vant';
Toast.allowMultiple(true) ;
const pendingAjax: any = [];
const fastClickMsg = '数据请求中,请稍后';
const CancelToken = axios.CancelToken;
......@@ -24,8 +25,8 @@ const removePendingAjax = (config: any, c?: any) => {
*/
const tip = (msg: string) => {
Toast({
message: msg,
duration: 1000,
message: `${msg}`,
duration: 2000,
forbidClick: true,
});
};
......@@ -75,7 +76,7 @@ const errorHandle = (status: number, other: any) => {
const instance = axios.create({ timeout: 1000 * 12});
// 设置post请求头
instance.defaults.headers.post['Content-Type'] = 'application/json';
let loading: any;
/**
* 请求拦截器
* 每次请求前,如果存在token则在请求头中携带token
......@@ -89,7 +90,7 @@ instance.interceptors.request.use(
// token && (config.headers.Authorization = token);
const url = config.url as string;
if (url.indexOf('list') < 0 ) {
const toast = Toast({
loading = Toast({
type: 'loading',
duration: 0,
forbidClick: true,
......@@ -111,7 +112,7 @@ instance.interceptors.response.use(
(res: any) => {
removePendingAjax(res.config);
setTimeout(() => {
Toast.clear();
loading.clear();
}, 200);
if ( res.status === 200) {
if (res.data.code === 200) {
......
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 to comment