|
|
|
@ -54,19 +54,58 @@ class Request { |
|
|
|
if (config.interceptors?.requestInterceptors) { |
|
|
|
config = config.interceptors.requestInterceptors(config as any) |
|
|
|
} |
|
|
|
const checkJsonList = [ |
|
|
|
'getDevCoordinateByIP', |
|
|
|
'getMapInfo', |
|
|
|
'getFacilityList', |
|
|
|
'GetWeather', |
|
|
|
'getBrandShopListByFloor', |
|
|
|
'getBrandShopListByIndustryId', |
|
|
|
'getBrandShopList', |
|
|
|
'getModuleList', |
|
|
|
'getArtList' |
|
|
|
] |
|
|
|
this.instance |
|
|
|
.request<any, T>(config) |
|
|
|
.then(res => { |
|
|
|
console.log('axios获取数据 :>> ', JSON.stringify(res)) |
|
|
|
if ( |
|
|
|
config.url && |
|
|
|
config.url?.search('getMap.json') <= 0 && |
|
|
|
config.url?.search('getMapInfo.json') <= 0 && |
|
|
|
config.url?.search('getBrandShopListByFloor.json') <= 0 && |
|
|
|
config.url?.search('getBrandShopListByIndustryId.json') <= 0 |
|
|
|
) { |
|
|
|
console.log('axios获取数据 :>> ', JSON.stringify(res)) |
|
|
|
} |
|
|
|
// 如果为单个响应设置拦截器,使用单个响应的拦截器
|
|
|
|
if (config.interceptors?.responseInterceptors) { |
|
|
|
res = config.interceptors.responseInterceptors(res) |
|
|
|
} |
|
|
|
|
|
|
|
if (config.url && Object(res).code !== 200) { |
|
|
|
for (let t = 0; t < checkJsonList.length; t++) { |
|
|
|
const element = checkJsonList[t] |
|
|
|
if (config.url.search(element) > 0) { |
|
|
|
console.log('开机读取JSON报错 :>> ') |
|
|
|
window?.android?.restartWebView() |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
resolve(res) |
|
|
|
}) |
|
|
|
.catch((err: any) => { |
|
|
|
console.log('axios获取数据失败 :==>> ', JSON.stringify(err)) |
|
|
|
|
|
|
|
if (config.url) { |
|
|
|
for (let t = 0; t < checkJsonList.length; t++) { |
|
|
|
const element = checkJsonList[t] |
|
|
|
if (config.url.search(element) > 0) { |
|
|
|
console.log('catch开机读取JSON报错 :>> ') |
|
|
|
window.android.restartWebView() |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
reject(err) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|