diff --git a/src/pages/be-vip.vue b/src/pages/be-vip.vue index 101423f..571de72 100644 --- a/src/pages/be-vip.vue +++ b/src/pages/be-vip.vue @@ -6,6 +6,7 @@ import SButton from "@/components/SButton.vue"; import SModal from "@/components/SModal.vue"; import Signin from "@/components/Signin.vue"; import { createOrderAPI } from "@/apis"; +import { formatTimestamp } from "@/util"; import useStore from "@/store"; import { storeToRefs } from "pinia"; const store = useStore(); @@ -38,7 +39,9 @@ const onPay = async () => { {{ user.nickName }} - 5月5号到期 + {{ formatTimestamp(user.expiredAt) }}到期 diff --git a/src/pages/rank-list.vue b/src/pages/rank-list.vue index dd255a3..208da75 100644 --- a/src/pages/rank-list.vue +++ b/src/pages/rank-list.vue @@ -5,17 +5,27 @@ import useStore from "@/store"; import { storeToRefs } from "pinia"; const store = useStore(); const { user, rankData } = storeToRefs(store); +const { getLvlName } = store; const isIos = ref(true); const selectedIndex = ref(0); +const currentList = ref([]); onMounted(async () => { const deviceInfo = uni.getDeviceInfo(); isIos.value = deviceInfo.osName === "ios"; + currentList.value = rankData.value.rank; }); const handleSelect = (index) => { selectedIndex.value = index; + if (index === 0) { + currentList.value = rankData.value.rank; + } else if (index === 2) { + currentList.value = rankData.value.ringRank; + } else { + currentList.value = []; + } }; const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"]; @@ -52,7 +62,7 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"]; {{ subTitles[selectedIndex] }} {{ index + 1 }} - + - 打酱油大声路过 - 钻石3级,20场 + {{ item.name }} + {{ getLvlName(item.totalScore) }},{{ item.TotalGames }}场 9999{{ item.totalScore }} diff --git a/src/pages/ranking.vue b/src/pages/ranking.vue index 3d6f898..e361b99 100644 --- a/src/pages/ranking.vue +++ b/src/pages/ranking.vue @@ -7,19 +7,25 @@ import { topThreeColors } from "@/constants"; import useStore from "@/store"; import { storeToRefs } from "pinia"; const store = useStore(); -const { user, device } = storeToRefs(store); +const { user, device, rankData } = storeToRefs(store); +const { getLvlName } = store; -const rankData = ref({}); const selectedIndex = ref(0); +const currentList = ref([]); const handleSelect = (index) => { selectedIndex.value = index; + if (index === 0) { + currentList.value = rankData.value.rank.slice(0, 10); + } else if (index === 2) { + currentList.value = rankData.value.ringRank.slice(0, 10); + } else { + currentList.value = []; + } }; onMounted(async () => { - const rankList = await getRankListAPI(); - console.log("排位赛数据:", rankList); - rankData.value = rankList; + currentList.value = rankData.value.rank; }); const toTeamMatchPage = (gameType, teamSize) => { @@ -142,128 +148,43 @@ const toRankListPage = () => { {{ rankType }} - - - + + + {{ index + 1 }} + + + {{ item.name }} + {{ getLvlName(item.totalScore) }},{{ item.TotalGames }}场 - - - - {{ rankType }} - - - {{ rankData.rank[index].name }} - 钻石三级,20场 - - {{ rankData.rank[index].totalScore }} - - - - - - - - {{ rankType }} - - - {{ - rankData.ringRank[index].name - }} - 钻石三级,20场 - - {{ rankData.ringRank[index].totalScore }} - - - - - - - - {{ rankType }} - - - 打酱油大声路过 - 钻石三级,20场 - - 8850 - - - + + {{ item.totalScore }} + 点击查看更多 diff --git a/src/store.js b/src/store.js index b6da364..14a645d 100644 --- a/src/store.js +++ b/src/store.js @@ -33,6 +33,21 @@ export default defineStore("store", { // 方法 actions: { + getLvlName(score) { + let lvlName = ""; + const rankInfos = this.config.randInfos || []; + rankInfos.some((r, index) => { + lvlName = rankInfos[index].name; + if (r.upgrade_scores > score) { + if (rankInfos[index - 1]) { + lvlName = rankInfos[index - 1].name; + } + return true; + } + return false; + }); + return lvlName; + }, updateRank(data = {}) { this.rankData = { rank: data.rank || [], ringRank: data.ringRank || [] }; }, diff --git a/src/util.js b/src/util.js index 6849dba..f027077 100644 --- a/src/util.js +++ b/src/util.js @@ -1,5 +1,14 @@ import websocket from "@/websocket"; +export const formatTimestamp = (timestamp) => { + const date = new Date(timestamp); + const year = date.getFullYear(); + const month = date.getMonth() + 1; + const day = date.getDate(); + + return `${year}.${month}.${day}`; +}; + export const checkConnection = () => { uni.sendSocketMessage({ data: JSON.stringify({ event: "ping", data: {} }),