feat(春节活动页面): 调整接口,设置预加载未成功每10s刷新一次页面

This commit is contained in:
hzj 2026-02-10 19:30:11 +08:00
parent 14d33b15b8
commit 92cc25ac07
4 changed files with 149 additions and 37 deletions

View File

@ -8,4 +8,4 @@ VITE_APP_TITLE=Azizi H5 (Development)
#VITE_USER_AUTH=EB4BAD4C6439CF503B16267C712F5AB6.djIlM0ExOTU3MzQ1MzEyOTYxNTI3ODA5JTNBTElLRUklM0ExNzU4Mjc4MDEzNzQ0JTNBMTc1NTY4NjAxMzc0NA==
# 代理用户 8826603
VITE_USER_AUTH=F7D59165057DB9913571DF5A6C9B014B.djIlM0ExOTkwNjg1NTY1MzMzNTkwMDE3JTNBTElLRUklM0ExNzcxNTYwNTI4NTc1JTNBMTc2ODk2ODUyODU3NQ==
VITE_USER_AUTH=45C34ABC2A47CB323383D9E78175DB2D.djIlM0ExOTkwNjg1NTY1MzMzNTkwMDE3JTNBTElLRUklM0ExNzcyNzgyNTI1MjIzJTNBMTc3MDE5MDUyNTIyMw==

View File

@ -9,7 +9,7 @@
>
<!-- 奖励列表 -->
<div
v-for="(reward, rewardIndex) in rewardsTop.rewardProps"
v-for="(reward, rewardIndex) in rewardsTop.propsGroup.activityRewardProps"
:key="rewardIndex"
style="
width: 100%;

View File

@ -768,6 +768,7 @@ const barrageText = (item) => {
const scrollWrapper = ref(null) //
watch(luckyUsers, async () => {
if (luckyUsers.value == [] || !scrollWrapper.value) return
await nextTick()
let retryCount = 0 //
@ -779,17 +780,17 @@ watch(luckyUsers, async () => {
if (!wrapper) return
const contentWidth = wrapper.scrollWidth
console.log('luckyUsers 更新后的宽度:', contentWidth)
// console.log('luckyUsers :', contentWidth)
if (contentWidth === 0) {
retryCount++
if (retryCount <= maxRetries) {
console.warn(`宽度为 0${retryCount} 次重试...`)
// console.warn(` 0 ${retryCount} ...`)
//
if (timerId) clearTimeout(timerId)
timerId = setTimeout(calculateWidth, 500) //
} else {
console.error('重试次数已达上限,未能获取有效宽度')
// console.error('')
}
} else {
//

View File

@ -628,6 +628,7 @@ import {
activityDetail, //
ranklist, //
activityRewardConfigs, //
apiGiftsRankingRewardConfigs, // .
winnerHistory, //
withdrawableAmount, //
} from '@/api/lottery'
@ -697,6 +698,7 @@ const currentLangType = computed(() => {
})
const isLoading = ref(true) //
const timeoutId = ref(null) // ID
// OSSURL
const imageUrl = (filename) => getPngUrl('Activities/SpringFestival/', filename)
@ -949,7 +951,7 @@ const getMyLotteryTicketCount = async () => {
//
const getWinners = async () => {
const resWinners = await winnerHistory()
const resWinners = await winnerHistory('2007771533988204877')
if (resWinners.status && resWinners.body) {
luckyUsers.value = resWinners.body
}
@ -1098,42 +1100,53 @@ const getRanking = async (rankingType = 'lottery') => {
//
const getGameReward = async () => {
let data = {
activityType: 'CONSUMPTION_ACTIVITY',
activityId: '2007771533988204877',
}
const resActivityReward = await activityRewardConfigs(data)
const resActivityReward = await apiGiftsRankingRewardConfigs()
if (resActivityReward.status && resActivityReward.body) {
let tempList = resActivityReward.body.filter((_, index) => index <= 3)
rankingRewards.value = tempList.map((rewards) => {
let jsonData = JSON.parse(rewards.jsonData)
rankingRewards.value = resActivityReward.body.map((rewards) => {
let addReward = []
if (rewards.sort == 1) {
if (rewards.rule.sort == 1) {
addReward = [
{
type: 'TICKET',
cover: imageUrl('ticket'),
content: 10,
type: 'DOLLARS',
cover: '',
content: 100,
},
{
type: 'TICKET',
cover: imageUrl('ticket'),
content: 10,
type: 'GIFT',
cover: imageUrl('IDReward'),
content: 'ID: XXXX',
},
]
} else if (rewards.rule.sort == 2) {
addReward = [
{
type: 'TICKET',
cover: imageUrl('ticket'),
type: 'DOLLARS',
cover: '',
content: 50,
},
]
} else if (rewards.rule.sort == 3) {
addReward = [
{
type: 'DOLLARS',
cover: '',
content: 30,
},
]
} else if (rewards.rule.sort == 4) {
addReward = [
{
type: 'DOLLARS',
cover: '',
content: 10,
},
]
}
rewards.rewardProps.push(...addReward) //
rewards.propsGroup.activityRewardProps.push(...addReward) //
rewards = {
...rewards,
...jsonData,
}
return rewards
})
@ -1146,7 +1159,7 @@ const getGameReward = async () => {
const getRechargeReward = async () => {
let data = {
activityType: 'CONSUMPTION_ACTIVITY',
activityId: '2007771533988204877',
activityId: '2007771533988204888',
}
const resActivityReward = await activityRewardConfigs(data)
if (resActivityReward.status && resActivityReward.body) {
@ -1234,11 +1247,36 @@ const initData = async () => {
//
const preloadCriticalImages = async () => {
const criticalImages = [
// //
// imageUrl('bg1'),
// //
// imageUrl(getImgName('rankingBtActive')),
// imageUrl(getImgName('rankingBt')),
//
imageUrl('bg1'),
imageUrl('bg2'),
imageUrl('bg3'),
imageUrl('bg4'),
imageUrl('bg5'),
//
imageUrl('bg1'),
imageUrl('bg2-2'),
//
imageUrl('TimeBg'),
//
imageUrl(getImgName('TagGameBt')),
imageUrl(getImgName('TagRechargeBt')),
imageUrl(getImgName('MTaskBt')),
imageUrl(getImgName('MRankingBt')),
imageUrl(getImgName('MRewardBt')),
//
imageUrl('taskListBg'),
imageUrl('taskItemBg'),
imageUrl('taskTypeGift'),
imageUrl('taskTypeGame'),
imageUrl('ticket'),
imageUrl('taskBtGo'),
imageUrl('taskBtReceive'),
imageUrl('taskBtReceived'),
]
await preloadImages(criticalImages)
@ -1248,7 +1286,10 @@ const preloadCriticalImages = async () => {
const completePreloading = async () => {
try {
//
await Promise.all([initData(), preloadCriticalImages()])
await Promise.all([
// initData(),
preloadCriticalImages(),
])
console.log('预加载完成,初始化数据成功')
} catch (error) {
console.error('预加载过程中发生错误:', error)
@ -1260,7 +1301,52 @@ const completePreloading = async () => {
//
const preloadOtherImages = async () => {
const criticalImages = []
const criticalImages = [
//
imageUrl('myRankingBg'),
imageUrl('rankingNumBg'),
imageUrl('userFrame'),
//
imageUrl('resultBg'),
imageUrl('resultBack'),
imageUrl('resultNext'),
//
imageUrl('recordBg'),
// help
imageUrl(getImgName('helpInfo')),
//
imageUrl('lotteryBg'),
imageUrl('historyBt'),
imageUrl('prizeActiveFrame'),
imageUrl('ticket'),
imageUrl('earningInfoBg'),
//
imageUrl('top1Bg'),
imageUrl('top2Bg'),
imageUrl('top3Bg'),
imageUrl('rankingNumBg'),
imageUrl('rankingItemBg'),
//
imageUrl('rankingRewardTop1Bg'),
imageUrl('rankingRewardTop2Bg'),
imageUrl('rankingRewardTop3Bg'),
imageUrl('rankingRewardTop4Bg'),
//
imageUrl('receiveBt'),
imageUrl('rechargeReward100'),
imageUrl('rechargeReward500'),
imageUrl('rechargeReward1000'),
imageUrl('rechargeReward3000'),
imageUrl('rechargeReward5000'),
imageUrl('rechargeReward10000'),
]
await preloadImages(criticalImages)
}
@ -1273,8 +1359,26 @@ const connectToAppHandler = async () => {
})
}
//
const startTimeoutCheck = () => {
timeoutId.value = setTimeout(() => {
if (isLoading.value) {
console.warn('⏰ 预加载超时,正在刷新页面...')
window.location.reload() //
}
}, 20000) // 20
}
//
const clearTimeoutCheck = () => {
if (timeoutId.value) {
clearTimeout(timeoutId.value)
timeoutId.value = null
}
}
//
onMounted(() => {
onMounted(async () => {
springFestivalStore.clear()
checkShow() //
@ -1287,7 +1391,12 @@ onMounted(() => {
changeTag('gamePlay')
changeModule('task')
}
connectToAppHandler()
//
startTimeoutCheck()
await connectToAppHandler()
initData()
preloadOtherImages() //
startCountdown() //
})
@ -1299,6 +1408,8 @@ onUnmounted(() => {
clearInterval(countdownTimer)
countdownTimer = null
}
clearTimeoutCheck() //
clearPayee() //
})
</script>
@ -1315,7 +1426,7 @@ onUnmounted(() => {
.fullPage {
width: 100vw;
min-height: 100vh;
background: #ff79a1;
background: #da4302;
position: relative;
}