first commit

This commit is contained in:
2024-12-10 12:20:05 +08:00
commit f866087c7e
37 changed files with 2080 additions and 0 deletions

49
js/http/index.js Normal file
View File

@@ -0,0 +1,49 @@
class Ajax {
xhr = new XMLHttpRequest()
get(option) {
$("body").mLoading("show")
return new Promise((succ, err) => {
// jquery 是通过 callback 来对异步ajax代码进行封装的
$.ajax({
type: "GET",
// http://192.168.31.101:9940/v1/api + /home/banner
url: config.checkUrl() + option.url,
data: option.data,
success: res => {
$("body").mLoading("hide")
succ( this.stateChange(res) )
},
error: msg => {
err(msg)
}
});
})
}
post(option) {
return new Promise((success, error) => {
})
}
// 对业务状态码进行判断
stateChange(res) {
switch (res.status) {
case 200:
return res.data
break;
case 404:
alert(res.message)
err(this.xhr)
break;
default:
break;
}
}
}