feat(抽奖活动页): 新增倒计时,暂时设置截止日期为2025.11.10 10:00:00

This commit is contained in:
hzj 2025-11-06 16:00:21 +08:00
parent 6bc3aa5d2b
commit bb1bef2246
2 changed files with 77 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@ -9,6 +9,26 @@
<!-- 弹幕 -->
<Barrage class="barrage-container" style="width: 100vw" :barrageList="barrageList"></Barrage>
<!-- 倒计时 -->
<div style="position: relative; padding: 10px 0">
<img :src="images.countdownBg" alt="" width="100%" style="display: block" />
<div
style="
position: absolute;
inset: 0;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.2em;
font-weight: 700;
letter-spacing: 2px;
"
>
{{ formattedCountdown }}
</div>
</div>
<!-- 模块切换按钮 -->
<div style="display: flex; justify-content: space-around">
<div style="width: 30%" @click="handleBt('Rank')">
@ -935,8 +955,12 @@ const withdrawShow = ref(false)
const selectedCoin = ref(null)
const appConnected = ref(false)
const headerInfo = ref({})
//
const Days = ref(0)
const Hours = ref(0)
const Minutes = ref(0)
const Seconds = ref(0)
let countdownTimer = null
//
const drawerShowBt = (type) => {
@ -955,6 +979,52 @@ const handleBt = (type) => {
selectedCoin.value = null //
}
// 2025111010
const getTargetTime = () => {
// 2025111010
const target = new Date(2025, 10, 10, 10, 0, 0) // 01011
return target.getTime()
}
//
const calculateCountdown = () => {
const now = Date.now()
const targetTime = getTargetTime()
let diff = targetTime - now
//
if (diff <= 0) {
Days.value = 0
Hours.value = '00'
Minutes.value = '00'
Seconds.value = '00'
if (countdownTimer) {
clearInterval(countdownTimer)
countdownTimer = null
}
return
}
//
const totalSeconds = Math.floor(diff / 1000)
Days.value = Math.floor(totalSeconds / (24 * 3600))
Hours.value = String(Math.floor((totalSeconds % (24 * 3600)) / 3600)).padStart(2, '0')
Minutes.value = String(Math.floor((totalSeconds % 3600) / 60)).padStart(2, '0')
Seconds.value = String(Math.floor(totalSeconds % 60)).padStart(2, '0')
}
//
const formattedCountdown = computed(() => {
return `${Days.value}D ${Hours.value}:${Minutes.value}:${Seconds.value}`
})
//
const startCountdown = () => {
calculateCountdown() //
countdownTimer = setInterval(calculateCountdown, 1000)
}
const taskList = ref([])
//
@ -1363,6 +1433,7 @@ const connectToAppHandler = async () => {
await connectToApp(() => {
//
initData()
startCountdown() //
})
}
@ -1372,6 +1443,10 @@ onMounted(() => {
})
onUnmounted(() => {
if (countdownTimer) {
clearInterval(countdownTimer)
countdownTimer = null
}
clearPayee() //
})
</script>