Files
shoot-miniprograms/src/pages/rank-list.vue

404 lines
9.6 KiB
Vue
Raw Normal View History

2025-06-17 12:01:44 +08:00
<script setup>
import { ref, onMounted } from "vue";
import Avatar from "@/components/Avatar.vue";
2025-06-28 12:03:33 +08:00
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user, rankData } = storeToRefs(store);
2025-07-01 10:57:49 +08:00
const { getLvlName } = store;
2025-06-26 23:41:23 +08:00
2025-08-07 10:48:05 +08:00
const capsuleHeight = ref(0);
2025-06-26 23:41:23 +08:00
const selectedIndex = ref(0);
2025-07-01 10:57:49 +08:00
const currentList = ref([]);
2025-07-18 22:17:17 +08:00
const myData = ref({});
2025-07-13 13:28:21 +08:00
const addBg = ref("");
2025-06-17 12:01:44 +08:00
2025-06-26 23:41:23 +08:00
onMounted(async () => {
2025-08-07 10:48:05 +08:00
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
capsuleHeight.value = menuBtnInfo.top - 9;
2025-08-18 16:09:11 +08:00
handleSelect(0);
2025-06-17 12:01:44 +08:00
});
const handleSelect = (index) => {
selectedIndex.value = index;
2025-08-18 16:09:11 +08:00
myData.value = {};
currentList.value = [];
2025-07-01 10:57:49 +08:00
if (index === 0) {
currentList.value = rankData.value.rank;
2025-08-15 16:15:36 +08:00
} else if (index === 1) {
currentList.value = rankData.value.mvpRank;
2025-07-01 10:57:49 +08:00
} else if (index === 2) {
currentList.value = rankData.value.ringRank;
2025-08-18 16:09:11 +08:00
}
if (user.value.id) {
currentList.value.some((item) => {
if (item.userId === user.value.id) {
myData.value = item;
return true;
}
return false;
});
2025-08-21 09:36:00 +08:00
if (!myData.value.userId) {
myData.value = {
userId: user.value.id,
TotalGames: 0,
totalScore: 0,
mvpCount: 0,
TenRings: 0,
};
}
2025-07-01 10:57:49 +08:00
}
2025-06-17 12:01:44 +08:00
};
2025-07-10 15:34:00 +08:00
const onScrollView = (e) => {
2025-07-13 13:28:21 +08:00
addBg.value = e.detail.scrollTop > 100;
2025-07-10 15:34:00 +08:00
};
2025-08-20 13:53:14 +08:00
const subTitles = ["排位赛积分", "MVP次数", "十环次数"];
2025-06-17 12:01:44 +08:00
</script>
<template>
2025-08-21 10:27:16 +08:00
<view class="container">
2025-07-10 15:34:00 +08:00
<view
class="header"
:style="{
2025-08-07 10:48:05 +08:00
paddingTop: capsuleHeight + 'px',
2025-07-10 15:34:00 +08:00
}"
2025-06-17 12:01:44 +08:00
>
2025-07-13 13:28:21 +08:00
<image
v-if="addBg"
class="bg-image"
src="../static/app-bg.png"
mode="widthFix"
/>
2025-07-10 15:34:00 +08:00
<navigator open-type="navigateBack">
2025-07-13 13:28:21 +08:00
<image class="header-back" src="../static/back.png" mode="widthFix" />
2025-07-10 15:34:00 +08:00
</navigator>
2025-08-07 10:48:05 +08:00
<text
:style="{ opacity: addBg ? 1 : 0, color: '#fff', fontWeight: 'bold' }"
>
2025-07-13 13:28:21 +08:00
本赛季排行榜
</text>
2025-07-10 15:34:00 +08:00
</view>
2025-08-21 10:27:16 +08:00
<scroll-view
scroll-y
@scroll="onScrollView"
:style="{ height: myData.userId ? '90vh' : '100vh' }"
>
2025-09-25 16:04:37 +08:00
<image
src="https://static.shelingxingqiu.com/attachment/2025-09-25/dd1p9b3wcrwnlnghiq.png"
mode="widthFix"
class="header-bg"
/>
2025-08-21 10:27:16 +08:00
<view class="rank-tabs">
<view
v-for="(rankType, index) in ['积分榜', 'MVP榜', '十环榜']"
:key="index"
:style="{
fontSize: index === selectedIndex ? '16px' : '14px',
color: index === selectedIndex ? '#000' : '#fff',
backgroundColor: index === selectedIndex ? '#FFD947' : '#383737',
}"
@tap="handleSelect(index)"
>
{{ rankType }}
2025-06-17 12:01:44 +08:00
</view>
</view>
2025-08-21 10:27:16 +08:00
<view class="rank-list">
<view class="rank-list-header">
<text>排名</text>
<text>用户ID</text>
<text>{{ subTitles[selectedIndex] }}</text>
</view>
<view
v-for="(item, index) in currentList"
:key="index"
class="rank-list-item"
:style="{
backgroundColor: index % 2 === 0 ? '#9898981f' : 'transparent',
}"
>
<image
v-if="index === 0"
class="player-bg"
src="../static/melee-player-bg1.png"
mode="aspectFill"
/>
<image
v-if="index === 1"
class="player-bg"
src="../static/melee-player-bg2.png"
mode="aspectFill"
/>
<image
v-if="index === 2"
class="player-bg"
src="../static/melee-player-bg3.png"
mode="aspectFill"
/>
<image
v-if="index === 0"
class="player-crown"
src="../static/champ1.png"
mode="widthFix"
/>
<image
v-if="index === 1"
class="player-crown"
src="../static/champ2.png"
mode="widthFix"
/>
<image
v-if="index === 2"
class="player-crown"
src="../static/champ3.png"
mode="widthFix"
/>
<view v-if="index > 2" class="view-crown">{{ index + 1 }}</view>
<Avatar :src="item.avatar" />
<view class="rank-item-content">
<text class="truncate">{{ item.name }}</text>
<text
>{{ getLvlName(item.totalScore) }}{{ item.TotalGames }}</text
>
</view>
<text class="rank-item-integral" v-if="selectedIndex === 0">
<text
:style="{ fontSize: '14px', color: '#fff', marginRight: '5px' }"
>{{ item.totalScore }} </text
>
</text>
<text class="rank-item-integral" v-if="selectedIndex === 1">
<text
:style="{ fontSize: '14px', color: '#fff', marginRight: '5px' }"
>{{ item.mvpCount }} </text
>
</text>
<text class="rank-item-integral" v-if="selectedIndex === 2">
<text
:style="{ fontSize: '14px', color: '#fff', marginRight: '5px' }"
>{{ item.TenRings }} </text
>
</text>
</view>
<view v-if="!currentList.length" class="no-data">
<text>筹备中...</text>
</view>
2025-07-11 00:56:39 +08:00
</view>
2025-08-21 10:27:16 +08:00
</scroll-view>
2025-07-18 22:17:17 +08:00
<view class="my-rank-data" v-if="myData.userId">
2025-08-07 10:48:05 +08:00
<image
src="https://static.shelingxingqiu.com/attachment/2025-08-05/dbuaf19pf7qd8ps0uh.png"
mode="widthFix"
/>
2025-07-03 11:40:03 +08:00
<text>{{ myData.rank }}</text>
2025-06-28 12:03:33 +08:00
<Avatar :src="user.avatar" />
2025-06-17 12:01:44 +08:00
<view class="rank-item-content">
2025-06-28 12:03:33 +08:00
<text class="truncate">{{ user.nickName }}</text>
2025-07-28 15:05:19 +08:00
<text>{{ user.lvlName }}{{ myData.TotalGames }}</text>
2025-06-17 12:01:44 +08:00
</view>
2025-08-18 16:09:11 +08:00
<text class="rank-item-integral" v-if="selectedIndex === 0">
<text
:style="{ fontSize: '14px', color: '#fff', marginRight: '5px' }"
2025-08-21 09:36:00 +08:00
>{{ myData.totalScore || 0 }}</text
2025-08-19 09:44:15 +08:00
></text
2025-08-18 16:09:11 +08:00
>
<text class="rank-item-integral" v-if="selectedIndex === 1">
2025-07-18 22:17:17 +08:00
<text
2025-07-17 15:50:49 +08:00
:style="{ fontSize: '14px', color: '#fff', marginRight: '5px' }"
2025-08-21 09:36:00 +08:00
>{{ myData.mvpCount || 0 }}</text
2025-07-17 15:50:49 +08:00
></text
>
2025-08-18 16:09:11 +08:00
<text class="rank-item-integral" v-if="selectedIndex === 2">
2025-07-18 22:17:17 +08:00
<text
2025-06-28 12:03:33 +08:00
:style="{ fontSize: '14px', color: '#fff', marginRight: '5px' }"
2025-08-21 09:36:00 +08:00
>{{ myData.TenRings || 0 }}</text
2025-08-18 16:09:11 +08:00
></text
2025-06-17 12:01:44 +08:00
>
</view>
2025-08-21 10:27:16 +08:00
</view>
2025-06-17 12:01:44 +08:00
</template>
<style scoped>
.container {
2025-07-10 15:34:00 +08:00
width: 100%;
2025-06-17 12:01:44 +08:00
}
.header-bg {
width: 100%;
}
2025-07-10 15:34:00 +08:00
.header {
width: 100%;
2025-08-07 10:48:05 +08:00
height: 50px;
2025-06-17 12:01:44 +08:00
display: flex;
2025-08-07 10:48:05 +08:00
align-items: center;
2025-07-10 15:34:00 +08:00
position: fixed;
top: 0;
transition: all 0.3s ease;
z-index: 10;
2025-07-13 13:28:21 +08:00
overflow: hidden;
2025-07-10 15:34:00 +08:00
}
.header text {
transition: all 0.3s ease;
2025-08-07 10:48:05 +08:00
line-height: 50px;
2025-07-13 13:28:21 +08:00
position: relative;
2025-06-17 12:01:44 +08:00
}
.rank-tabs {
width: calc(100% - 20px);
display: flex;
justify-content: space-around;
padding: 0 10px;
margin-top: -15px;
}
.rank-tabs > view {
width: 25%;
padding: 10px;
text-align: center;
border-radius: 20px;
}
.rank-list {
display: flex;
flex-direction: column;
align-items: center;
width: calc(100% - 20px);
color: #fff9;
font-size: 12px;
margin: 10px;
border: 1px solid rgb(255 217 71 / 0.2);
border-radius: 10px;
background-color: #313131;
}
.rank-list > view {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
overflow: hidden;
position: relative;
}
.rank-list-header {
width: calc(100% - 20px) !important;
padding: 10px;
}
.rank-list-header > text:nth-child(2) {
width: 14%;
}
.rank-list-header > text:last-child {
width: 30%;
text-align: right;
}
.rank-list-item {
padding: 10px 0;
}
.player-bg {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.player-crown {
position: relative;
width: 27px;
2025-08-20 13:53:14 +08:00
height: 27px;
2025-06-17 12:01:44 +08:00
margin: 0 15px;
}
.view-crown {
width: 27px;
height: 27px;
line-height: 27px;
text-align: center;
border-radius: 50%;
margin: 0 15px;
color: #fff;
background-color: #676767;
position: relative;
}
.rank-item-content {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
width: 50%;
position: relative;
padding-left: 10px;
}
.rank-item-content > text:first-child {
color: #fff;
font-size: 14px;
margin-bottom: 3px;
2025-06-28 12:03:33 +08:00
width: 120px;
2025-06-17 12:01:44 +08:00
}
.rank-list-item > text:last-child {
margin-right: 10px;
2025-07-17 09:57:08 +08:00
width: 56px;
text-align: right;
2025-06-17 12:01:44 +08:00
}
.my-rank-data {
width: calc(100% - 30px);
padding: 15px;
display: flex;
align-items: center;
justify-content: space-between;
color: #fff9;
font-size: 12px;
2025-08-21 10:27:16 +08:00
height: calc(10vh - 30px);
position: relative;
overflow: hidden;
border-radius: 10px;
2025-06-17 12:01:44 +08:00
}
.my-rank-data > image:first-child {
position: absolute;
width: 100%;
left: 0;
top: -5px;
}
.my-rank-data > text:nth-child(2) {
background-color: #c1a434;
position: relative;
color: #fff;
padding: 3px 5px;
border-radius: 20px;
2025-07-17 09:57:08 +08:00
margin: 10px;
2025-06-17 12:01:44 +08:00
font-size: 14px;
2025-07-18 22:17:17 +08:00
min-width: 15px;
text-align: center;
2025-06-17 12:01:44 +08:00
}
.my-rank-data > text:last-child {
position: relative;
margin-right: 10px;
2025-07-18 22:17:17 +08:00
width: 65px;
2025-07-17 09:57:08 +08:00
text-align: right;
2025-06-17 12:01:44 +08:00
}
.my-rank-data > .rank-item-content > text:first-child {
color: #fed847;
}
.my-rank-data > .rank-item-integral {
color: #fff9;
font-size: 12px;
margin-right: 0 !important;
}
2025-07-11 00:56:39 +08:00
.no-data {
width: 100%;
height: 400px;
display: flex;
justify-content: center !important;
align-items: center;
color: #fff9;
font-size: 14px;
}
2025-07-13 13:28:21 +08:00
.header-back {
width: 22px;
height: 22px;
2025-08-07 10:48:05 +08:00
margin: 0px 15px;
2025-08-21 10:27:16 +08:00
margin-top: 5px;
2025-07-13 13:28:21 +08:00
position: relative;
}
.bg-image {
width: 100vw;
height: 100vh;
position: absolute;
top: 0;
left: 0;
}
2025-06-17 12:01:44 +08:00
</style>