This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
import Taro from '@tarojs/taro';
|
||||
|
||||
export const BASE_URL = process.env.TARO_APP_API;
|
||||
|
||||
@@ -8,15 +8,15 @@ interface Res<T> {
|
||||
msg: string;
|
||||
}
|
||||
|
||||
type Method = "GET" | "POST" | "PUT" | "DELETE";
|
||||
type Method = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
||||
|
||||
// 忽略系统提示白名单
|
||||
const IGNORED_TIPS = ["/user/find/phone"];
|
||||
const IGNORED_TIPS = ['/user/find/phone', '/user/check/payPassword'];
|
||||
|
||||
const request = (
|
||||
url: string,
|
||||
data: object = {},
|
||||
method: Method = "GET"
|
||||
method: Method = 'GET',
|
||||
): Promise<Res<any>> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Taro.request({
|
||||
@@ -24,15 +24,15 @@ const request = (
|
||||
data: data,
|
||||
method: method,
|
||||
header: {
|
||||
"content-type": "application/json",
|
||||
token: Taro.getStorageSync("token") || "",
|
||||
'content-type': 'application/json',
|
||||
token: Taro.getStorageSync('token') || '',
|
||||
},
|
||||
success: ({ data }) => {
|
||||
success: ({data}) => {
|
||||
if (data.code !== 200) {
|
||||
if (!IGNORED_TIPS.includes(url)) {
|
||||
Taro.showToast({
|
||||
title: data.msg,
|
||||
icon: "none",
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
reject(data);
|
||||
@@ -40,7 +40,7 @@ const request = (
|
||||
resolve(data);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
fail: err => {
|
||||
reject(err);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user