feat(custom): 大转盘第一版

This commit is contained in:
2024-01-13 16:56:15 +08:00
parent 9f43f1293c
commit e4908909bd
38 changed files with 7099 additions and 8218 deletions

View File

@@ -2,34 +2,34 @@ import { app } from '@/config'
import Taro from '@tarojs/taro'
export interface RequestParams {
url: string
method: 'GET' | 'POST' | 'PUT' | 'DELETE'
header?: object
data?: string | object
url: string
method: 'GET' | 'POST' | 'PUT' | 'DELETE'
header?: object
data?: string | object
}
const request = (request: RequestParams): Promise<any> => {
Taro.showLoading({
title: '加载中',
})
return new Promise((resolve, reject) => {
Taro.request({
url: `${app.API_URL()}${request.url}`,
method: request.method,
timeout: 5000,
dataType: 'json',
header: request.header || {},
data: request.data || {},
success: (res) => {
resolve(res.data)
Taro.hideLoading()
},
fail: (err) => {
reject(err)
Taro.hideLoading()
},
// Taro.showLoading({
// title: '加载中',
// })
return new Promise((resolve, reject) => {
Taro.request({
url: `${app.API_URL()}${request.url}`,
method: request.method,
timeout: 5000,
dataType: 'json',
header: request.header || {},
data: request.data || {},
success: (res) => {
resolve(res.data)
// Taro.hideLoading()
},
fail: (err) => {
reject(err)
Taro.hideLoading()
},
})
})
})
}
export default request