|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
* @Author: 王文杰
|
|
|
|
|
* @Date: 2024-01-04 12:54:56
|
|
|
|
|
* @LastEditors: 王文杰
|
|
|
|
|
* @LastEditTime: 2024-03-07 17:18:09
|
|
|
|
|
* @LastEditTime: 2024-03-08 12:04:46
|
|
|
|
|
* @FilePath: /app-nx-recycle/src/utils/http.ts
|
|
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
|
|
*/
|
|
|
|
@ -66,7 +66,7 @@ type Data<T> = {
|
|
|
|
|
result: T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ajaxError(data) {
|
|
|
|
|
function ajaxError(data: AnyObject) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: data.msg || '请求出错,请重试',
|
|
|
|
|
icon: 'none',
|
|
|
|
@ -75,10 +75,10 @@ function ajaxError(data) {
|
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
|
memberStore.clearProfile()
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/login/login'
|
|
|
|
|
url: '/pages/login/login',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 2.2 添加类型,支持泛型
|
|
|
|
@ -88,7 +88,7 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|
|
|
|
uni.request({
|
|
|
|
|
...options,
|
|
|
|
|
// 响应成功
|
|
|
|
|
success(res) {
|
|
|
|
|
success(res: AnyObject) {
|
|
|
|
|
// 状态码 2xx, axios 就是这样设计的
|
|
|
|
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
|
|
|
if (res.data?.code == 200) {
|
|
|
|
|