first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
import config from "@/config"
export default class Http {
constructor() {}
async get(params) {
uni.showLoading({
title: '加载中...'
});
return new Promise((success, error) => {
uni.request({
url: config.CheckBaseUrl() + params.url,
method: "GET",
data: params.data,
header: Object.assign({
"Content-Type": "application/json; charset=utf-8",
}, params.headers),
success: (res) => {
this.interceptors(success, error, res.data)
}
});
})
}
async post(params) {
uni.showLoading({
title: '加载中...'
});
return new Promise((success, error) => {
uni.request({
url: config.CheckBaseUrl() + params.url,
method: "POST",
data: params.data,
header: Object.assign({
"Content-Type": "application/json; charset=utf-8",
}, params.headers),
success: (res) => {
this.interceptors(success, error, res.data)
}
});
})
}
interceptors(s, e, data) {
uni.hideLoading();
switch (data.status) {
case 200:
s(data.result)
break;
case 404:
uni.showToast({
title: data.msg,
duration: 2000
});
throw new Error(data.msg);
break;
default:
break;
}
}
}