fix(默认图片增加): 新增出错时的默认图片展示,调整奖励的展示信息

This commit is contained in:
hzj 2025-09-22 17:04:58 +08:00
parent 50bdee106f
commit 72816c186c
2 changed files with 29 additions and 3 deletions

View File

@ -508,6 +508,7 @@
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 3%;
margin-bottom: 3%;
"
>
<div
@ -529,7 +530,13 @@
align-items: center;
"
>
<img :src="reward.cover" alt="" width="50%" style="aspect-ratio: 1/1" />
<img
:src="reward.cover || '/src/assets/icon/coin.png'"
alt=""
width="50%"
style="aspect-ratio: 1/1"
@error="(e) => handleImageError(e, reward.type)"
/>
</div>
</div>
@ -540,7 +547,7 @@
text-align: center;
"
>
{{ reward.name }}
{{ showDetail(reward.type, reward) }}
</div>
</div>
</div>
@ -805,6 +812,25 @@ const getCountdown = () => {
Second.value = formatTime(Math.floor(totalSeconds % 60)) //
}
//
const showDetail = (type, reward) => {
let showamount = ['GOLD', 'DIAMOND', 'GIFT', 'FRAGMENTS']
if (showamount.includes(type)) {
return reward.content
} else {
return `${reward.quantity}Days`
}
}
//
const handleImageError = (e, type) => {
console.log('图片资源出错')
e.target.onerror = null //
if ((type = 'GOLD')) {
e.target.src = new URL('/src/assets/icon/coin.png', import.meta.url).href
}
}
//
const getTopList = async (params) => {
const resWeekTopList = await getWeekTopList(params)

View File

@ -842,7 +842,7 @@ const showRanking = computed(() => {
return Ranking.value.filter((_, index) => index >= 3)
})
//
//
const handleImageError = (e, type) => {
console.log('图片资源出错')
e.target.onerror = null //