update
This commit is contained in:
@@ -32,9 +32,9 @@ const beforeUpload = (file) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isLt2M = file.size / 1024 / 1024 < 5;
|
const isLt2M = file.size / 1024 / 1024 < 10;
|
||||||
if (!isLt2M) {
|
if (!isLt2M) {
|
||||||
ElMessage.error('图片大小不能超过5MB!');
|
ElMessage.error('图片大小不能超过10MB!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ const fetchImages = async () => {
|
|||||||
})
|
})
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
if (response.status == 200 || response.status == 201) {
|
if (response.status == 200 || response.status == 201) {
|
||||||
images.value = data.data;
|
// 只保留result_url存在的记录
|
||||||
const foundItem = data.data.find(item => item.is_public === true);
|
images.value = data.data.filter(item => item.result_url);
|
||||||
|
const foundItem = images.value.find(item => item.is_public === true);
|
||||||
if (foundItem) {
|
if (foundItem) {
|
||||||
globalStore.result_url = foundItem.result_url;
|
globalStore.result_url = foundItem.result_url;
|
||||||
globalStore.mergeId = foundItem.id
|
globalStore.mergeId = foundItem.id
|
||||||
@@ -44,7 +45,7 @@ const fetchImages = async () => {
|
|||||||
} else {
|
} else {
|
||||||
displayZhuli.value = false;
|
displayZhuli.value = false;
|
||||||
}
|
}
|
||||||
imageList.value = data;
|
imageList.value = images.value;
|
||||||
|
|
||||||
const hasPublicImage = images.value.some(item => item.is_public);
|
const hasPublicImage = images.value.some(item => item.is_public);
|
||||||
if (hasPublicImage) {
|
if (hasPublicImage) {
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export const Request = async (url, data, type, noloading, noerror) => {
|
|||||||
headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}`
|
headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}`
|
||||||
} else {
|
} else {
|
||||||
Storage.clear()
|
Storage.clear()
|
||||||
weui.alert("错误的请求")
|
weui.alert("登录失效,请重新登录")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,92 +190,7 @@ export const Request = async (url, data, type, noloading, noerror) => {
|
|||||||
return { res: response, json: result }
|
return { res: response, json: result }
|
||||||
} else if (response.status == 401) {
|
} else if (response.status == 401) {
|
||||||
Storage.clear()
|
Storage.clear()
|
||||||
weui.alert("错误的请求")
|
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("错误的请求")
|
|
||||||
// window.location.reload()
|
// window.location.reload()
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user