This commit is contained in:
yixu
2025-09-22 17:36:39 +08:00
parent dbe781c402
commit 50e1dc2139
3 changed files with 8 additions and 92 deletions

View File

@@ -139,7 +139,7 @@ export const Request = async (url, data, type, noloading, noerror) => {
headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}`
} else {
Storage.clear()
weui.alert("错误的请求")
weui.alert("登录失效,请重新登录")
}
}
@@ -190,92 +190,7 @@ export const Request = async (url, data, type, noloading, noerror) => {
return { res: response, json: result }
} else if (response.status == 401) {
Storage.clear()
weui.alert("错误的请求")
// window.location.reload()
return
} else {
if (!noerror) {
weui.alert(message)
}
return { res: response, json: result }
}
} catch (error) {
if (!noerror) {
weui.alert(message)
}
loading && loading.hide()
}
}
export const RequestImg = async (url, data, type, noloading, noerror) => {
let headers = {
'Content-Type': 'multipart/form-data',
Accept: "application/json",
"Source": "faceFamily",
'App-Channel': getUserBrowersName(),
refer: document.referrer,
blackbox: Storage.get("blackbox") ? Storage.get("blackbox") : false
}
if (url != "sms/sendCode" && url != "sms/authPhone" && url != "wechat/login" && url != "wechat/jssdk") {
if (isLogin()) {
headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}`
} else {
Storage.clear()
weui.alert("错误的请求")
return
}
}
if (isBaseLogin() && url == "sms/authPhone") {
headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}`
}
let loading = false
if (!noloading) {
loading = weui.loading()
}
let message = "请求失败,请重试"
let fetchData = {
method: type || 'POST',
headers: new Headers(headers),
}
if (fetchData.method == "POST") {
fetchData.body = JSON.stringify(data)
}
let requrl = 'https://huodong2.lzlj.com/api/faceFamily/upload/image'
if (type === "GET") {
let paramArr = []
Object.keys(data).forEach(v => {
paramArr.push(`${v}=${data[v]}`)
})
requrl = paramArr.length === 0 ? `${requrl}` : `${requrl}?${paramArr.join("&")}`
}
try {
const response = await fetch(`${requrl}`, fetchData)
const result = await response.json()
message = result.message || message
if (getParam("debug")) {
console.log("url:", url)
console.log("data:", data)
console.log(response)
console.log(result)
}
loading && loading.hide()
if (response.status == 200 || response.status == 201) {
return { res: response, json: result }
} else if (response.status == 401) {
Storage.clear()
weui.alert("错误的请求")
weui.alert("登录失效,请重新登录")
// window.location.reload()
return
} else {