排行榜数据显示
This commit is contained in:
@@ -4,7 +4,7 @@ import Avatar from "@/components/Avatar.vue";
|
|||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user, config } = storeToRefs(store);
|
const { user, config, rankData } = storeToRefs(store);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
showRank: {
|
showRank: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -89,13 +89,18 @@ watch(
|
|||||||
src="../static/global-rank.png"
|
src="../static/global-rank.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
<text>本赛季</text>
|
<block v-if="user.ranking > 0 && rankData.rank.length">
|
||||||
<text>暂未上榜</text>
|
<text>本赛季全国</text>
|
||||||
<!-- <text class="rank-number"
|
<text class="rank-number"
|
||||||
>第<text :style="{ color: '#ffd700' }"
|
>第<text :style="{ color: '#ffd700' }"
|
||||||
>{{ user.points }}/{{ user.rankLvl }}</text
|
>{{ user.ranking }}/{{ rankData.rank.length }}</text
|
||||||
>名</text
|
>名</text
|
||||||
> -->
|
>
|
||||||
|
</block>
|
||||||
|
<block v-else>
|
||||||
|
<text>本赛季</text>
|
||||||
|
<text>暂未上榜</text>
|
||||||
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<block v-else>
|
<block v-else>
|
||||||
|
|||||||
@@ -15,12 +15,11 @@ import { topThreeColors } from "@/constants";
|
|||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { updateConfig, updateUser, updateDevice } = store;
|
const { updateConfig, updateUser, updateDevice, updateRank } = store;
|
||||||
// 使用storeToRefs,用于UI里显示,保持响应性
|
// 使用storeToRefs,用于UI里显示,保持响应性
|
||||||
const { user, device, remoteConnect } = storeToRefs(store);
|
const { user, device, remoteConnect, rankData } = storeToRefs(store);
|
||||||
const showModal = ref(false);
|
const showModal = ref(false);
|
||||||
const isIos = ref(true);
|
const isIos = ref(true);
|
||||||
const rankData = ref({});
|
|
||||||
|
|
||||||
const toPage = (path) => {
|
const toPage = (path) => {
|
||||||
if (!user.value.id) {
|
if (!user.value.id) {
|
||||||
@@ -53,11 +52,11 @@ onMounted(async () => {
|
|||||||
const deviceInfo = uni.getDeviceInfo();
|
const deviceInfo = uni.getDeviceInfo();
|
||||||
isIos.value = deviceInfo.osName === "ios";
|
isIos.value = deviceInfo.osName === "ios";
|
||||||
const config = await getAppConfig();
|
const config = await getAppConfig();
|
||||||
|
updateConfig(config);
|
||||||
console.log("全局配置:", config);
|
console.log("全局配置:", config);
|
||||||
const rankList = await getRankListAPI();
|
const rankList = await getRankListAPI();
|
||||||
if (rankList) rankData.value = rankList;
|
|
||||||
console.log("排位赛数据:", rankList);
|
console.log("排位赛数据:", rankList);
|
||||||
updateConfig(config);
|
updateRank(rankList);
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
if (token) {
|
if (token) {
|
||||||
const result = await getHomeData();
|
const result = await getHomeData();
|
||||||
@@ -148,7 +147,7 @@ const comingSoon = () => {
|
|||||||
</block>
|
</block>
|
||||||
</block>
|
</block>
|
||||||
<view class="more-players" @click="toRankListPage">
|
<view class="more-players" @click="toRankListPage">
|
||||||
<text>456{{ remoteConnect ? 1 : 0 }}</text>
|
<text>{{ rankData.rank.length }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ export default defineStore("store", {
|
|||||||
deviceName: "",
|
deviceName: "",
|
||||||
},
|
},
|
||||||
config: {},
|
config: {},
|
||||||
|
rankData: {
|
||||||
|
rank: [],
|
||||||
|
ringRank: [],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
@@ -30,6 +34,9 @@ export default defineStore("store", {
|
|||||||
|
|
||||||
// 方法
|
// 方法
|
||||||
actions: {
|
actions: {
|
||||||
|
updateRank(data = {}) {
|
||||||
|
this.rankData = { rank: data.rank || [], ringRank: data.ringRank || [] };
|
||||||
|
},
|
||||||
updateConnect(connect) {
|
updateConnect(connect) {
|
||||||
this.remoteConnect = connect;
|
this.remoteConnect = connect;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user