|
@@ -13,14 +13,14 @@ import whiteList from './whiteList';
|
|
|
fly.interceptors.request.use(function (request) {
|
|
|
fly.lock();
|
|
|
// console.log('进入fly-request', request);
|
|
|
-wx.showLoading({
|
|
|
+/* wx.showLoading({
|
|
|
'title': '加载中',
|
|
|
'mask': true
|
|
|
-});
|
|
|
+}); */
|
|
|
// 不显示加载页面的接口
|
|
|
if (request.url.indexOf(whiteList.loading) === -1) {
|
|
|
// 隐藏loading遮罩
|
|
|
- wx.hideLoading();
|
|
|
+ // wx.hideLoading();
|
|
|
}
|
|
|
// 白名单内url不添加token
|
|
|
if (request.url.indexOf(whiteList.nullHeaderToken) !== -1) {
|
|
@@ -30,6 +30,7 @@ wx.showLoading({
|
|
|
'X-Tag': 'flyio'
|
|
|
};
|
|
|
console.log('nullHeaderToken()')
|
|
|
+ // wx.hideLoading();
|
|
|
fly.unlock();
|
|
|
return request;
|
|
|
}
|
|
@@ -41,6 +42,7 @@ wx.showLoading({
|
|
|
'content-type': 'application/json',
|
|
|
'X-Tag': 'flyio'
|
|
|
})
|
|
|
+ //wx.hideLoading();
|
|
|
fly.unlock();
|
|
|
return request;
|
|
|
}
|
|
@@ -53,27 +55,15 @@ wx.showLoading({
|
|
|
'X-Tag': 'flyio',
|
|
|
'Authorization': `Bearer ${wx.getStorageSync('token')}`
|
|
|
})
|
|
|
+ // wx.hideLoading();
|
|
|
fly.unlock();
|
|
|
return request;
|
|
|
}
|
|
|
else{
|
|
|
console.log("没有token,先请求token...");
|
|
|
+ // wx.hideLoading();
|
|
|
wx.login({
|
|
|
success(wxres) {
|
|
|
-/* requestAPI.userLogin(wxres.code).then(res => {
|
|
|
- if (res.status === 401) {
|
|
|
- self.setData({
|
|
|
- ifUser: false
|
|
|
- })
|
|
|
- } else {
|
|
|
- if (res.data.access_token) {
|
|
|
- wx.setStorageSync('token', res.data.access_token);
|
|
|
- wx.switchTab({
|
|
|
- url: '/pages/home/home',
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }) */
|
|
|
|
|
|
//锁定当天实例,后续请求会在拦截器外排队
|
|
|
|
|
@@ -111,11 +101,11 @@ fly.interceptors.response.use(
|
|
|
(response) => {
|
|
|
//正常返回
|
|
|
reqCount =0;
|
|
|
- wx.hideLoading();
|
|
|
+ // wx.hideLoading();
|
|
|
return response
|
|
|
},
|
|
|
(err, promise) => {
|
|
|
- wx.hideLoading();
|
|
|
+ // wx.hideLoading();
|
|
|
let msg = '';
|
|
|
if (err.status === 0) {
|
|
|
msg = '网络连接异常'
|