|
@@ -3,7 +3,12 @@ import store from '../store/index.js'
|
|
// vm,就是我们在vue文件里面的this,所以我们能在这里获取vuex的变量,比如存放在里面的token
|
|
// vm,就是我们在vue文件里面的this,所以我们能在这里获取vuex的变量,比如存放在里面的token
|
|
const install = (Vue, vm) => {
|
|
const install = (Vue, vm) => {
|
|
Vue.prototype.$u.http.setConfig({
|
|
Vue.prototype.$u.http.setConfig({
|
|
- baseUrl: config.baseUrl
|
|
|
|
|
|
+ baseUrl: config.baseUrl,
|
|
|
|
+ showLoading: true, // 是否显示请求中的loading
|
|
|
|
+ loadingText: '请求中...', // 请求loading中的文字提示
|
|
|
|
+ loadingTime: 500, // 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
|
|
|
|
+ originalData: false, // 是否在拦截器中返回服务端的原始数据
|
|
|
|
+ loadingMask: true // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
|
|
});
|
|
});
|
|
// 请求拦截,配置Token等参数
|
|
// 请求拦截,配置Token等参数
|
|
Vue.prototype.$u.http.interceptor.request = (config) => {
|
|
Vue.prototype.$u.http.interceptor.request = (config) => {
|
|
@@ -12,7 +17,7 @@ const install = (Vue, vm) => {
|
|
}
|
|
}
|
|
// 请求地址加时间戳
|
|
// 请求地址加时间戳
|
|
config.url = config.url + '?t=' + Date.now()
|
|
config.url = config.url + '?t=' + Date.now()
|
|
- let noTokenList = ['/wechat/h5/user','/client/auth/verifyCode'];
|
|
|
|
|
|
+ let noTokenList = ['/client/wechat/h5/code/', '/client/auth/sendSmsCodeV2', '/client/auth/verifyCodeV2'];
|
|
if(noTokenList.includes(config.url)) config.header.noToken = true;
|
|
if(noTokenList.includes(config.url)) config.header.noToken = true;
|
|
return config;
|
|
return config;
|
|
}
|
|
}
|
|
@@ -20,7 +25,7 @@ const install = (Vue, vm) => {
|
|
Vue.prototype.$u.http.interceptor.response = (res) => {
|
|
Vue.prototype.$u.http.interceptor.response = (res) => {
|
|
if(res.code == 200) {
|
|
if(res.code == 200) {
|
|
return res;
|
|
return res;
|
|
- } else if(res.code == 401 || res.code == 400){
|
|
|
|
|
|
+ } else if(res.code == 401 || res.code == 400) {
|
|
const backUrl = location.href
|
|
const backUrl = location.href
|
|
// 判断浏览器
|
|
// 判断浏览器
|
|
const ua = window.navigator.userAgent.toLowerCase();
|
|
const ua = window.navigator.userAgent.toLowerCase();
|