feat(新页面): 幸运美金第四期

This commit is contained in:
hzj 2026-04-09 16:15:03 +08:00
parent 365588e6f3
commit 9fe4400fcd
6 changed files with 3598 additions and 0 deletions

View File

@ -395,6 +395,12 @@ const router = createRouter({
},
// 限时活动
{
path: '/activities/lucky-dollars-season4',
name: 'lucky-dollars-season4',
component: () => import('../views/Activities/LuckyDollars/Season4/index.vue'),
meta: { requiresAuth: true },
}, //2026年x月x日上午5点结束
{
path: '/activities/lesser-bairam',
name: 'lesser-bairam',

View File

@ -60,6 +60,7 @@ const ACTIVITIES = [
'/recharge-reward', //充值奖励
'/login-reward', // 登录奖励
'/activities/lucky-dollars-season4', // 幸运美金活动
'/activities/lesser-bairam', // 开斋节打榜
'/activities/lucky-dollars-season3', // 斋月打榜
'/activities/spring-festival', // 春节打榜

View File

@ -411,6 +411,7 @@ class RouteGuard {
'/recharge-reward', //充值奖励
'/login-reward', // 登录奖励
'/activities/lucky-dollars-season4', // 幸运美金活动
'/activities/lesser-bairam', // 开斋节打榜
'/activities/lucky-dollars-season3', // 斋月打榜
'/activities/spring-festival', // 春节打榜

View File

@ -0,0 +1,285 @@
<!-- Barrage.vue 优化版 -->
<template>
<div
style="position: relative; width: 100%; height: 32vw; overflow: hidden; pointer-events: none"
>
<!-- 双行弹幕轨道 -->
<div
v-for="(track, index) in visibleTracks"
:key="index"
style="position: absolute; width: 100%; height: 50px"
:style="{ top: `calc(${index} * 16vw)` }"
>
<div
v-for="item in track"
:key="item.id"
class="barrage-item"
style="
position: absolute;
border-radius: 26px;
padding: 4px;
display: flex;
align-items: center;
gap: 4px;
backdrop-filter: blur(1px);
"
:style="getBarrageStyle(item)"
@animationend="handleAnimationEnd(item.id)"
>
<img
:src="item.avatar || ''"
alt=""
style="
width: 10vw;
border-radius: 50%;
display: block;
aspect-ratio: 1/1;
object-fit: cover;
"
@error="handleAvatarImageError"
/>
<div
style="
font-weight: 700;
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: linear-gradient(
180deg,
#fff9a9 26.92%,
#ed7d0a 52.08%,
#fffab5 73.08%
);
"
>
{{ barrageText(item) }}
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { handleAvatarImageError } from '@/utils/imageHandler.js'
const { locale, t } = useI18n()
const props = defineProps({
barrageList: {
type: Array,
required: true,
default: () => [],
},
speed: {
type: Number,
default: 80, //
},
maxItems: {
type: Number,
default: 4, //
},
loopInterval: {
type: Number,
default: 2000, // (ms)
},
})
const tracks = ref([[], []]) //
const idCounter = ref(0) // ID
const currentIndex = ref(0) //
//
const visibleTracks = computed(() => tracks.value.filter((track) => track.length > 0))
//
const barrageText = (item) => {
const params = { nickname: item.nickname, prizeName: item.prizeName }
return item.prizeType == 'GOLD' || item.prizeType == 'MONEY'
? t('barrage_won_prize', params)
: t('barrage_won_the_prize', params)
}
//
const getBarrageStyle = (item) => {
const isRTL = locale.value === 'ar'
return {
animationDuration: `${item.duration}s`,
animationDelay: `${item.delay}s`,
'--start-pos': `${item.startPos}px`,
border: item.prizeType == 'MONEY' ? '1px solid #FFF1B2' : '1px solid #BAD0FF',
background:
item.prizeType == 'MONEY'
? 'linear-gradient(270deg, rgba(255, 222, 77, 0.65) 0%, rgba(117, 95, 0, 0.20) 93.75%)'
: 'linear-gradient(270deg, rgba(103, 152, 255, 0.65) 0%, rgba(32, 77, 173, 0.20) 93.75%)',
// RTL
...(isRTL
? {
right: '0',
left: 'auto',
transform: 'translateX(-100vw)',
}
: {
left: '0',
right: 'auto',
transform: 'translateX(100vw)',
}),
}
}
//
const generateBarrageProps = (item) => {
const textLength = barrageText(item).length
return {
duration: Math.max(8 - textLength * 0.2, 5) * (100 / props.speed), // 0.25
startPos: Math.floor(Math.random() * 21) - 10, // -1010
}
}
//
const addToTrack = (item) => {
//
const trackIndex = tracks.value.reduce(
(minIndex, track, index) => (track.length < tracks.value[minIndex].length ? index : minIndex),
0,
)
if (tracks.value[trackIndex].length < props.maxItems) {
tracks.value[trackIndex].push({
...item,
id: idCounter.value++, //
delay: Math.random() * 4, // 0-4
...generateBarrageProps(item),
})
}
}
//
const cleanCompleted = () => {
tracks.value.forEach((track) => {
for (let i = track.length - 1; i >= 0; i--) {
if (track[i].completed) {
track.splice(i, 1)
}
}
})
}
//
const handleAnimationEnd = (id) => {
tracks.value.forEach((track) => {
const item = track.find((item) => item.id === id)
if (item) item.completed = true
})
}
//
const getNextBarrage = () => {
if (props.barrageList.length === 0) return null
const item = props.barrageList[currentIndex.value] //
currentIndex.value = (currentIndex.value + 1) % props.barrageList.length //0
return { ...item } //
}
//
let barrageInterval = null
//
const startBarrage = () => {
barrageInterval = setInterval(() => {
cleanCompleted() //
const nextBarrage = getNextBarrage() //
if (nextBarrage) {
addToTrack(nextBarrage) //
}
}, props.loopInterval)
}
onMounted(() => {
startBarrage() //
})
onUnmounted(() => {
clearInterval(barrageInterval) //
})
//
watch(
() => props.barrageList,
(newList) => {
currentIndex.value = 0 //
clearInterval(barrageInterval) //
//
if (newList.length !== 0) {
startBarrage() //
}
},
{ deep: true },
)
</script>
<style scoped>
/* 样式保持不变(同之前版本) */
.barrage-item {
will-change: transform;
animation: moveLeft linear forwards;
}
@keyframes moveLeft {
0% {
transform: translateX(100vw);
}
100% {
transform: translateX(-100%);
}
}
/* RTL支持 - 镜像弹幕动画 */
[dir='rtl'] .barrage-item {
animation: moveRight linear forwards;
}
@keyframes moveRight {
0% {
transform: translateX(-100vw);
}
100% {
transform: translateX(100%);
}
}
@media screen and (max-width: 360px) {
* {
font-size: 10px;
}
}
@media screen and (min-width: 360px) {
* {
font-size: 14px;
}
}
@media screen and (min-width: 768px) {
* {
font-size: 24px;
}
}
@media screen and (min-width: 1024px) {
* {
font-size: 32px;
}
}
</style>

View File

@ -0,0 +1,284 @@
<template>
<div style="width: 100%">
<div style="position: relative">
<img
v-smart-img
:src="BorderImgUrl"
alt=""
width="100%"
style="display: block; position: relative; z-index: 2"
/>
<!-- 头像 -->
<div
style="
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 1;
display: flex;
justify-content: center;
align-items: center;
"
:style="{ height: avatarContainerHeight }"
>
<div :style="{ width: avatarWidth }">
<img
:src="avatarUrl || ''"
alt=""
width="100%"
style="display: block; border-radius: 50%; aspect-ratio: 1/1; object-fit: cover"
@error="handleAvatarImageError"
/>
</div>
</div>
<!-- 用户名和贡献值 -->
<div
style="
position: absolute;
bottom: 0;
left: 0;
right: 0;
z-index: 3;
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
"
:style="{ height: bottomSectionHeight }"
>
<div
style="display: flex; justify-content: center; align-items: center"
:style="{
width: nameValueWidth,
height: nameValueHeight,
}"
>
<div style="font-weight: 700" class="showText" :class="isTopOne ? 'top1Text' : 'text'">
{{ name }}
</div>
</div>
<div
style="
padding: 1px 2px;
display: flex;
justify-content: center;
align-items: center;
"
:style="{
width: distributionValueWidth,
height: distributionValueHeight,
}"
>
<div
style="font-weight: 590"
class="showText"
:class="isTopOne ? 'top1Text' : 'text'"
:style="{
color: ranking == '1' ? `#FFE601` : '#FFF',
}"
>
${{ distributionValue }}
</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { handleAvatarImageError } from '@/utils/imageHandler.js'
import { computed } from 'vue'
const props = defineProps({
ranking: {
type: String,
default: '',
},
avatarUrl: {
type: String,
default: '',
},
BorderImgUrl: {
type: String,
required: true,
},
name: {
type: String,
default: '',
},
distributionValue: {
type: String,
default: '',
},
})
//
const isTopOne = computed(() => {
return props.ranking === '1'
})
//
const avatarContainerHeight = computed(() => {
switch (props.ranking) {
case '1':
return '70%'
case '2':
return '60%'
case '3':
return '60%'
default:
return '60%'
}
})
//
const avatarWidth = computed(() => {
switch (props.ranking) {
case '1':
return '43%'
case '2':
return '77%'
case '3':
return '77%'
default:
return '77%'
}
})
//
const bottomSectionHeight = computed(() => {
switch (props.ranking) {
case '1':
return '35%'
case '2':
return '39%'
case '3':
return '40%'
default:
return '39%'
}
})
//
const nameValueWidth = computed(() => {
switch (props.ranking) {
case '1':
return '30%'
case '2':
return '60%'
case '3':
return '60%'
default:
return '60%'
}
})
//
const nameValueHeight = computed(() => {
switch (props.ranking) {
case '1':
return '25%'
case '2':
return '25%'
case '3':
return '25%'
default:
return '25%'
}
})
//
const distributionValueWidth = computed(() => {
switch (props.ranking) {
case '1':
return '25%'
case '2':
return '40%'
case '3':
return '40%'
default:
return '40%'
}
})
//
const distributionValueHeight = computed(() => {
switch (props.ranking) {
case '1':
return '35%'
case '2':
return '20%'
case '3':
return '20%'
default:
return '20%'
}
})
//
const coinWidth = computed(() => {
switch (props.ranking) {
case '1':
return '1em'
case '2':
return '0.9em'
case '3':
return '0.9em'
default:
return '0.9em'
}
})
</script>
<style lang="scss" scoped>
* {
color: black;
}
.showText {
color: #fff;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.top1Text {
font-size: 0.75em;
}
.text {
font-size: 0.6em;
}
@media screen and (max-width: 360px) {
* {
font-size: 10px;
}
}
@media screen and (min-width: 360px) {
* {
font-size: 16px;
}
}
@media screen and (min-width: 768px) {
* {
font-size: 24px;
}
}
@media screen and (min-width: 1024px) {
* {
font-size: 32px;
}
}
</style>

File diff suppressed because it is too large Load Diff