提现错误弹窗
This commit is contained in:
@@ -105,7 +105,7 @@ class HttpService {
|
||||
}
|
||||
|
||||
// 处理响应
|
||||
private handleResponse<T>(response: any): Promise<ApiResponse<T>> {
|
||||
private handleResponse<T>(response: any, showToast: boolean): Promise<ApiResponse<T>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { statusCode, data } = response
|
||||
|
||||
@@ -121,8 +121,12 @@ class HttpService {
|
||||
// 业务状态码检查
|
||||
if (data && typeof data === 'object') {
|
||||
if (data.success === false || (data.code && data.code !== 0 && data.code !== 200)) {
|
||||
this.handleBusinessError(data)
|
||||
reject(new Error(data.message || '请求失败'))
|
||||
if (showToast) {
|
||||
this.handleBusinessError(data)
|
||||
reject(new Error(data.message || '请求失败'))
|
||||
} else {
|
||||
reject(response.data)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -191,7 +195,8 @@ class HttpService {
|
||||
data,
|
||||
params,
|
||||
showLoading = false,
|
||||
loadingText = '请求中...'
|
||||
loadingText = '请求中...',
|
||||
showToast = true,
|
||||
} = config
|
||||
|
||||
let fullUrl = this.buildUrl(url, method === 'GET' ? params : undefined)
|
||||
@@ -238,11 +243,12 @@ class HttpService {
|
||||
method: method,
|
||||
data: method !== 'GET' ? data : undefined,
|
||||
header: reqHeader,
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
showToast,
|
||||
}
|
||||
|
||||
const response = await Taro.request(requestConfig)
|
||||
return this.handleResponse<T>(response)
|
||||
return this.handleResponse<T>(response, showToast)
|
||||
} catch (error) {
|
||||
this.log('error', '请求失败', error)
|
||||
|
||||
@@ -304,9 +310,9 @@ class HttpService {
|
||||
}
|
||||
|
||||
|
||||
uploadFile(){
|
||||
uploadFile() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// PUT请求
|
||||
|
||||
Reference in New Issue
Block a user