import { BASE_URL } from "@/config/index.js" const install = (Vue, vm) => { // 请求全局配置 Vue.prototype.$u.http.setConfig({ baseUrl: BASE_URL, method: 'POST', dataType: 'json', // 返回数据时自动 JSON.parse() showLoading: false, // 是否显示请求中的loading loadingText: '正在加载', loadingTime: 800 // 延迟800毫秒时显示加载框 }); // 请求前拦截, 现在不做拦截 Vue.prototype.$u.http.interceptor.request = config => { return true; }; // 响应拦截 Vue.prototype.$u.http.interceptor.response = res => { if(res.code == 0) { return res; } else { vm.$msg(res.msg); return false; } // res.code == 9998 手机号 res.code == 9999 用户信息 } } export default { install }