first commit

This commit is contained in:
Ls
2026-02-12 12:19:20 +08:00
commit 219fd9be5c
529 changed files with 169918 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
export class HttpRequest {
/***普通请求方法***/
static Request(url: string, method: "GET" | "POST" | "PUT" | undefined, data: object | any) {
return new Promise(function(resolve, reject) {
let header = {
'content-type': method == 'POST' || method == 'PUT' ? 'application/x-www-form-urlencoded' : 'application/json; charset=utf-8',
'Access-Control-Allow-Origin': '*'
};
uni.request({
url: url,
method: method,
data: data,
header: header,
success(res: any) {
if (res.statusCode == "200") {
resolve(res.data);
}
else
{
resolve(res);
}
},
fail(err) {
//请求失败
uni.showToast({
title: '无法连接到服务器',
icon: 'none'
})
reject(err)
}
})
})
};
/***带Token的请求方法***/
static RequestWithToken(url: string, method: "GET" | "POST" | "PUT" | undefined, token: string, data: object | any) {
return new Promise(function(resolve, reject) {
let header = {
'content-type': method == 'POST' || method == 'PUT' ? 'application/x-www-form-urlencoded' : 'application/json; charset=utf-8',
'Authorization': 'Bearer ' + token,//token获取
'Access-Control-Allow-Origin': '*'
};
uni.request({
url: url,
method: method,
data: data,
header: header,
success(res: any) {
resolve(res);
},
fail(err) {
//请求失败
uni.showToast({
title: '无法连接到服务器',
icon: 'none'
})
reject(err)
}
})
})
}
}