| | |
| | | |
| | | // 新建响应拦截器 |
| | | axiosInstance.interceptors.response.use((response) => { |
| | | |
| | | |
| | | // console.log(response.status) |
| | | // debugger |
| | | // 请求失败 |
| | |
| | | } |
| | | // 业务失败 |
| | | if (!response.data.success) { |
| | | return Promise.reject(response.data) |
| | | Message.error(response.data.message) |
| | | return null |
| | | } |
| | | return response.data.data |
| | | if (response.data.data) { |
| | | return response.data.data |
| | | } else { |
| | | return response.data |
| | | } |
| | | |
| | | }, function (error) { |
| | | if (error.code == null) { |
| | | return Promise.reject(new Error('服务器繁忙,请稍后再试')) |
| | |
| | | __arguments: args, |
| | | __result_promise: null, |
| | | // 开启缓存 |
| | | cache () { |
| | | cache() { |
| | | const data = this.__cacheImpl.getJSON(cacheKey) |
| | | if (data != null) { |
| | | this.__result_promise = Promise.resolve(data) |
| | |
| | | } |
| | | return this |
| | | }, |
| | | then () { |
| | | then() { |
| | | return this.__access('then', arguments) |
| | | }, |
| | | catch () { |
| | | catch() { |
| | | return this.__access('catch', arguments) |
| | | }, |
| | | finally () { |
| | | finally() { |
| | | return this.__access('finally', arguments) |
| | | }, |
| | | __access (methodName, args) { |
| | | __access(methodName, args) { |
| | | if (this.__result_promise != null) { |
| | | return this.__result_promise |
| | | } |