feat(革命节和英雄节): 取消历史榜首、设置截止日期、对接正确接口

This commit is contained in:
hzj 2025-11-06 19:19:36 +08:00
parent bb1bef2246
commit 155fd86684
3 changed files with 169 additions and 602 deletions

39
src/api/activity.js Normal file
View File

@ -0,0 +1,39 @@
import { get, post } from '../utils/http.js'
// 获取排行榜和我的排名
export const getRankingListAndMyRanking = async (activityType) => {
try {
let data = { activityType }
const response = await post(`/ranking/list`, data)
return response
} catch (error) {
console.error('Failed to get list and my ranking:', error)
console.error('error:' + error.response.errorMsg)
throw error
}
}
// 获取本周奖励和礼物
export const getThisWeekRewardsAndGifts = async (activityId) => {
try {
const response = await get(`/activity/king-queen/effective?templateId=${activityId}`)
return response
} catch (error) {
console.error('Failed to get this week rewards and gifts:', error)
console.error('error:' + error.response.errorMsg)
throw error
}
}
// 获取历史榜首
export const getHistoryTopOne = async (activityType) => {
try {
let data = { activityType }
const response = await post(`/ranking/historical-top1`, data)
return response
} catch (error) {
console.error('Failed to get history top one:', error)
console.error('error:' + error.response.errorMsg)
throw error
}
}

View File

@ -6,28 +6,19 @@
<div v-if="isInAppEnvironment" style="height: 30px"></div>
<!-- 按钮 -->
<div
style="
margin-top: 100vw;
display: flex;
justify-content: space-between;
align-items: center;
"
>
<!-- 历史榜首按钮 -->
<img
:src="images.history"
alt=""
style="display: block; width: 20%"
@click="historyShow = true"
/>
<div style="display: flex; justify-content: flex-end; align-items: center">
<!-- 帮助按钮 -->
<img
:src="images.help"
alt=""
style="display: block; width: 10%; margin-right: 8px"
@click="helpInfoShow = true"
style="
display: block;
margin-top: 100vw;
position: relative;
width: 10%;
margin-right: 8px;
"
@click="maskLayerShow = true"
/>
</div>
@ -156,8 +147,8 @@
<div style="display: flex; justify-content: center">
<TopUser
:BorderImgUrl="images.topOne"
:avatarUrl="RankingHasTop3[0].userAvatar"
:name="RankingHasTop3[0].userNickname"
:avatarUrl="RankingHasTop3[0].avatar"
:name="RankingHasTop3[0].nickname"
:distributionValue="RankingHasTop3[0].quantity"
style="width: 43%"
@click="viewUserInfo(RankingHasTop3[0].userId)"
@ -168,8 +159,8 @@
<TopUser
:isTopOne="false"
:BorderImgUrl="images.topTwo"
:avatarUrl="RankingHasTop3[1].userAvatar"
:name="RankingHasTop3[1].userNickname"
:avatarUrl="RankingHasTop3[1].avatar"
:name="RankingHasTop3[1].nickname"
:distributionValue="RankingHasTop3[1].quantity"
style="width: 30%"
@click="viewUserInfo(RankingHasTop3[1].userId)"
@ -177,8 +168,8 @@
<TopUser
:isTopOne="false"
:BorderImgUrl="images.topThree"
:avatarUrl="RankingHasTop3[2].userAvatar"
:name="RankingHasTop3[2].userNickname"
:avatarUrl="RankingHasTop3[2].avatar"
:name="RankingHasTop3[2].nickname"
:distributionValue="RankingHasTop3[2].quantity"
style="width: 30%"
@click="viewUserInfo(RankingHasTop3[2].userId)"
@ -212,7 +203,7 @@
{{ listItem.rank }}
</div>
<img
:src="listItem.userAvatar || ''"
:src="listItem.avatar || ''"
alt=""
style="
width: 20%;
@ -242,7 +233,7 @@
"
class="UserNickname"
>
{{ listItem.userNickname }}
{{ listItem.nickname }}
</div>
<div style="color: #fff; font-weight: 590" class="UserNickname">
ID:{{ listItem.account }}
@ -258,8 +249,6 @@
</div>
</div>
</div>
<!-- 触发加载功能 -->
<div ref="RankingLoadmore" v-show="showRankingLoading && rankingShow"></div>
<!-- 底框 -->
<img
@ -282,7 +271,11 @@
style="position: relative; width: 90%; margin-bottom: 20px"
>
<div style="position: relative">
<img :src="topImg[Number(top)]" alt="" style="width: 100%; margin: 24px 0" />
<img
:src="topImg[Number(rewardsTop.rankRange) - 1]"
alt=""
style="width: 100%; margin: 24px 0"
/>
<div
style="
position: absolute;
@ -294,7 +287,7 @@
"
>
<div
v-for="(reward, rewardIndex) in rewardsTop.propsGroup.activityRewardProps"
v-for="(reward, rewardIndex) in rewardsTop.rewards"
:key="rewardIndex"
style="width: 100%"
>
@ -323,7 +316,7 @@
</div>
<div style="color: rgba(255, 255, 255, 1); font-weight: 590; text-align: center">
{{ showDetail(reward.type, reward.quantity) }}
{{ showDetail(reward.type, reward) }}
</div>
</div>
</div>
@ -368,7 +361,7 @@
<div style="color: #edb247; font-weight: 700">{{ myRanking.rank || 999 }}</div>
<!-- 头像 -->
<img
:src="myRanking.userAvatar || ''"
:src="myRanking.avatar || ''"
alt=""
style="
display: block;
@ -392,7 +385,7 @@
"
class="UserNickname"
>
{{ myRanking.userNickname }}
{{ myRanking.nickname }}
</div>
</div>
</div>
@ -408,104 +401,11 @@
</div>
<!-- 弹窗遮罩层 -->
<maskLayer :maskLayerShow="maskLayerShow" @click="closedPopup">
<maskLayer :maskLayerShow="maskLayerShow" @click="maskLayerShow = false">
<!-- help弹窗 -->
<div v-if="helpInfoShow" style="margin: 20% 0" @click.stop>
<div style="margin: 20% 0" @click.stop>
<img :src="images.helpInfo" alt="" style="width: 100%" />
</div>
<!-- history弹窗 -->
<div v-if="historyShow" style="position: relative; margin: 20% 0" @click.stop>
<!-- 背景图 -->
<img :src="images.historyBg" alt="" style="width: 100%; display: block" />
<!-- 内容 -->
<div
style="
position: absolute;
inset: 0;
padding: 17% 5% 10%;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
"
>
<div style="position: relative; width: 75%">
<!-- 头像框 -->
<img
:src="images.topOneHistory"
alt=""
style="width: 100%; display: block; position: relative; z-index: 1"
/>
<div style="position: absolute; inset: 0">
<div
style="height: 100%; display: flex; justify-content: center; align-items: center"
>
<img
:src="showTopOne.userAvatar || ''"
alt=""
style="
width: 50%;
display: block;
border-radius: 50%;
aspect-ratio: 1/1;
object-fit: cover;
"
@error="defaultAvatarUrl"
/>
</div>
<!-- 名字 -->
<div
style="
width: 100%;
position: absolute;
left: 0;
right: 0;
bottom: 10vw;
z-index: 2;
display: flex;
justify-content: center;
"
>
<div
style="
width: 25%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
"
class="history-name"
>
{{ showTopOne.userNickname }}
</div>
</div>
</div>
</div>
<!-- 历史时间 -->
<div
style="width: 50%; display: flex; justify-content: space-between; align-items: center"
>
<img :src="images.backGift" alt="" width="13%" @click="changeHistoryIndex(1)" />
<div
style="
flex: 1;
text-align: center;
font-weight: 590;
background: linear-gradient(180deg, #00f331 0%, #c6ffc6 100%);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
"
class="history-time"
>
{{ showTopOne.group }}
</div>
<img :src="images.nextGift" alt="" width="13%" @click="changeHistoryIndex(-1)" />
</div>
</div>
</div>
</maskLayer>
</div>
</div>
@ -517,15 +417,8 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
import itemCenter from '@/components/WeeklyStar/itemCenter.vue'
import TopUser from '../RevolutionUnityDay/topUser.vue'
import maskLayer from '@/components/MaskLayer.vue'
import { useDebounce, useThrottle } from '@/utils/useDebounce'
import { getMemberProfile } from '@/api/wallet'
import {
getWeekStarRanking,
getWeekRewards,
getWeekGifts,
getMyWeekStarRanking,
getHistoryTopOne,
} from '@/api/weeklyStar.js'
import { getThisWeekRewardsAndGifts, getRankingListAndMyRanking } from '@/api/activity.js'
import { connectToApp } from '@/utils/appConnector.js'
// vite
@ -540,16 +433,8 @@ const images = Object.fromEntries(
})
)
const userInfo = ref({})
const isInAppEnvironment = ref(false) // APP
const helpInfoShow = ref(false) //
const historyShow = ref(false) //
//
const maskLayerShow = computed(() => {
return helpInfoShow.value || historyShow.value
})
const maskLayerShow = ref(false) //
//
const Days = ref(0)
@ -561,39 +446,13 @@ let timer = null
//
const rankingShow = ref(true) //
const current = ref(1) //
const RankingLoadmore = ref(null) //
const showRankingLoading = ref(true) //
const Ranking = ref([]) //
const RankingLoadParams = computed(() => {
return {
type: 'THIS_WEEK',
current: current.value,
size: 10,
}
})
const myRanking = ref([]) //
const myRanking = ref({}) //
const rewardsList = ref([]) //
const gifts = ref([]) //
const historyRankingTop1 = ref([]) //
const historyIndex = ref(0)
const showTopOne = computed(() => {
return historyRankingTop1.value[historyIndex.value] || {}
})
const topImg = ref([images.top1RewardBg, images.top2RewardBg, images.top3RewardBg]) // top
const changeHistoryIndex = (num) => {
let targetIndex = historyIndex.value + num
let length = historyRankingTop1.value.length
if (targetIndex >= 0 && targetIndex < length) {
historyIndex.value = targetIndex
}
}
// 3
const RankingHasTop3 = computed(() => {
let RankingShow = [...Ranking.value]
@ -629,27 +488,13 @@ const defaultAvatarUrl = (e) => {
e.target.src = new URL('/src/assets/images/WeeklyStar/defaultAvatar.png', import.meta.url).href
}
//
const closedPopup = () => {
helpInfoShow.value = false
historyShow.value = false
// 2025111410
const getTargetTime = () => {
const targetDate = new Date(2025, 10, 14, 10, 0, 0) // 01011
return targetDate.getTime()
}
//
const getNextMondayInSaudi = () => {
const now = new Date()
const utcDay = now.getUTCDay() //UTC0()-6()
//
const daysToAdd = utcDay === 1 ? 7 : (1 + 7 - utcDay) % 7
const nextMondayUTC = new Date(now) //UTC
nextMondayUTC.setUTCDate(now.getUTCDate() + daysToAdd) //
nextMondayUTC.setUTCHours(0, 0, 0, 0) // 63
return nextMondayUTC.getTime() //00:00:00.000
}
const targetTime = ref(getNextMondayInSaudi()) // ()
const targetTime = ref(getTargetTime())
//
const formatTime = (value) => {
@ -661,12 +506,19 @@ const getCountdown = () => {
const now = Date.now()
let diff = targetTime.value - now
//
if (diff <= 0) {
//
getUserInfo()
resetPage()
targetTime.value += 7 * 86400000 // +7 ()
diff = targetTime.value - now
Days.value = 0
Hours.value = '00'
Minutes.value = '00'
Second.value = '00'
//
if (timer) {
clearInterval(timer)
timer = null
}
return
}
const totalSeconds = Math.floor(diff / 1000)
@ -676,119 +528,41 @@ const getCountdown = () => {
Second.value = formatTime(Math.floor(totalSeconds % 60))
}
//
const resetPage = () => {
current.value = 1 //
showRankingLoading.value = true //
Ranking.value = [] //
historyIndex.value = 0 //
initData() //
}
//
const showDetail = (type, quantity) => {
const showDetail = (type, reward) => {
let showamount = ['GOLD', 'DIAMOND', 'GIFT', 'FRAGMENTS']
if (showamount.includes(type)) {
return quantity
return reward.content
} else {
return `${quantity}Days`
return `${reward.quantity}Days`
}
}
//
const getUserInfo = async () => {
if (Object.keys(userInfo.value).length === 0) {
const resUserInfo = await getMemberProfile()
if (resUserInfo.status && resUserInfo.body) {
userInfo.value = resUserInfo.body
}
}
getMyThisWeekRanking() //
}
//
const getThisWeekRanking = async () => {
const resWeekStarRanking = await getWeekStarRanking(RankingLoadParams.value)
console.log('resWeekStarRanking:', resWeekStarRanking)
if (
resWeekStarRanking.status &&
resWeekStarRanking.body &&
resWeekStarRanking.body.rankUsers?.records
) {
let rankUsers = resWeekStarRanking.body.rankUsers
Ranking.value.push(...rankUsers.records)
if (current.value * rankUsers.size >= rankUsers.total) {
showRankingLoading.value = false
}
}
}
//
const getHistoryRankingTop1 = async () => {
const resHistoryTopOne = await getHistoryTopOne()
console.log('resHistoryTopOne:', resHistoryTopOne)
if (resHistoryTopOne.status && resHistoryTopOne.body) {
historyRankingTop1.value = resHistoryTopOne.body
}
}
//
const getMyThisWeekRanking = async () => {
let data = {
userId: userInfo.value.id,
type: 'THIS_WEEK',
}
const resMyWeekStarRanking = await getMyWeekStarRanking(data)
//
const getListAndMy = async () => {
const resMyWeekStarRanking = await getRankingListAndMyRanking(1)
console.log('resMyWeekStarRanking:', resMyWeekStarRanking)
if (resMyWeekStarRanking.status && resMyWeekStarRanking.body) {
myRanking.value = resMyWeekStarRanking.body
myRanking.value = resMyWeekStarRanking.body.currentUserRank
Ranking.value = resMyWeekStarRanking.body.rankingList
}
}
//
const getThisWeekGifts = async () => {
const resThisWeekGifts = await getWeekGifts('THIS_WEEK')
console.log('resThisWeekGifts:', resThisWeekGifts)
if (resThisWeekGifts.status && resThisWeekGifts.body) {
gifts.value = resThisWeekGifts.body
}
}
//
const getThisWeekRewards = async () => {
const resThisWeekRewards = await getWeekRewards()
console.log('resThisWeekRewards:', resThisWeekRewards)
if (resThisWeekRewards.status && resThisWeekRewards.body) {
rewardsList.value = resThisWeekRewards.body
//
const getRewardsAndGifts = async () => {
const resRewardsAndGifts = await getThisWeekRewardsAndGifts('1986033416841801729')
if (resRewardsAndGifts.status && resRewardsAndGifts.body) {
gifts.value = resRewardsAndGifts.body.gifts
rewardsList.value = resRewardsAndGifts.body.butOneRewards
}
}
//
const initData = () => {
getUserInfo()
getThisWeekRanking() //
getHistoryRankingTop1() // top1
getThisWeekRewards() //
getThisWeekGifts() //
getListAndMy() //
getRewardsAndGifts() //
}
const debouceGetThisWeekRanking = useThrottle(() => {
getThisWeekRanking()
}, 1000)
// IntersectionObserver
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio > 0 && Ranking.value.length != 0) {
console.log('触发RankingLoadmore加载')
current.value++
debouceGetThisWeekRanking()
}
})
})
// 使APP
const connectToAppHandler = async () => {
await connectToApp(() => {
@ -803,12 +577,7 @@ onMounted(() => {
isInAppEnvironment.value = isInApp()
getCountdown()
timer = setInterval(getCountdown, 1000) //
//
if (RankingLoadmore.value) {
observer.observe(RankingLoadmore.value)
}
timer = setInterval(getCountdown, 1000) //
})
onUnmounted(() => {

View File

@ -1,4 +1,4 @@
<!-- src/views/Activities/RevolutionUnityDay/index.vue -->
<!-- src/views/Activities/heroesDay/index.vue -->
<template>
<div class="fullPage">
<div class="bg">
@ -6,23 +6,13 @@
<div v-if="isInAppEnvironment" style="height: 30px"></div>
<!-- 按钮 -->
<div
style="margin-top: 60vw; display: flex; justify-content: space-between; align-items: center"
>
<!-- 历史榜首按钮 -->
<img
:src="images.history"
alt=""
style="display: block; width: 20%"
@click="historyShow = true"
/>
<div style="margin-top: 80vw; display: flex; justify-content: flex-end; align-items: center">
<!-- 帮助按钮 -->
<img
:src="images.help"
alt=""
style="display: block; width: 10%; margin-right: 8px"
@click="helpInfoShow = true"
style="display: block; position: relative; width: 10%; margin-right: 8px"
@click="maskLayerShow = true"
/>
</div>
@ -151,8 +141,8 @@
<div style="display: flex; justify-content: center">
<TopUser
:BorderImgUrl="images.topOne"
:avatarUrl="RankingHasTop3[0].userAvatar"
:name="RankingHasTop3[0].userNickname"
:avatarUrl="RankingHasTop3[0].avatar"
:name="RankingHasTop3[0].nickname"
:distributionValue="RankingHasTop3[0].quantity"
style="width: 43%"
@click="viewUserInfo(RankingHasTop3[0].userId)"
@ -162,20 +152,18 @@
<div style="display: flex; justify-content: space-between; margin-top: -20%">
<TopUser
:isTopOne="false"
ranking="2"
:BorderImgUrl="images.topTwo"
:avatarUrl="RankingHasTop3[1].userAvatar"
:name="RankingHasTop3[1].userNickname"
:avatarUrl="RankingHasTop3[1].avatar"
:name="RankingHasTop3[1].nickname"
:distributionValue="RankingHasTop3[1].quantity"
style="width: 30%"
@click="viewUserInfo(RankingHasTop3[1].userId)"
/>
<TopUser
:isTopOne="false"
ranking="3"
:BorderImgUrl="images.topThree"
:avatarUrl="RankingHasTop3[2].userAvatar"
:name="RankingHasTop3[2].userNickname"
:avatarUrl="RankingHasTop3[2].avatar"
:name="RankingHasTop3[2].nickname"
:distributionValue="RankingHasTop3[2].quantity"
style="width: 30%"
@click="viewUserInfo(RankingHasTop3[2].userId)"
@ -209,7 +197,7 @@
{{ listItem.rank }}
</div>
<img
:src="listItem.userAvatar || ''"
:src="listItem.avatar || ''"
alt=""
style="
width: 20%;
@ -239,7 +227,7 @@
"
class="UserNickname"
>
{{ listItem.userNickname }}
{{ listItem.nickname }}
</div>
<div style="color: #fff; font-weight: 590" class="UserNickname">
ID:{{ listItem.account }}
@ -255,8 +243,6 @@
</div>
</div>
</div>
<!-- 触发加载功能 -->
<div ref="RankingLoadmore" v-show="showRankingLoading && rankingShow"></div>
<!-- 底框 -->
<img
@ -279,7 +265,11 @@
style="position: relative; width: 90%; margin-bottom: 20px"
>
<div style="position: relative">
<img :src="topImg[Number(top)]" alt="" style="width: 100%; margin-top: 10px" />
<img
:src="topImg[Number(rewardsTop.rankRange) - 1]"
alt=""
style="width: 100%; margin: 24px 0"
/>
<div
style="
position: absolute;
@ -287,23 +277,16 @@
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
padding: 30vw 5vw 20vw;
padding: 25vw 5vw 15vw;
"
>
<div
v-for="(reward, rewardIndex) in rewardsTop.propsGroup.activityRewardProps"
v-for="(reward, rewardIndex) in rewardsTop.rewards"
:key="rewardIndex"
style="width: 100%"
>
<div
style="
position: relative;
display: flex;
flex-direction: column;
align-items: center;
"
>
<img :src="images.giftItemBg" style="" alt="" width="90%" />
<div style="position: relative">
<img :src="images.giftItemBg" style="" alt="" width="100%" />
<div
style="
position: absolute;
@ -327,7 +310,7 @@
</div>
<div style="color: rgba(255, 255, 255, 1); font-weight: 590; text-align: center">
{{ showDetail(reward.type, reward.quantity) }}
{{ showDetail(reward.type, reward) }}
</div>
</div>
</div>
@ -372,7 +355,7 @@
<div style="color: #edb247; font-weight: 700">{{ myRanking.rank || 999 }}</div>
<!-- 头像 -->
<img
:src="myRanking.userAvatar || ''"
:src="myRanking.avatar || ''"
alt=""
style="
display: block;
@ -396,7 +379,7 @@
"
class="UserNickname"
>
{{ myRanking.userNickname }}
{{ myRanking.nickname }}
</div>
</div>
</div>
@ -412,104 +395,11 @@
</div>
<!-- 弹窗遮罩层 -->
<maskLayer :maskLayerShow="maskLayerShow" @click="closedPopup">
<maskLayer :maskLayerShow="maskLayerShow" @click="maskLayerShow = false">
<!-- help弹窗 -->
<div v-if="helpInfoShow" style="margin: 20% 0" @click.stop>
<div style="margin: 20% 0" @click.stop>
<img :src="images.helpInfo" alt="" style="width: 100%" />
</div>
<!-- history弹窗 -->
<div v-if="historyShow" style="position: relative; margin: 20% 0" @click.stop>
<!-- 背景图 -->
<img :src="images.historyBg" alt="" style="width: 100%; display: block" />
<!-- 内容 -->
<div
style="
position: absolute;
inset: 0;
padding: 17% 5% 10%;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
"
>
<div style="position: relative; width: 75%">
<!-- 头像框 -->
<img
:src="images.topOneHistory"
alt=""
style="width: 100%; display: block; position: relative; z-index: 1"
/>
<div style="position: absolute; inset: 0">
<div
style="height: 100%; display: flex; justify-content: center; align-items: center"
>
<img
:src="showTopOne.userAvatar || ''"
alt=""
style="
width: 50%;
display: block;
border-radius: 50%;
aspect-ratio: 1/1;
object-fit: cover;
"
@error="defaultAvatarUrl"
/>
</div>
<!-- 名字 -->
<div
style="
width: 100%;
position: absolute;
left: 0;
right: 0;
bottom: 10vw;
z-index: 2;
display: flex;
justify-content: center;
"
>
<div
style="
width: 25%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
"
class="history-name"
>
{{ showTopOne.userNickname }}
</div>
</div>
</div>
</div>
<!-- 历史时间 -->
<div
style="width: 50%; display: flex; justify-content: space-between; align-items: center"
>
<img :src="images.backGift" alt="" width="13%" @click="changeHistoryIndex(1)" />
<div
style="
flex: 1;
text-align: center;
font-weight: 590;
background: linear-gradient(180deg, #f30000 0%, #ffc6c6 100%);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
"
class="history-time"
>
{{ showTopOne.group }}
</div>
<img :src="images.nextGift" alt="" width="13%" @click="changeHistoryIndex(-1)" />
</div>
</div>
</div>
</maskLayer>
</div>
</div>
@ -521,15 +411,8 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
import itemCenter from '@/components/WeeklyStar/itemCenter.vue'
import TopUser from '../heroesDay/topUser.vue'
import maskLayer from '@/components/MaskLayer.vue'
import { useDebounce, useThrottle } from '@/utils/useDebounce'
import { getMemberProfile } from '@/api/wallet'
import {
getWeekStarRanking,
getWeekRewards,
getWeekGifts,
getMyWeekStarRanking,
getHistoryTopOne,
} from '@/api/weeklyStar.js'
import { getThisWeekRewardsAndGifts, getRankingListAndMyRanking } from '@/api/activity.js'
import { connectToApp } from '@/utils/appConnector.js'
// vite
@ -544,16 +427,8 @@ const images = Object.fromEntries(
})
)
const userInfo = ref({})
const isInAppEnvironment = ref(false) // APP
const helpInfoShow = ref(false) //
const historyShow = ref(false) //
//
const maskLayerShow = computed(() => {
return helpInfoShow.value || historyShow.value
})
const maskLayerShow = ref(false) //
//
const Days = ref(0)
@ -565,46 +440,20 @@ let timer = null
//
const rankingShow = ref(true) //
const current = ref(1) //
const RankingLoadmore = ref(null) //
const showRankingLoading = ref(true) //
const Ranking = ref([]) //
const RankingLoadParams = computed(() => {
return {
type: 'THIS_WEEK',
current: current.value,
size: 10,
}
})
const myRanking = ref([]) //
const myRanking = ref({}) //
const rewardsList = ref([]) //
const gifts = ref([]) //
const historyRankingTop1 = ref([]) //
const historyIndex = ref(0)
const showTopOne = computed(() => {
return historyRankingTop1.value[historyIndex.value] || {}
})
const topImg = ref([images.top1RewardBg, images.top2RewardBg, images.top3RewardBg]) // top
const changeHistoryIndex = (num) => {
let targetIndex = historyIndex.value + num
let length = historyRankingTop1.value.length
if (targetIndex >= 0 && targetIndex < length) {
historyIndex.value = targetIndex
}
}
// 3
const RankingHasTop3 = computed(() => {
let RankingShow = [...Ranking.value]
if (Ranking.value.length < 3) {
let addNullUser = Array.from({ length: 3 - Ranking.value.length }, () => ({
userAvatar: '',
userNickname: '',
avatar: '',
nickname: '',
quantity: '',
}))
RankingShow.push(...addNullUser)
@ -633,27 +482,13 @@ const defaultAvatarUrl = (e) => {
e.target.src = new URL('/src/assets/images/WeeklyStar/defaultAvatar.png', import.meta.url).href
}
//
const closedPopup = () => {
helpInfoShow.value = false
historyShow.value = false
// 2025111810
const getTargetTime = () => {
const targetDate = new Date(2025, 10, 18, 10, 0, 0) // 01011
return targetDate.getTime()
}
// 西
const getNextMondayInSaudi = () => {
const now = new Date()
const utcDay = now.getUTCDay() //UTC0()-6()
//
const daysToAdd = utcDay === 1 ? 7 : (1 + 7 - utcDay) % 7
const nextMondayUTC = new Date(now) //UTC
nextMondayUTC.setUTCDate(now.getUTCDate() + daysToAdd) //
nextMondayUTC.setUTCHours(23, 0, 0, 0) // 西63
return nextMondayUTC.getTime() //00:00:00.000
}
const targetTime = ref(getNextMondayInSaudi()) // ()
const targetTime = ref(getTargetTime())
//
const formatTime = (value) => {
@ -665,12 +500,19 @@ const getCountdown = () => {
const now = Date.now()
let diff = targetTime.value - now
//
if (diff <= 0) {
//
getUserInfo()
resetPage()
targetTime.value += 7 * 86400000 // +7 ()
diff = targetTime.value - now
Days.value = 0
Hours.value = '00'
Minutes.value = '00'
Second.value = '00'
//
if (timer) {
clearInterval(timer)
timer = null
}
return
}
const totalSeconds = Math.floor(diff / 1000)
@ -680,119 +522,41 @@ const getCountdown = () => {
Second.value = formatTime(Math.floor(totalSeconds % 60))
}
//
const resetPage = () => {
current.value = 1 //
showRankingLoading.value = true //
Ranking.value = [] //
historyIndex.value = 0 //
initData() //
}
//
const showDetail = (type, quantity) => {
const showDetail = (type, reward) => {
let showamount = ['GOLD', 'DIAMOND', 'GIFT', 'FRAGMENTS']
if (showamount.includes(type)) {
return quantity
return reward.content
} else {
return `${quantity}Days`
return `${reward.quantity}Days`
}
}
//
const getUserInfo = async () => {
if (Object.keys(userInfo.value).length === 0) {
const resUserInfo = await getMemberProfile()
if (resUserInfo.status && resUserInfo.body) {
userInfo.value = resUserInfo.body
}
}
getMyThisWeekRanking() //
}
//
const getThisWeekRanking = async () => {
const resWeekStarRanking = await getWeekStarRanking(RankingLoadParams.value)
console.log('resWeekStarRanking:', resWeekStarRanking)
if (
resWeekStarRanking.status &&
resWeekStarRanking.body &&
resWeekStarRanking.body.rankUsers?.records
) {
let rankUsers = resWeekStarRanking.body.rankUsers
Ranking.value.push(...rankUsers.records)
if (current.value * rankUsers.size >= rankUsers.total) {
showRankingLoading.value = false
}
}
}
//
const getHistoryRankingTop1 = async () => {
const resHistoryTopOne = await getHistoryTopOne()
console.log('resHistoryTopOne:', resHistoryTopOne)
if (resHistoryTopOne.status && resHistoryTopOne.body) {
historyRankingTop1.value = resHistoryTopOne.body
}
}
//
const getMyThisWeekRanking = async () => {
let data = {
userId: userInfo.value.id,
type: 'THIS_WEEK',
}
const resMyWeekStarRanking = await getMyWeekStarRanking(data)
//
const getListAndMy = async () => {
const resMyWeekStarRanking = await getRankingListAndMyRanking(2)
console.log('resMyWeekStarRanking:', resMyWeekStarRanking)
if (resMyWeekStarRanking.status && resMyWeekStarRanking.body) {
myRanking.value = resMyWeekStarRanking.body
myRanking.value = resMyWeekStarRanking.body.currentUserRank
Ranking.value = resMyWeekStarRanking.body.rankingList
}
}
//
const getThisWeekGifts = async () => {
const resThisWeekGifts = await getWeekGifts('THIS_WEEK')
console.log('resThisWeekGifts:', resThisWeekGifts)
if (resThisWeekGifts.status && resThisWeekGifts.body) {
gifts.value = resThisWeekGifts.body
}
}
//
const getThisWeekRewards = async () => {
const resThisWeekRewards = await getWeekRewards()
console.log('resThisWeekRewards:', resThisWeekRewards)
if (resThisWeekRewards.status && resThisWeekRewards.body) {
rewardsList.value = resThisWeekRewards.body
//
const getRewardsAndGifts = async () => {
const resRewardsAndGifts = await getThisWeekRewardsAndGifts('1986033481182425089')
if (resRewardsAndGifts.status && resRewardsAndGifts.body) {
gifts.value = resRewardsAndGifts.body.gifts
rewardsList.value = resRewardsAndGifts.body.butOneRewards
}
}
//
const initData = () => {
getUserInfo()
getThisWeekRanking() //
getHistoryRankingTop1() // top1
getThisWeekRewards() //
getThisWeekGifts() //
getListAndMy() //
getRewardsAndGifts() //
}
const debouceGetThisWeekRanking = useThrottle(() => {
getThisWeekRanking()
}, 1000)
// IntersectionObserver
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio > 0 && Ranking.value.length != 0) {
console.log('触发RankingLoadmore加载')
current.value++
debouceGetThisWeekRanking()
}
})
})
// 使APP
const connectToAppHandler = async () => {
await connectToApp(() => {
@ -807,12 +571,7 @@ onMounted(() => {
isInAppEnvironment.value = isInApp()
getCountdown()
timer = setInterval(getCountdown, 1000) //
//
if (RankingLoadmore.value) {
observer.observe(RankingLoadmore.value)
}
timer = setInterval(getCountdown, 1000) //
})
onUnmounted(() => {