| | |
| | | // #ifdef H5 |
| | | baseApi = import.meta.env.VITE_APP_BASE_API; |
| | | // #endif |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | return new Promise((resolve: any, reject: any) => { |
| | | uni.request({ |
| | | ...options, |
| | | url: `${baseApi}${options.url}`, |
| | |
| | | |
| | | // 业务状态码 00000 表示成功 |
| | | if (resData.code === ResultCodeEnum.SUCCESS) { |
| | | resolve(resData.data); |
| | | resolve(resData); |
| | | } |
| | | // 令牌失效或过期处理 |
| | | else if (resData.code === ResultCodeEnum.TOKEN_INVALID) { |
| | |
| | | uni.showToast({ |
| | | title: resData.msg || "业务处理失败", |
| | | icon: "none", |
| | | duration: 2000, |
| | | }); |
| | | reject({ |
| | | message: resData.msg || "业务处理失败", |
| | | code: resData.code, |
| | | duration: 2000, |
| | | }); |
| | | } |
| | | }, |
| | |
| | | reject({ |
| | | message: "网络请求失败", |
| | | error, |
| | | duration: 2000, |
| | | }); |
| | | }, |
| | | }); |