diff --git a/src/api/activity.js b/src/api/activity.js
new file mode 100644
index 0000000..0d8fa29
--- /dev/null
+++ b/src/api/activity.js
@@ -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
+ }
+}
diff --git a/src/views/Activities/RevolutionUnityDay/index.vue b/src/views/Activities/RevolutionUnityDay/index.vue
index 686f5eb..8062814 100644
--- a/src/views/Activities/RevolutionUnityDay/index.vue
+++ b/src/views/Activities/RevolutionUnityDay/index.vue
@@ -6,28 +6,19 @@
-
-
-
![]()
-
+
@@ -156,8 +147,8 @@
- {{ listItem.userNickname }}
+ {{ listItem.nickname }}
ID:{{ listItem.account }}
@@ -258,8 +249,6 @@
-
-
-
![]()
+
@@ -323,7 +316,7 @@
- {{ showDetail(reward.type, reward.quantity) }}
+ {{ showDetail(reward.type, reward) }}
@@ -368,7 +361,7 @@
{{ myRanking.rank || 999 }}
- {{ myRanking.userNickname }}
+ {{ myRanking.nickname }}
@@ -408,104 +401,11 @@
-
+
-
+
-
-
-
-
-
![]()
-
-
-
-
-
![]()
-
-
-
![]()
-
-
-
-
- {{ showTopOne.userNickname }}
-
-
-
-
-
-
-
-
![]()
-
- {{ showTopOne.group }}
-
-
![]()
-
-
-
@@ -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
+// 获取2025年11月14日上午10点的时间戳(北京时间)
+const getTargetTime = () => {
+ const targetDate = new Date(2025, 10, 14, 10, 0, 0) // 月份从0开始,10代表11月
+ return targetDate.getTime()
}
-// 获取孟加拉下周一早上六点的时间戳
-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 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(() => {
diff --git a/src/views/Activities/heroesDay/index.vue b/src/views/Activities/heroesDay/index.vue
index 73d6215..049f897 100644
--- a/src/views/Activities/heroesDay/index.vue
+++ b/src/views/Activities/heroesDay/index.vue
@@ -1,4 +1,4 @@
-
+
@@ -6,23 +6,13 @@
-
-
-
![]()
-
+
@@ -151,8 +141,8 @@
- {{ listItem.userNickname }}
+ {{ listItem.nickname }}
ID:{{ listItem.account }}
@@ -255,8 +243,6 @@
-
-
-
![]()
+
-
-
![]()
+
+
- {{ showDetail(reward.type, reward.quantity) }}
+ {{ showDetail(reward.type, reward) }}
@@ -372,7 +355,7 @@
{{ myRanking.rank || 999 }}
![]()
- {{ myRanking.userNickname }}
+ {{ myRanking.nickname }}
@@ -412,104 +395,11 @@
-
+
-
+
-
-
-
-
-
![]()
-
-
-
-
-
![]()
-
-
-
![]()
-
-
-
-
- {{ showTopOne.userNickname }}
-
-
-
-
-
-
-
-
![]()
-
- {{ showTopOne.group }}
-
-
![]()
-
-
-
@@ -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
+// 获取2025年11月18日上午10点的时间戳(北京时间)
+const getTargetTime = () => {
+ const targetDate = new Date(2025, 10, 18, 10, 0, 0) // 月份从0开始,10代表11月
+ return targetDate.getTime()
}
-// 获取印度尼西亚下周一早上六点的时间戳
-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 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(() => {