feat(排行榜): 对接我的排名接口

This commit is contained in:
hzj 2025-10-11 15:49:29 +08:00
parent 78ef3c7874
commit 9f762b1d48
2 changed files with 75 additions and 33 deletions

View File

@ -37,9 +37,9 @@ export const getRoomRanking = async () => {
} }
// 获取我的排名 // 获取我的排名
export const getMyRanking = async () => { export const getMyRanking = async (type, dateType) => {
try { try {
const response = await get(`/activity/leaderboard/my-rank`) const response = await get(`/activity/leaderboard/my-rank?type=${type}&dateType=${dateType}`)
return response return response
} catch (error) { } catch (error) {
console.error('Failed to fetch get my ranking:', error) console.error('Failed to fetch get my ranking:', error)

View File

@ -23,7 +23,7 @@
<div style="display: flex; justify-content: space-around; position: relative"> <div style="display: flex; justify-content: space-around; position: relative">
<div <div
class="tab" class="tab"
@click="rankingType = 'Wealth'" @click="changeType('Wealth')"
style="" style=""
:style="{ color: rankingType == 'Wealth' ? '#FFB760' : '#fff' }" :style="{ color: rankingType == 'Wealth' ? '#FFB760' : '#fff' }"
> >
@ -31,7 +31,7 @@
</div> </div>
<div <div
class="tab" class="tab"
@click="rankingType = 'Charm'" @click="changeType('Charm')"
style="" style=""
:style="{ color: rankingType == 'Charm' ? '#60FF83' : '#fff' }" :style="{ color: rankingType == 'Charm' ? '#60FF83' : '#fff' }"
> >
@ -39,7 +39,7 @@
</div> </div>
<div <div
class="tab" class="tab"
@click="rankingType = 'Room'" @click="changeType('Room')"
style="" style=""
:style="{ color: rankingType == 'Room' ? '#9B60FF' : '#fff' }" :style="{ color: rankingType == 'Room' ? '#9B60FF' : '#fff' }"
> >
@ -73,28 +73,28 @@
<div <div
class="tag" class="tag"
:class="{ tagActive: selectedTimeTab == 'Hourly' }" :class="{ tagActive: selectedTimeTab == 'Hourly' }"
@click="selectedTimeTab = 'Hourly'" @click="changeDateType('Hourly')"
> >
Hourly Hourly
</div> </div>
<div <div
class="tag" class="tag"
:class="{ tagActive: selectedTimeTab == 'Daily' }" :class="{ tagActive: selectedTimeTab == 'Daily' }"
@click="selectedTimeTab = 'Daily'" @click="changeDateType('Daily')"
> >
Daily Daily
</div> </div>
<div <div
class="tag" class="tag"
:class="{ tagActive: selectedTimeTab == 'Weekly' }" :class="{ tagActive: selectedTimeTab == 'Weekly' }"
@click="selectedTimeTab = 'Weekly'" @click="changeDateType('Weekly')"
> >
Weekly Weekly
</div> </div>
<div <div
class="tag" class="tag"
:class="{ tagActive: selectedTimeTab == 'Monthly' }" :class="{ tagActive: selectedTimeTab == 'Monthly' }"
@click="selectedTimeTab = 'Monthly'" @click="changeDateType('Monthly')"
> >
Monthly Monthly
</div> </div>
@ -157,7 +157,7 @@
<div style="display: flex; align-items: center; width: 70%"> <div style="display: flex; align-items: center; width: 70%">
<div style="font-weight: 700">{{ index + 4 }}</div> <div style="font-weight: 700">{{ index + 4 }}</div>
<img <img
:src="userInfo.avatar" :src="userInfo.avatar || ''"
alt="" alt=""
width="20%" width="20%"
style=" style="
@ -230,18 +230,19 @@
}" }"
> >
<div style="display: flex; align-items: center; width: 70%"> <div style="display: flex; align-items: center; width: 70%">
<div style="font-weight: 700">999</div> <div style="font-weight: 700">{{ myRanking.rank || 0 }}</div>
<img <img
src="" :src="myRanking.avatar || ''"
alt="" alt=""
width="20%" width="20%"
style="display: block; aspect-ratio: 1/1; margin: 0 4px" style="display: block; aspect-ratio: 1/1; margin: 0 4px"
:style="{ borderRadius: rankingType === 'Room' ? '0' : '50%' }"
@error="defaultAvatarUrl" @error="defaultAvatarUrl"
/> />
<div <div
style="font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis" style="font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
> >
aaaaaaaaaaaa {{ myRanking.nickname || '' }}
</div> </div>
</div> </div>
<div style="display: flex; align-items: center; width: 30%"> <div style="display: flex; align-items: center; width: 30%">
@ -260,7 +261,7 @@
text-overflow: ellipsis; text-overflow: ellipsis;
" "
> >
123456789 {{ myRanking.quantityFormat || 0 }}
</div> </div>
</div> </div>
</div> </div>
@ -287,6 +288,10 @@ const isInAppEnvironment = ref(false) // 检测是否在APP环境中
const rankingType = ref('Wealth') // const rankingType = ref('Wealth') //
const selectedTimeTab = ref('Hourly') // const selectedTimeTab = ref('Hourly') //
//
const params_type = ref('GIFTS_SEND') //
const params_dateType = ref('HOUR') //
const totalRanking = ref({}) const totalRanking = ref({})
const showRanking = ref([]) const showRanking = ref([])
const myRanking = ref({}) // const myRanking = ref({}) //
@ -306,25 +311,48 @@ const updateTimeRanking = () => {
} }
} }
watch( //
() => rankingType.value, const changeType = (type) => {
() => { if (rankingType.value != type) {
console.log('监听到rankingType.value变化') console.log('改变rankingType')
rankingType.value = type
selectedTimeTab.value = 'Hourly'
params_dateType.value = 'HOUR'
if (type == 'Wealth') {
params_type.value = 'GIFTS_SEND'
} else if (type == 'Charm') {
params_type.value = 'GIFTS_RECEIVED'
} else if (type == 'Room') {
params_type.value = 'ROOM_GIFTS'
}
totalRanking.value = {} totalRanking.value = {}
showRanking.value = [] showRanking.value = []
// myRanking.value = {}
getRanking() getRanking() //
getMyRankingInfo() //
} }
) }
watch( //
() => selectedTimeTab.value, const changeDateType = (dateType) => {
() => { if (selectedTimeTab.value != dateType) {
console.log('监听到selectedTimeTab.value变化') console.log('改变rankingType')
selectedTimeTab.value = dateType
if (dateType == 'Hourly') {
params_dateType.value = 'HOUR'
} else if (dateType == 'Daily') {
params_dateType.value = 'DAY'
} else if (dateType == 'Weekly') {
params_dateType.value = 'WEEK'
} else if (dateType == 'Monthly') {
params_dateType.value = 'MONTH'
}
showRanking.value = [] showRanking.value = []
myRanking.value = {}
updateTimeRanking() // updateTimeRanking() //
getMyRankingInfo() //
} }
) }
// //
const RankingTop3 = computed(() => { const RankingTop3 = computed(() => {
@ -348,15 +376,17 @@ const RankingFromTop4 = computed(() => {
}) })
// //
const backgroundColor = ref('') // const backgroundColor = ref('') //
const backgroundImage = ref('') // const backgroundImage = ref('') //
const border = ref('') //
const background = ref('') //
const rankItemBackground = ref('') //
const rankItemBorder = ref('') //
const topBorderBg = ref('') //top1 const topBorderBg = ref('') //top1
const top2BorderBg = ref('') //top2 const top2BorderBg = ref('') //top2
const top3BorderBg = ref('') //top3 const top3BorderBg = ref('') //top3
const border = ref('') //
const background = ref('') //
const rankItemBackground = ref('') //
const rankItemBorder = ref('') //
const sentinel = ref(null) const sentinel = ref(null)
const stickyHeader = ref(null) const stickyHeader = ref(null)
@ -422,6 +452,7 @@ const observer = new IntersectionObserver((entries) => {
}) })
}) })
//
const getRanking = async () => { const getRanking = async () => {
console.log('获取榜单') console.log('获取榜单')
@ -439,13 +470,24 @@ const getRanking = async () => {
} }
} }
//
const getMyRankingInfo = async () => {
console.log('获取我的排名')
const resMyRanking = await getMyRanking(params_type.value, params_dateType.value)
if (resMyRanking.status && resMyRanking.body) {
myRanking.value = resMyRanking.body
} else {
myRanking.value = {}
}
}
onMounted(() => { onMounted(() => {
isInAppEnvironment.value = isInApp() isInAppEnvironment.value = isInApp()
observer.observe(sentinel.value) observer.observe(sentinel.value)
getRanking() // getRanking() //
getMyRanking() // getMyRankingInfo() //
}) })
</script> </script>