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

@@ -34,24 +34,27 @@ const fetchImages = async () => {
}
})
const data = await response.json()
console.log('Success:', data)
images.value = data.data;
const foundItem = data.data.find(item => item.is_public === true);
if (foundItem) {
globalStore.result_url = foundItem.result_url;
displayZhuli.value = true;
} else {
displayZhuli.value = false;
}
imageList.value = data;
const hasPublicImage = images.value.some(item => item.is_public);
if (hasPublicImage) {
globalStore.chartsBattle = true;
const publicIndex = images.value.findIndex(item => item.is_public);
if (publicIndex !== -1) {
activeBorders.value = activeBorders.value.map((_, index) => index === publicIndex);
if (response.status == 200 || response.status == 201) {
images.value = data.data;
const foundItem = data.data.find(item => item.is_public === true);
if (foundItem) {
globalStore.result_url = foundItem.result_url;
displayZhuli.value = true;
} else {
displayZhuli.value = false;
}
imageList.value = data;
const hasPublicImage = images.value.some(item => item.is_public);
if (hasPublicImage) {
globalStore.chartsBattle = true;
const publicIndex = images.value.findIndex(item => item.is_public);
if (publicIndex !== -1) {
activeBorders.value = activeBorders.value.map((_, index) => index === publicIndex);
}
}
} else {
ElMessage.error(data.message);
}
} catch (error) {
console.error('Error:', error)
@@ -97,17 +100,19 @@ const handleDabangClick = () => {
},
body: {}
})
.then(response => response.json())
.then(data => {
ElMessage.success('打榜成功!');
displayZhuli.value = true;
console.log('Success:', data);
globalStore.chartsBattle = true;
return { success: true, data };
.then(async response => {
const data = await response.json()
if (response.status == 200 || response.status == 201) {
ElMessage.success('打榜成功!');
displayZhuli.value = true;
globalStore.chartsBattle = true;
return { success: true, data };
} else {
ElMessage.error(data.message);
}
})
.catch((error) => {
ElMessage.success('打榜失败!');
console.error('Error:', error);
ElMessage.error('打榜失败!');
return { success: false, error };
});
};
@@ -122,6 +127,7 @@ const downloadGenerateImg = (item) => {
console.log('下载被点击');
}
import haibaoCoverBorderNoTitle from "../assets/images/haibao-cover-no-title.webp"
import haibaoCoverBorderSuccess from "../assets/images/haibao-cover-sucess.webp";
import failedImg from '../assets/images/failed.webp';
const getGenerateImgStatus = async (item)=> {
@@ -131,17 +137,20 @@ const getGenerateImgStatus = async (item)=> {
'Authorization': `Bearer ${Storage.get("userinfos").api_token}`
}
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
.then(async response => {
const data = await response.json()
if (response.status == 200 || response.status == 201) {
if (data.status = 'failed') {
item.result_url = failedImg;
} else if (data.status = 'success') {
item.result_url = data.result_url;
}
} else {
ElMessage.error(data.message);
}
})
.catch((error) => {
console.error('Error:', error);
ElMessage.error('获取状态失败!');
});
}
@@ -185,45 +194,81 @@ const handleHaibao = async (item) => {
const loading = weui.loading()
const infos = Storage.get("userinfos")
const haibaoCover = new Haibao(951, 1607)
const userPicture = await loadImage(globalStore.result_url)
haibaoCover.add(userPicture, 0, 50, 951, 1698)
haibaoCover.add(mask, 10, 100)
let userPicture = '';
if (item && item.result_url) {
userPicture = await loadImage(item.result_url)
haibaoCover.add(userPicture, 0, 50, 951, 1698)
haibaoCover.add(mask, 10, 100)
haibaoCover.add(haibaoCoverBorderSuccess, 0, 0)
} else {
haibaoCover.add(haibaoCoverBorder, 0, 0)
}
haibaoCover.draw('destination-in').then(() => {
haibaoCover.generate({ mimeType: 'image/png' }).then(async (url) => {
userHaibaoUrl.value = url
haibaoCover.draw('destination-in').then(() => {
haibaoCover.generate({ mimeType: 'image/png' }).then(async (url) => {
userHaibaoUrl.value = url
const haibaoSave = new Haibao(1080, 2160)
const qrcode = await generateQR(`fromid=${infos.invite_code}&merge_id=${infos.merge_id}`, 200, 200)
haibaoSave.add(bg, 0, 0)
haibaoSave.add(url, 64, 250)
haibaoSave.add(qrcode, 115, 1875)
haibaoSave.draw().then(() => {
haibaoSave.text(infos.nickname + '的全家福', haibaoSave.canvas.width / 2, 200, { font: 'bold 50px Arial', color: '#fcf2b3' })
haibaoSave.generate({ mimeType: 'image/png' }).then(url => {
if (item && item.result_url) {
haibaoUrl.value = item.result_url
} else {
haibaoUrl.value = url
}
loading.hide()
const haibaoSave = new Haibao(1080, 2160)
const qrcode = await generateQR(`fromid=${infos.invite_code}&merge_id=${infos.merge_id}`, 200, 200)
haibaoSave.add(bg, 0, 0)
haibaoSave.add(url, 64, 250)
haibaoSave.add(qrcode, 115, 1875)
haibaoSave.draw().then(() => {
haibaoSave.text(infos.nickname + '的全家福', haibaoSave.canvas.width / 2, 200, { font: 'bold 50px Arial', color: '#fcf2b3' })
haibaoSave.generate({ mimeType: 'image/png' }).then(url => {
if (item && item.result_url) {
haibaoUrl.value = item.result_url
}
loading.hide()
}).catch(err => {
console.log(err)
weui.alert("海报生成失败,请重新生成")
loading.hide()
})
}).catch(err => {
console.log(err)
weui.alert("海报生成失败,请重新生成")
loading.hide()
})
}).catch(err => {
console.log(err)
weui.alert("海报生成失败,请重新生成")
loading.hide()
})
})
})
} else {
userPicture = await loadImage(globalStore.result_url)
const haibaoCoverNoTitleBorder = new Haibao(951, 1607)
haibaoCoverNoTitleBorder.add(userPicture, 0, 50, 951, 1698)
haibaoCoverNoTitleBorder.add(mask, 10, 100)
haibaoCoverNoTitleBorder.add(haibaoCoverBorder, 0, 0)
haibaoCoverNoTitleBorder.draw('destination-in').then(() => {
haibaoCoverNoTitleBorder.generate({ mimeType: 'image/png' }).then(async (url) => {
userHaibaoUrl.value = url
})
})
const haibaoCoverNoTitle = new Haibao(951, 1607)
haibaoCoverNoTitle.add(userPicture, 0, 50, 951, 1698)
haibaoCoverNoTitle.add(mask, 10, 100)
haibaoCoverNoTitle.add(haibaoCoverBorderNoTitle, 0, 0)
haibaoCoverNoTitle.draw('destination-in').then(() => {
haibaoCoverNoTitle.generate({ mimeType: 'image/png' }).then(async (url) => {
const haibaoSaveNoTitle = new Haibao(1080, 2160)
const qrcode = await generateQR(`fromid=${infos.invite_code}&merge_id=${infos.merge_id}`, 200, 200)
haibaoSaveNoTitle.add(bg, 0, 0)
haibaoSaveNoTitle.add(url, 64, 250)
haibaoSaveNoTitle.add(qrcode, 115, 1875)
haibaoSaveNoTitle.draw().then(() => {
haibaoSaveNoTitle.text(infos.nickname + '的全家福', haibaoSaveNoTitle.canvas.width / 2, 200, { font: 'bold 50px Arial', color: '#fcf2b3' })
haibaoSaveNoTitle.generate({ mimeType: 'image/png' }).then(url => {
haibaoUrl.value = url
loading.hide()
}).catch(err => {
console.log(err)
weui.alert("海报生成失败,请重新生成")
loading.hide()
})
}).catch(err => {
console.log(err)
weui.alert("海报生成失败,请重新生成")
loading.hide()
})
})
})
}
}
const markers = ref([]);
@@ -397,13 +442,12 @@ markers.value = [
.border-image {
position: absolute;
width: 40vw;
top: 1.6333vh;
left: -0.4vw;
top: 2.8vw;
left: -0.8vw;
}
.image-gallery {
overflow-y: auto;
overflow-x: hidden;
display: block;
width: 84vw;
height: 57vh;
position: relative;
@@ -411,6 +455,7 @@ markers.value = [
flex-flow: row;
flex-wrap: wrap;
top: 26vw;
padding-bottom: 22vw;
}
.image-container {
@@ -419,7 +464,7 @@ markers.value = [
top: 0;
margin-bottom: 3vw;
background-image: url('../assets/images/test.webp');
background-size: cover;
background-size: 100%;
background-repeat: no-repeat;
display: flex;
flex-direction: column;