feat(革命节和英雄节): 取消历史榜首、设置截止日期、对接正确接口
This commit is contained in:
parent
bb1bef2246
commit
155fd86684
39
src/api/activity.js
Normal file
39
src/api/activity.js
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,28 +6,19 @@
|
|||||||
<div v-if="isInAppEnvironment" style="height: 30px"></div>
|
<div v-if="isInAppEnvironment" style="height: 30px"></div>
|
||||||
|
|
||||||
<!-- 按钮 -->
|
<!-- 按钮 -->
|
||||||
<div
|
<div style="display: flex; justify-content: flex-end; align-items: center">
|
||||||
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"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 帮助按钮 -->
|
<!-- 帮助按钮 -->
|
||||||
<img
|
<img
|
||||||
:src="images.help"
|
:src="images.help"
|
||||||
alt=""
|
alt=""
|
||||||
style="display: block; width: 10%; margin-right: 8px"
|
style="
|
||||||
@click="helpInfoShow = true"
|
display: block;
|
||||||
|
margin-top: 100vw;
|
||||||
|
position: relative;
|
||||||
|
width: 10%;
|
||||||
|
margin-right: 8px;
|
||||||
|
"
|
||||||
|
@click="maskLayerShow = true"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -156,8 +147,8 @@
|
|||||||
<div style="display: flex; justify-content: center">
|
<div style="display: flex; justify-content: center">
|
||||||
<TopUser
|
<TopUser
|
||||||
:BorderImgUrl="images.topOne"
|
:BorderImgUrl="images.topOne"
|
||||||
:avatarUrl="RankingHasTop3[0].userAvatar"
|
:avatarUrl="RankingHasTop3[0].avatar"
|
||||||
:name="RankingHasTop3[0].userNickname"
|
:name="RankingHasTop3[0].nickname"
|
||||||
:distributionValue="RankingHasTop3[0].quantity"
|
:distributionValue="RankingHasTop3[0].quantity"
|
||||||
style="width: 43%"
|
style="width: 43%"
|
||||||
@click="viewUserInfo(RankingHasTop3[0].userId)"
|
@click="viewUserInfo(RankingHasTop3[0].userId)"
|
||||||
@ -168,8 +159,8 @@
|
|||||||
<TopUser
|
<TopUser
|
||||||
:isTopOne="false"
|
:isTopOne="false"
|
||||||
:BorderImgUrl="images.topTwo"
|
:BorderImgUrl="images.topTwo"
|
||||||
:avatarUrl="RankingHasTop3[1].userAvatar"
|
:avatarUrl="RankingHasTop3[1].avatar"
|
||||||
:name="RankingHasTop3[1].userNickname"
|
:name="RankingHasTop3[1].nickname"
|
||||||
:distributionValue="RankingHasTop3[1].quantity"
|
:distributionValue="RankingHasTop3[1].quantity"
|
||||||
style="width: 30%"
|
style="width: 30%"
|
||||||
@click="viewUserInfo(RankingHasTop3[1].userId)"
|
@click="viewUserInfo(RankingHasTop3[1].userId)"
|
||||||
@ -177,8 +168,8 @@
|
|||||||
<TopUser
|
<TopUser
|
||||||
:isTopOne="false"
|
:isTopOne="false"
|
||||||
:BorderImgUrl="images.topThree"
|
:BorderImgUrl="images.topThree"
|
||||||
:avatarUrl="RankingHasTop3[2].userAvatar"
|
:avatarUrl="RankingHasTop3[2].avatar"
|
||||||
:name="RankingHasTop3[2].userNickname"
|
:name="RankingHasTop3[2].nickname"
|
||||||
:distributionValue="RankingHasTop3[2].quantity"
|
:distributionValue="RankingHasTop3[2].quantity"
|
||||||
style="width: 30%"
|
style="width: 30%"
|
||||||
@click="viewUserInfo(RankingHasTop3[2].userId)"
|
@click="viewUserInfo(RankingHasTop3[2].userId)"
|
||||||
@ -212,7 +203,7 @@
|
|||||||
{{ listItem.rank }}
|
{{ listItem.rank }}
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
:src="listItem.userAvatar || ''"
|
:src="listItem.avatar || ''"
|
||||||
alt=""
|
alt=""
|
||||||
style="
|
style="
|
||||||
width: 20%;
|
width: 20%;
|
||||||
@ -242,7 +233,7 @@
|
|||||||
"
|
"
|
||||||
class="UserNickname"
|
class="UserNickname"
|
||||||
>
|
>
|
||||||
{{ listItem.userNickname }}
|
{{ listItem.nickname }}
|
||||||
</div>
|
</div>
|
||||||
<div style="color: #fff; font-weight: 590" class="UserNickname">
|
<div style="color: #fff; font-weight: 590" class="UserNickname">
|
||||||
ID:{{ listItem.account }}
|
ID:{{ listItem.account }}
|
||||||
@ -258,8 +249,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 触发加载功能 -->
|
|
||||||
<div ref="RankingLoadmore" v-show="showRankingLoading && rankingShow"></div>
|
|
||||||
|
|
||||||
<!-- 底框 -->
|
<!-- 底框 -->
|
||||||
<img
|
<img
|
||||||
@ -282,7 +271,11 @@
|
|||||||
style="position: relative; width: 90%; margin-bottom: 20px"
|
style="position: relative; width: 90%; margin-bottom: 20px"
|
||||||
>
|
>
|
||||||
<div style="position: relative">
|
<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
|
<div
|
||||||
style="
|
style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -294,7 +287,7 @@
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-for="(reward, rewardIndex) in rewardsTop.propsGroup.activityRewardProps"
|
v-for="(reward, rewardIndex) in rewardsTop.rewards"
|
||||||
:key="rewardIndex"
|
:key="rewardIndex"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
@ -323,7 +316,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="color: rgba(255, 255, 255, 1); font-weight: 590; text-align: center">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -368,7 +361,7 @@
|
|||||||
<div style="color: #edb247; font-weight: 700">{{ myRanking.rank || 999 }}</div>
|
<div style="color: #edb247; font-weight: 700">{{ myRanking.rank || 999 }}</div>
|
||||||
<!-- 头像 -->
|
<!-- 头像 -->
|
||||||
<img
|
<img
|
||||||
:src="myRanking.userAvatar || ''"
|
:src="myRanking.avatar || ''"
|
||||||
alt=""
|
alt=""
|
||||||
style="
|
style="
|
||||||
display: block;
|
display: block;
|
||||||
@ -392,7 +385,7 @@
|
|||||||
"
|
"
|
||||||
class="UserNickname"
|
class="UserNickname"
|
||||||
>
|
>
|
||||||
{{ myRanking.userNickname }}
|
{{ myRanking.nickname }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -408,104 +401,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 弹窗遮罩层 -->
|
<!-- 弹窗遮罩层 -->
|
||||||
<maskLayer :maskLayerShow="maskLayerShow" @click="closedPopup">
|
<maskLayer :maskLayerShow="maskLayerShow" @click="maskLayerShow = false">
|
||||||
<!-- help弹窗 -->
|
<!-- 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%" />
|
<img :src="images.helpInfo" alt="" style="width: 100%" />
|
||||||
</div>
|
</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>
|
</maskLayer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -517,15 +417,8 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|||||||
import itemCenter from '@/components/WeeklyStar/itemCenter.vue'
|
import itemCenter from '@/components/WeeklyStar/itemCenter.vue'
|
||||||
import TopUser from '../RevolutionUnityDay/topUser.vue'
|
import TopUser from '../RevolutionUnityDay/topUser.vue'
|
||||||
import maskLayer from '@/components/MaskLayer.vue'
|
import maskLayer from '@/components/MaskLayer.vue'
|
||||||
import { useDebounce, useThrottle } from '@/utils/useDebounce'
|
|
||||||
import { getMemberProfile } from '@/api/wallet'
|
import { getMemberProfile } from '@/api/wallet'
|
||||||
import {
|
import { getThisWeekRewardsAndGifts, getRankingListAndMyRanking } from '@/api/activity.js'
|
||||||
getWeekStarRanking,
|
|
||||||
getWeekRewards,
|
|
||||||
getWeekGifts,
|
|
||||||
getMyWeekStarRanking,
|
|
||||||
getHistoryTopOne,
|
|
||||||
} from '@/api/weeklyStar.js'
|
|
||||||
import { connectToApp } from '@/utils/appConnector.js'
|
import { connectToApp } from '@/utils/appConnector.js'
|
||||||
|
|
||||||
// vite动态批量导入图片
|
// vite动态批量导入图片
|
||||||
@ -540,16 +433,8 @@ const images = Object.fromEntries(
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const userInfo = ref({})
|
|
||||||
|
|
||||||
const isInAppEnvironment = ref(false) // 检测是否在APP环境中
|
const isInAppEnvironment = ref(false) // 检测是否在APP环境中
|
||||||
const helpInfoShow = ref(false) //帮助模块
|
const maskLayerShow = ref(false) //帮助模块
|
||||||
const historyShow = ref(false) //历史模块
|
|
||||||
|
|
||||||
// 展示遮罩层
|
|
||||||
const maskLayerShow = computed(() => {
|
|
||||||
return helpInfoShow.value || historyShow.value
|
|
||||||
})
|
|
||||||
|
|
||||||
// 倒计时
|
// 倒计时
|
||||||
const Days = ref(0)
|
const Days = ref(0)
|
||||||
@ -561,39 +446,13 @@ let timer = null
|
|||||||
// 模块切换展示
|
// 模块切换展示
|
||||||
const rankingShow = ref(true) //排行榜
|
const rankingShow = ref(true) //排行榜
|
||||||
|
|
||||||
const current = ref(1) //排行榜第几页
|
|
||||||
const RankingLoadmore = ref(null) //触底模块
|
|
||||||
const showRankingLoading = ref(true) //触底加载功能
|
|
||||||
const Ranking = ref([]) // 排行榜
|
const Ranking = ref([]) // 排行榜
|
||||||
|
const myRanking = ref({}) // 我的排名
|
||||||
const RankingLoadParams = computed(() => {
|
|
||||||
return {
|
|
||||||
type: 'THIS_WEEK',
|
|
||||||
current: current.value,
|
|
||||||
size: 10,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const myRanking = ref([]) // 我的排名
|
|
||||||
const rewardsList = ref([]) // 奖励列表
|
const rewardsList = ref([]) // 奖励列表
|
||||||
const gifts = 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 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人时的情况
|
// 处理排行榜小于3人时的情况
|
||||||
const RankingHasTop3 = computed(() => {
|
const RankingHasTop3 = computed(() => {
|
||||||
let RankingShow = [...Ranking.value]
|
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
|
e.target.src = new URL('/src/assets/images/WeeklyStar/defaultAvatar.png', import.meta.url).href
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭弹窗
|
// 获取2025年11月14日上午10点的时间戳(北京时间)
|
||||||
const closedPopup = () => {
|
const getTargetTime = () => {
|
||||||
helpInfoShow.value = false
|
const targetDate = new Date(2025, 10, 14, 10, 0, 0) // 月份从0开始,10代表11月
|
||||||
historyShow.value = false
|
return targetDate.getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取孟加拉下周一早上六点的时间戳
|
const targetTime = ref(getTargetTime())
|
||||||
const getNextMondayInSaudi = () => {
|
|
||||||
const now = new Date()
|
|
||||||
const utcDay = now.getUTCDay() //获取UTC星期几,0(周日)-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) // 设置为孟加拉下周一当天早上6点(北京时间3点)
|
|
||||||
return nextMondayUTC.getTime() //得到下周一00:00:00.000的时间戳
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetTime = ref(getNextMondayInSaudi()) // 闭包保存目标时间 (核心修正)
|
|
||||||
|
|
||||||
// 格式化时间
|
// 格式化时间
|
||||||
const formatTime = (value) => {
|
const formatTime = (value) => {
|
||||||
@ -661,12 +506,19 @@ const getCountdown = () => {
|
|||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
let diff = targetTime.value - now
|
let diff = targetTime.value - now
|
||||||
|
|
||||||
|
// 如果已过期,显示全零
|
||||||
if (diff <= 0) {
|
if (diff <= 0) {
|
||||||
// 初始化数据
|
Days.value = 0
|
||||||
getUserInfo()
|
Hours.value = '00'
|
||||||
resetPage()
|
Minutes.value = '00'
|
||||||
targetTime.value += 7 * 86400000 // +7天 (更新闭包变量)
|
Second.value = '00'
|
||||||
diff = targetTime.value - now
|
|
||||||
|
// 清除定时器
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalSeconds = Math.floor(diff / 1000)
|
const totalSeconds = Math.floor(diff / 1000)
|
||||||
@ -676,119 +528,41 @@ const getCountdown = () => {
|
|||||||
Second.value = formatTime(Math.floor(totalSeconds % 60))
|
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']
|
let showamount = ['GOLD', 'DIAMOND', 'GIFT', 'FRAGMENTS']
|
||||||
if (showamount.includes(type)) {
|
if (showamount.includes(type)) {
|
||||||
return quantity
|
return reward.content
|
||||||
} else {
|
} else {
|
||||||
return `${quantity}Days`
|
return `${reward.quantity}Days`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取用户信息
|
// 获取排行榜和我的排名
|
||||||
const getUserInfo = async () => {
|
const getListAndMy = async () => {
|
||||||
if (Object.keys(userInfo.value).length === 0) {
|
const resMyWeekStarRanking = await getRankingListAndMyRanking(1)
|
||||||
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)
|
|
||||||
console.log('resMyWeekStarRanking:', resMyWeekStarRanking)
|
console.log('resMyWeekStarRanking:', resMyWeekStarRanking)
|
||||||
if (resMyWeekStarRanking.status && resMyWeekStarRanking.body) {
|
if (resMyWeekStarRanking.status && resMyWeekStarRanking.body) {
|
||||||
myRanking.value = resMyWeekStarRanking.body
|
myRanking.value = resMyWeekStarRanking.body.currentUserRank
|
||||||
|
Ranking.value = resMyWeekStarRanking.body.rankingList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取本周礼物
|
// 获取每周奖励列表和礼物
|
||||||
const getThisWeekGifts = async () => {
|
const getRewardsAndGifts = async () => {
|
||||||
const resThisWeekGifts = await getWeekGifts('THIS_WEEK')
|
const resRewardsAndGifts = await getThisWeekRewardsAndGifts('1986033416841801729')
|
||||||
console.log('resThisWeekGifts:', resThisWeekGifts)
|
if (resRewardsAndGifts.status && resRewardsAndGifts.body) {
|
||||||
if (resThisWeekGifts.status && resThisWeekGifts.body) {
|
gifts.value = resRewardsAndGifts.body.gifts
|
||||||
gifts.value = resThisWeekGifts.body
|
rewardsList.value = resRewardsAndGifts.body.butOneRewards
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取本周奖励
|
|
||||||
const getThisWeekRewards = async () => {
|
|
||||||
const resThisWeekRewards = await getWeekRewards()
|
|
||||||
console.log('resThisWeekRewards:', resThisWeekRewards)
|
|
||||||
if (resThisWeekRewards.status && resThisWeekRewards.body) {
|
|
||||||
rewardsList.value = resThisWeekRewards.body
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新页面数据
|
// 刷新页面数据
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
getUserInfo()
|
getListAndMy() // 获取排行榜和我的排名
|
||||||
getThisWeekRanking() // 获取本周排名
|
getRewardsAndGifts() //获取本周的礼物和奖励列表
|
||||||
getHistoryRankingTop1() // 获取历史top1
|
|
||||||
getThisWeekRewards() // 获取本周奖励
|
|
||||||
getThisWeekGifts() //获取礼物
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// 使用工具函数连接APP
|
||||||
const connectToAppHandler = async () => {
|
const connectToAppHandler = async () => {
|
||||||
await connectToApp(() => {
|
await connectToApp(() => {
|
||||||
@ -803,12 +577,7 @@ onMounted(() => {
|
|||||||
isInAppEnvironment.value = isInApp()
|
isInAppEnvironment.value = isInApp()
|
||||||
|
|
||||||
getCountdown()
|
getCountdown()
|
||||||
timer = setInterval(getCountdown, 1000) //每秒更新
|
timer = setInterval(getCountdown, 1000) //倒计时每秒更新
|
||||||
|
|
||||||
// 监听加载模块
|
|
||||||
if (RankingLoadmore.value) {
|
|
||||||
observer.observe(RankingLoadmore.value)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<!-- src/views/Activities/RevolutionUnityDay/index.vue -->
|
<!-- src/views/Activities/heroesDay/index.vue -->
|
||||||
<template>
|
<template>
|
||||||
<div class="fullPage">
|
<div class="fullPage">
|
||||||
<div class="bg">
|
<div class="bg">
|
||||||
@ -6,23 +6,13 @@
|
|||||||
<div v-if="isInAppEnvironment" style="height: 30px"></div>
|
<div v-if="isInAppEnvironment" style="height: 30px"></div>
|
||||||
|
|
||||||
<!-- 按钮 -->
|
<!-- 按钮 -->
|
||||||
<div
|
<div style="margin-top: 80vw; display: flex; justify-content: flex-end; align-items: center">
|
||||||
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"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 帮助按钮 -->
|
<!-- 帮助按钮 -->
|
||||||
<img
|
<img
|
||||||
:src="images.help"
|
:src="images.help"
|
||||||
alt=""
|
alt=""
|
||||||
style="display: block; width: 10%; margin-right: 8px"
|
style="display: block; position: relative; width: 10%; margin-right: 8px"
|
||||||
@click="helpInfoShow = true"
|
@click="maskLayerShow = true"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -151,8 +141,8 @@
|
|||||||
<div style="display: flex; justify-content: center">
|
<div style="display: flex; justify-content: center">
|
||||||
<TopUser
|
<TopUser
|
||||||
:BorderImgUrl="images.topOne"
|
:BorderImgUrl="images.topOne"
|
||||||
:avatarUrl="RankingHasTop3[0].userAvatar"
|
:avatarUrl="RankingHasTop3[0].avatar"
|
||||||
:name="RankingHasTop3[0].userNickname"
|
:name="RankingHasTop3[0].nickname"
|
||||||
:distributionValue="RankingHasTop3[0].quantity"
|
:distributionValue="RankingHasTop3[0].quantity"
|
||||||
style="width: 43%"
|
style="width: 43%"
|
||||||
@click="viewUserInfo(RankingHasTop3[0].userId)"
|
@click="viewUserInfo(RankingHasTop3[0].userId)"
|
||||||
@ -162,20 +152,18 @@
|
|||||||
<div style="display: flex; justify-content: space-between; margin-top: -20%">
|
<div style="display: flex; justify-content: space-between; margin-top: -20%">
|
||||||
<TopUser
|
<TopUser
|
||||||
:isTopOne="false"
|
:isTopOne="false"
|
||||||
ranking="2"
|
|
||||||
:BorderImgUrl="images.topTwo"
|
:BorderImgUrl="images.topTwo"
|
||||||
:avatarUrl="RankingHasTop3[1].userAvatar"
|
:avatarUrl="RankingHasTop3[1].avatar"
|
||||||
:name="RankingHasTop3[1].userNickname"
|
:name="RankingHasTop3[1].nickname"
|
||||||
:distributionValue="RankingHasTop3[1].quantity"
|
:distributionValue="RankingHasTop3[1].quantity"
|
||||||
style="width: 30%"
|
style="width: 30%"
|
||||||
@click="viewUserInfo(RankingHasTop3[1].userId)"
|
@click="viewUserInfo(RankingHasTop3[1].userId)"
|
||||||
/>
|
/>
|
||||||
<TopUser
|
<TopUser
|
||||||
:isTopOne="false"
|
:isTopOne="false"
|
||||||
ranking="3"
|
|
||||||
:BorderImgUrl="images.topThree"
|
:BorderImgUrl="images.topThree"
|
||||||
:avatarUrl="RankingHasTop3[2].userAvatar"
|
:avatarUrl="RankingHasTop3[2].avatar"
|
||||||
:name="RankingHasTop3[2].userNickname"
|
:name="RankingHasTop3[2].nickname"
|
||||||
:distributionValue="RankingHasTop3[2].quantity"
|
:distributionValue="RankingHasTop3[2].quantity"
|
||||||
style="width: 30%"
|
style="width: 30%"
|
||||||
@click="viewUserInfo(RankingHasTop3[2].userId)"
|
@click="viewUserInfo(RankingHasTop3[2].userId)"
|
||||||
@ -209,7 +197,7 @@
|
|||||||
{{ listItem.rank }}
|
{{ listItem.rank }}
|
||||||
</div>
|
</div>
|
||||||
<img
|
<img
|
||||||
:src="listItem.userAvatar || ''"
|
:src="listItem.avatar || ''"
|
||||||
alt=""
|
alt=""
|
||||||
style="
|
style="
|
||||||
width: 20%;
|
width: 20%;
|
||||||
@ -239,7 +227,7 @@
|
|||||||
"
|
"
|
||||||
class="UserNickname"
|
class="UserNickname"
|
||||||
>
|
>
|
||||||
{{ listItem.userNickname }}
|
{{ listItem.nickname }}
|
||||||
</div>
|
</div>
|
||||||
<div style="color: #fff; font-weight: 590" class="UserNickname">
|
<div style="color: #fff; font-weight: 590" class="UserNickname">
|
||||||
ID:{{ listItem.account }}
|
ID:{{ listItem.account }}
|
||||||
@ -255,8 +243,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 触发加载功能 -->
|
|
||||||
<div ref="RankingLoadmore" v-show="showRankingLoading && rankingShow"></div>
|
|
||||||
|
|
||||||
<!-- 底框 -->
|
<!-- 底框 -->
|
||||||
<img
|
<img
|
||||||
@ -279,7 +265,11 @@
|
|||||||
style="position: relative; width: 90%; margin-bottom: 20px"
|
style="position: relative; width: 90%; margin-bottom: 20px"
|
||||||
>
|
>
|
||||||
<div style="position: relative">
|
<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
|
<div
|
||||||
style="
|
style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -287,23 +277,16 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
padding: 30vw 5vw 20vw;
|
padding: 25vw 5vw 15vw;
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-for="(reward, rewardIndex) in rewardsTop.propsGroup.activityRewardProps"
|
v-for="(reward, rewardIndex) in rewardsTop.rewards"
|
||||||
:key="rewardIndex"
|
:key="rewardIndex"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<div
|
<div style="position: relative">
|
||||||
style="
|
<img :src="images.giftItemBg" style="" alt="" width="100%" />
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<img :src="images.giftItemBg" style="" alt="" width="90%" />
|
|
||||||
<div
|
<div
|
||||||
style="
|
style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -327,7 +310,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="color: rgba(255, 255, 255, 1); font-weight: 590; text-align: center">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -372,7 +355,7 @@
|
|||||||
<div style="color: #edb247; font-weight: 700">{{ myRanking.rank || 999 }}</div>
|
<div style="color: #edb247; font-weight: 700">{{ myRanking.rank || 999 }}</div>
|
||||||
<!-- 头像 -->
|
<!-- 头像 -->
|
||||||
<img
|
<img
|
||||||
:src="myRanking.userAvatar || ''"
|
:src="myRanking.avatar || ''"
|
||||||
alt=""
|
alt=""
|
||||||
style="
|
style="
|
||||||
display: block;
|
display: block;
|
||||||
@ -396,7 +379,7 @@
|
|||||||
"
|
"
|
||||||
class="UserNickname"
|
class="UserNickname"
|
||||||
>
|
>
|
||||||
{{ myRanking.userNickname }}
|
{{ myRanking.nickname }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -412,104 +395,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 弹窗遮罩层 -->
|
<!-- 弹窗遮罩层 -->
|
||||||
<maskLayer :maskLayerShow="maskLayerShow" @click="closedPopup">
|
<maskLayer :maskLayerShow="maskLayerShow" @click="maskLayerShow = false">
|
||||||
<!-- help弹窗 -->
|
<!-- 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%" />
|
<img :src="images.helpInfo" alt="" style="width: 100%" />
|
||||||
</div>
|
</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>
|
</maskLayer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -521,15 +411,8 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
|
|||||||
import itemCenter from '@/components/WeeklyStar/itemCenter.vue'
|
import itemCenter from '@/components/WeeklyStar/itemCenter.vue'
|
||||||
import TopUser from '../heroesDay/topUser.vue'
|
import TopUser from '../heroesDay/topUser.vue'
|
||||||
import maskLayer from '@/components/MaskLayer.vue'
|
import maskLayer from '@/components/MaskLayer.vue'
|
||||||
import { useDebounce, useThrottle } from '@/utils/useDebounce'
|
|
||||||
import { getMemberProfile } from '@/api/wallet'
|
import { getMemberProfile } from '@/api/wallet'
|
||||||
import {
|
import { getThisWeekRewardsAndGifts, getRankingListAndMyRanking } from '@/api/activity.js'
|
||||||
getWeekStarRanking,
|
|
||||||
getWeekRewards,
|
|
||||||
getWeekGifts,
|
|
||||||
getMyWeekStarRanking,
|
|
||||||
getHistoryTopOne,
|
|
||||||
} from '@/api/weeklyStar.js'
|
|
||||||
import { connectToApp } from '@/utils/appConnector.js'
|
import { connectToApp } from '@/utils/appConnector.js'
|
||||||
|
|
||||||
// vite动态批量导入图片
|
// vite动态批量导入图片
|
||||||
@ -544,16 +427,8 @@ const images = Object.fromEntries(
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const userInfo = ref({})
|
|
||||||
|
|
||||||
const isInAppEnvironment = ref(false) // 检测是否在APP环境中
|
const isInAppEnvironment = ref(false) // 检测是否在APP环境中
|
||||||
const helpInfoShow = ref(false) //帮助模块
|
const maskLayerShow = ref(false) //帮助模块
|
||||||
const historyShow = ref(false) //历史模块
|
|
||||||
|
|
||||||
// 展示遮罩层
|
|
||||||
const maskLayerShow = computed(() => {
|
|
||||||
return helpInfoShow.value || historyShow.value
|
|
||||||
})
|
|
||||||
|
|
||||||
// 倒计时
|
// 倒计时
|
||||||
const Days = ref(0)
|
const Days = ref(0)
|
||||||
@ -565,46 +440,20 @@ let timer = null
|
|||||||
// 模块切换展示
|
// 模块切换展示
|
||||||
const rankingShow = ref(true) //排行榜
|
const rankingShow = ref(true) //排行榜
|
||||||
|
|
||||||
const current = ref(1) //排行榜第几页
|
|
||||||
const RankingLoadmore = ref(null) //触底模块
|
|
||||||
const showRankingLoading = ref(true) //触底加载功能
|
|
||||||
const Ranking = ref([]) // 排行榜
|
const Ranking = ref([]) // 排行榜
|
||||||
|
const myRanking = ref({}) // 我的排名
|
||||||
const RankingLoadParams = computed(() => {
|
|
||||||
return {
|
|
||||||
type: 'THIS_WEEK',
|
|
||||||
current: current.value,
|
|
||||||
size: 10,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const myRanking = ref([]) // 我的排名
|
|
||||||
const rewardsList = ref([]) // 奖励列表
|
const rewardsList = ref([]) // 奖励列表
|
||||||
const gifts = 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 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人时的情况
|
// 处理排行榜小于3人时的情况
|
||||||
const RankingHasTop3 = computed(() => {
|
const RankingHasTop3 = computed(() => {
|
||||||
let RankingShow = [...Ranking.value]
|
let RankingShow = [...Ranking.value]
|
||||||
if (Ranking.value.length < 3) {
|
if (Ranking.value.length < 3) {
|
||||||
let addNullUser = Array.from({ length: 3 - Ranking.value.length }, () => ({
|
let addNullUser = Array.from({ length: 3 - Ranking.value.length }, () => ({
|
||||||
userAvatar: '',
|
avatar: '',
|
||||||
userNickname: '',
|
nickname: '',
|
||||||
quantity: '',
|
quantity: '',
|
||||||
}))
|
}))
|
||||||
RankingShow.push(...addNullUser)
|
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
|
e.target.src = new URL('/src/assets/images/WeeklyStar/defaultAvatar.png', import.meta.url).href
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭弹窗
|
// 获取2025年11月18日上午10点的时间戳(北京时间)
|
||||||
const closedPopup = () => {
|
const getTargetTime = () => {
|
||||||
helpInfoShow.value = false
|
const targetDate = new Date(2025, 10, 18, 10, 0, 0) // 月份从0开始,10代表11月
|
||||||
historyShow.value = false
|
return targetDate.getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取印度尼西亚下周一早上六点的时间戳
|
const targetTime = ref(getTargetTime())
|
||||||
const getNextMondayInSaudi = () => {
|
|
||||||
const now = new Date()
|
|
||||||
const utcDay = now.getUTCDay() //获取UTC星期几,0(周日)-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) // 设置为印度尼西亚下周一当天早上6点(北京时间3点)
|
|
||||||
return nextMondayUTC.getTime() //得到下周一00:00:00.000的时间戳
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetTime = ref(getNextMondayInSaudi()) // 闭包保存目标时间 (核心修正)
|
|
||||||
|
|
||||||
// 格式化时间
|
// 格式化时间
|
||||||
const formatTime = (value) => {
|
const formatTime = (value) => {
|
||||||
@ -665,12 +500,19 @@ const getCountdown = () => {
|
|||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
let diff = targetTime.value - now
|
let diff = targetTime.value - now
|
||||||
|
|
||||||
|
// 如果已过期,显示全零
|
||||||
if (diff <= 0) {
|
if (diff <= 0) {
|
||||||
// 初始化数据
|
Days.value = 0
|
||||||
getUserInfo()
|
Hours.value = '00'
|
||||||
resetPage()
|
Minutes.value = '00'
|
||||||
targetTime.value += 7 * 86400000 // +7天 (更新闭包变量)
|
Second.value = '00'
|
||||||
diff = targetTime.value - now
|
|
||||||
|
// 清除定时器
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalSeconds = Math.floor(diff / 1000)
|
const totalSeconds = Math.floor(diff / 1000)
|
||||||
@ -680,119 +522,41 @@ const getCountdown = () => {
|
|||||||
Second.value = formatTime(Math.floor(totalSeconds % 60))
|
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']
|
let showamount = ['GOLD', 'DIAMOND', 'GIFT', 'FRAGMENTS']
|
||||||
if (showamount.includes(type)) {
|
if (showamount.includes(type)) {
|
||||||
return quantity
|
return reward.content
|
||||||
} else {
|
} else {
|
||||||
return `${quantity}Days`
|
return `${reward.quantity}Days`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取用户信息
|
// 获取排行榜和我的排名
|
||||||
const getUserInfo = async () => {
|
const getListAndMy = async () => {
|
||||||
if (Object.keys(userInfo.value).length === 0) {
|
const resMyWeekStarRanking = await getRankingListAndMyRanking(2)
|
||||||
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)
|
|
||||||
console.log('resMyWeekStarRanking:', resMyWeekStarRanking)
|
console.log('resMyWeekStarRanking:', resMyWeekStarRanking)
|
||||||
if (resMyWeekStarRanking.status && resMyWeekStarRanking.body) {
|
if (resMyWeekStarRanking.status && resMyWeekStarRanking.body) {
|
||||||
myRanking.value = resMyWeekStarRanking.body
|
myRanking.value = resMyWeekStarRanking.body.currentUserRank
|
||||||
|
Ranking.value = resMyWeekStarRanking.body.rankingList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取本周礼物
|
// 获取每周奖励列表和礼物
|
||||||
const getThisWeekGifts = async () => {
|
const getRewardsAndGifts = async () => {
|
||||||
const resThisWeekGifts = await getWeekGifts('THIS_WEEK')
|
const resRewardsAndGifts = await getThisWeekRewardsAndGifts('1986033481182425089')
|
||||||
console.log('resThisWeekGifts:', resThisWeekGifts)
|
if (resRewardsAndGifts.status && resRewardsAndGifts.body) {
|
||||||
if (resThisWeekGifts.status && resThisWeekGifts.body) {
|
gifts.value = resRewardsAndGifts.body.gifts
|
||||||
gifts.value = resThisWeekGifts.body
|
rewardsList.value = resRewardsAndGifts.body.butOneRewards
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取本周奖励
|
|
||||||
const getThisWeekRewards = async () => {
|
|
||||||
const resThisWeekRewards = await getWeekRewards()
|
|
||||||
console.log('resThisWeekRewards:', resThisWeekRewards)
|
|
||||||
if (resThisWeekRewards.status && resThisWeekRewards.body) {
|
|
||||||
rewardsList.value = resThisWeekRewards.body
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新页面数据
|
// 刷新页面数据
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
getUserInfo()
|
getListAndMy() // 获取排行榜和我的排名
|
||||||
getThisWeekRanking() // 获取本周排名
|
getRewardsAndGifts() //获取本周的礼物和奖励列表
|
||||||
getHistoryRankingTop1() // 获取历史top1
|
|
||||||
getThisWeekRewards() // 获取本周奖励
|
|
||||||
getThisWeekGifts() //获取礼物
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// 使用工具函数连接APP
|
||||||
const connectToAppHandler = async () => {
|
const connectToAppHandler = async () => {
|
||||||
await connectToApp(() => {
|
await connectToApp(() => {
|
||||||
@ -807,12 +571,7 @@ onMounted(() => {
|
|||||||
isInAppEnvironment.value = isInApp()
|
isInAppEnvironment.value = isInApp()
|
||||||
|
|
||||||
getCountdown()
|
getCountdown()
|
||||||
timer = setInterval(getCountdown, 1000) //每秒更新
|
timer = setInterval(getCountdown, 1000) //倒计时每秒更新
|
||||||
|
|
||||||
// 监听加载模块
|
|
||||||
if (RankingLoadmore.value) {
|
|
||||||
observer.observe(RankingLoadmore.value)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user