This commit is contained in:
yixu
2025-09-18 20:58:24 +08:00
parent 438bf9eecf
commit a9dc9cda79
8 changed files with 297 additions and 210 deletions

View File

@@ -204,7 +204,7 @@ const generateImage = async (options) => {
try {
const loading = weui.loading();
const mergeResponse = await fetch('https://huodong2.lzlj.com/api/faceFamily/face/merge', {
const response = await fetch('https://huodong2.lzlj.com/api/faceFamily/face/merge', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -213,49 +213,53 @@ const generateImage = async (options) => {
},
body: JSON.stringify(formData)
});
const mergeData = await mergeResponse.json();
globalStore.mergeId = mergeData.merge_id;
const navigateToSynthesizedResults = () => {
router.push({
name: 'synthesizedResults'
})
}
let index = 0
const max = 4;
const Timer = setInterval(()=>{
if (index >= max) {
loading.hide();
clearInterval(Timer)
} else {
index++
mergeFetch(index)
const data = await response.json()
if (response.status == 200 || response.status == 201) {
globalStore.mergeId = data.merge_id;
const navigateToSynthesizedResults = () => {
router.push({
name: 'synthesizedResults'
})
}
}, 1000)
const mergeFetch = async (index)=> {
const statusRes = await Request(`face/merge/${mergeData.merge_id}/status`, {}, 'GET', true)
if (statusRes.res.status === 200) {
if (statusRes.json.status === 'success') {
displayMyPhotoBtn.value = false;
let index = 0
const max = 4;
const Timer = setInterval(()=>{
if (index >= max) {
loading.hide();
clearInterval(Timer)
navigateToSynthesizedResults();
globalStore.result_url = statusRes.json.result_url;
} else {
index++
mergeFetch(index)
}
}, 1000)
const mergeFetch = async (index)=> {
const statusRes = await Request(`face/merge/${data.merge_id}/status`, {}, 'GET', true)
if (statusRes.res.status === 200) {
if (statusRes.json.status === 'success') {
displayMyPhotoBtn.value = false;
loading.hide();
clearInterval(Timer)
navigateToSynthesizedResults();
globalStore.result_url = statusRes.json.result_url;
} else {
if (index === 4) {
disableScanAnimation.value = true;
displayMyPhotoBtn.value = true;
}
}
} else {
if (index === 4) {
disableScanAnimation.value = true;
displayMyPhotoBtn.value = true;
}
}
} else {
if (index === 4) {
disableScanAnimation.value = true;
displayMyPhotoBtn.value = true;
}
}
} else {
ElMessage.error(data.message);
}
} catch (error) {
@@ -394,11 +398,14 @@ const customUpload = async (options) => {
},
body: formData
})
.then(response => response.json())
.then(data => {
loading.hide();
console.log('Success:', data);
onSuccess(data);
.then(async response => {
const data = await response.json()
if (response.status == 200 || response.status == 201) {
loading.hide();
onSuccess(data);
} else {
ElMessage.error(data.message);
}
})
.catch((error) => {
loading.hide();
@@ -699,7 +706,7 @@ import generateImg from '../assets/images/generate-img-bg.webp'
}
.item-4 {
width: 72vw;
top: 23.5%;
top: 48vw;
pointer-events: none;
}
.item-5 {