import axios from "axios"; import { Toast } from "vant"; let loading = null; const service = axios.create({ baseURL: "/shop-mall", timeout: 5000 }); service.interceptors.request.use( config => { config.headers["Authorization"] = "b6cd4e221fdc4e46a6825c236c912fa6"; if (!config.loading) { loading = Toast.loading({ forbidClick: true, message: "加载中..." }); } return config; }, error => { if (loading) Toast.clear(); console.log("rqquest====错误", error); } ); service.interceptors.response.use( response => { if (loading) Toast.clear(); const res = response.data; return res; }, error => { if (loading) Toast.clear(); console.log("response===错误", error); } ); export default service;