|
@@ -20,7 +20,7 @@ fly.interceptors.request.use((request) => {
|
|
wx.hideLoading();
|
|
wx.hideLoading();
|
|
}
|
|
}
|
|
// 请求资源服务器时,不添加token
|
|
// 请求资源服务器时,不添加token
|
|
- if (whiteList.nullHeaderToken.indexOf(request.url) !== -1) {
|
|
|
|
|
|
+ if (request.url.indexOf(whiteList.nullHeaderToken) !== -1) {
|
|
request.timeout = 30000; // 请求超时
|
|
request.timeout = 30000; // 请求超时
|
|
request.headers = {
|
|
request.headers = {
|
|
'content-type': 'application/json',
|
|
'content-type': 'application/json',
|
|
@@ -31,6 +31,17 @@ fly.interceptors.request.use((request) => {
|
|
}
|
|
}
|
|
// fly.lock()
|
|
// fly.lock()
|
|
// 延迟发请求 等 getStorageSync 存储
|
|
// 延迟发请求 等 getStorageSync 存储
|
|
|
|
+ if (request.headers.Authorization) {
|
|
|
|
+ // 给所有请求添加自定义header
|
|
|
|
+ request.timeout = 30000;
|
|
|
|
+ Object.assign(request.headers, {
|
|
|
|
+ 'content-type': 'application/json',
|
|
|
|
+ 'X-Tag': 'flyio'
|
|
|
|
+ })
|
|
|
|
+ // fly.unlock(); //解锁请求
|
|
|
|
+ return request;
|
|
|
|
+ }
|
|
|
|
+
|
|
if(wx.getStorageSync('token')) {
|
|
if(wx.getStorageSync('token')) {
|
|
// 给所有请求添加自定义header
|
|
// 给所有请求添加自定义header
|
|
request.timeout = 30000;
|
|
request.timeout = 30000;
|
|
@@ -41,16 +52,7 @@ fly.interceptors.request.use((request) => {
|
|
})
|
|
})
|
|
// fly.unlock(); //解锁请求
|
|
// fly.unlock(); //解锁请求
|
|
return request;
|
|
return request;
|
|
- } else if (request.headers.Authorization) {
|
|
|
|
- // 给所有请求添加自定义header
|
|
|
|
- request.timeout = 30000;
|
|
|
|
- Object.assign(request.headers, {
|
|
|
|
- 'content-type': 'application/json',
|
|
|
|
- 'X-Tag': 'flyio'
|
|
|
|
- })
|
|
|
|
- // fly.unlock(); //解锁请求
|
|
|
|
- return request;
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
// else if(!wx.getStorageSync('token')&&app.getCurrentPages()=='pages/login/login') {
|
|
// else if(!wx.getStorageSync('token')&&app.getCurrentPages()=='pages/login/login') {
|
|
// request.headers = {
|
|
// request.headers = {
|
|
// 'content-type': 'application/json',
|
|
// 'content-type': 'application/json',
|