188 lines
4.5 KiB
Vue
188 lines
4.5 KiB
Vue
|
|
<script setup>
|
|||
|
|
import { ref } from "vue";
|
|||
|
|
import { onLoad } from "@dcloudio/uni-app";
|
|||
|
|
import Container from "@/components/Container.vue";
|
|||
|
|
import BowTarget from "@/components/BowTarget.vue";
|
|||
|
|
import Avatar from "@/components/Avatar.vue";
|
|||
|
|
import { roundsName } from "@/constants";
|
|||
|
|
import { getGameAPI } from "@/apis";
|
|||
|
|
import useStore from "@/store";
|
|||
|
|
import { storeToRefs } from "pinia";
|
|||
|
|
const store = useStore();
|
|||
|
|
const { user } = storeToRefs(store);
|
|||
|
|
const scores = ref([]);
|
|||
|
|
const currentUser = ref({});
|
|||
|
|
const data = ref({});
|
|||
|
|
onLoad(async (options) => {
|
|||
|
|
if (options.battleId) {
|
|||
|
|
const result = await getGameAPI(options.battleId);
|
|||
|
|
data.value = result;
|
|||
|
|
const mine = result.players.find((p) => p.playerId === user.value.id);
|
|||
|
|
currentUser.value = mine;
|
|||
|
|
if (mine && mine.arrowHistory) {
|
|||
|
|
scores.value = mine.arrowHistory;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
const onSelect = (userId) => {
|
|||
|
|
const user = data.value.players.find((p) => p.playerId === userId);
|
|||
|
|
currentUser.value = user;
|
|||
|
|
if (user && user.arrowHistory) {
|
|||
|
|
scores.value = user.arrowHistory;
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<template>
|
|||
|
|
<Container title="5人大乱斗 - 靶纸">
|
|||
|
|
<view class="container">
|
|||
|
|
<view class="rank-rows">
|
|||
|
|
<view
|
|||
|
|
v-for="(player, index) in data.players"
|
|||
|
|
:key="index"
|
|||
|
|
@click="() => onSelect(player.playerId)"
|
|||
|
|
>
|
|||
|
|
<image
|
|||
|
|
v-if="index === 0"
|
|||
|
|
src="../static/champ1.png"
|
|||
|
|
mode="widthFix"
|
|||
|
|
/>
|
|||
|
|
<image
|
|||
|
|
v-if="index === 1"
|
|||
|
|
src="../static/champ2.png"
|
|||
|
|
mode="widthFix"
|
|||
|
|
/>
|
|||
|
|
<image
|
|||
|
|
v-if="index === 2"
|
|||
|
|
src="../static/champ3.png"
|
|||
|
|
mode="widthFix"
|
|||
|
|
/>
|
|||
|
|
<view v-if="index > 2" class="rank-view">{{ index + 1 }}</view>
|
|||
|
|
<Avatar :src="player.avatar" :size="24" />
|
|||
|
|
<text
|
|||
|
|
>积分
|
|||
|
|
{{
|
|||
|
|
player.totalScore > 0
|
|||
|
|
? "+" + player.totalScore
|
|||
|
|
: player.totalScore
|
|||
|
|
}}分</text
|
|||
|
|
>
|
|||
|
|
<text>{{ player.totalRings }}环</text>
|
|||
|
|
<text v-for="(arrow, index2) in player.arrowHistory" :key="index2">
|
|||
|
|
{{ arrow.ring }}环
|
|||
|
|
</text>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
<view :style="{ margin: '20px 0' }">
|
|||
|
|
<BowTarget
|
|||
|
|
:scores="scores"
|
|||
|
|
:showLatestArrow="false"
|
|||
|
|
:avatar="currentUser ? currentUser.avatar : ''"
|
|||
|
|
/>
|
|||
|
|
</view>
|
|||
|
|
<view class="score-text"
|
|||
|
|
><text :style="{ color: '#fed847' }">{{ scores.length }}</text
|
|||
|
|
>支箭,共<text :style="{ color: '#fed847' }">{{
|
|||
|
|
scores.reduce((last, next) => last + next.ring, 0)
|
|||
|
|
}}</text
|
|||
|
|
>环</view
|
|||
|
|
>
|
|||
|
|
<view class="score-row">
|
|||
|
|
<view
|
|||
|
|
v-for="(score, index) in scores"
|
|||
|
|
:key="index"
|
|||
|
|
class="score-item"
|
|||
|
|
:style="{ width: '13vw', height: '13vw' }"
|
|||
|
|
>
|
|||
|
|
{{ score.ring }}
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</Container>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<style scoped>
|
|||
|
|
.container {
|
|||
|
|
width: 100%;
|
|||
|
|
flex-direction: column;
|
|||
|
|
justify-content: center;
|
|||
|
|
align-items: center;
|
|||
|
|
}
|
|||
|
|
.score-text {
|
|||
|
|
width: 100%;
|
|||
|
|
color: #fff;
|
|||
|
|
text-align: center;
|
|||
|
|
font-size: 16px;
|
|||
|
|
margin-bottom: 6px;
|
|||
|
|
}
|
|||
|
|
.score-row {
|
|||
|
|
margin: 10px;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
flex-wrap: wrap;
|
|||
|
|
}
|
|||
|
|
.score-item {
|
|||
|
|
background-image: url("../static/score-bg.png");
|
|||
|
|
background-size: cover;
|
|||
|
|
background-repeat: no-repeat;
|
|||
|
|
background-position: center;
|
|||
|
|
color: #fed847;
|
|||
|
|
display: flex;
|
|||
|
|
justify-content: center;
|
|||
|
|
align-items: center;
|
|||
|
|
font-size: 24px;
|
|||
|
|
margin: 3px;
|
|||
|
|
}
|
|||
|
|
.rank-rows {
|
|||
|
|
display: flex;
|
|||
|
|
flex-direction: column;
|
|||
|
|
width: 100%;
|
|||
|
|
border-top: 1px solid #fff3;
|
|||
|
|
}
|
|||
|
|
.rank-rows > view {
|
|||
|
|
width: clac(100% - 20px);
|
|||
|
|
color: #fff9;
|
|||
|
|
border-bottom: 1px solid #fff3;
|
|||
|
|
padding: 7px 10px;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
font-size: 14px;
|
|||
|
|
overflow-x: auto;
|
|||
|
|
}
|
|||
|
|
.rank-rows > view::-webkit-scrollbar {
|
|||
|
|
width: 0;
|
|||
|
|
height: 0;
|
|||
|
|
color: transparent;
|
|||
|
|
}
|
|||
|
|
.rank-rows > view > image:first-child,
|
|||
|
|
.rank-rows > view > view:first-child {
|
|||
|
|
width: 20px;
|
|||
|
|
height: 20px;
|
|||
|
|
line-height: 20px;
|
|||
|
|
text-align: center;
|
|||
|
|
font-size: 12px;
|
|||
|
|
margin-right: 10px;
|
|||
|
|
flex: 0 0 auto;
|
|||
|
|
}
|
|||
|
|
.rank-rows > view > view:first-child {
|
|||
|
|
background-color: #6d6d6d;
|
|||
|
|
border-radius: 50%;
|
|||
|
|
}
|
|||
|
|
.rank-rows > view > text {
|
|||
|
|
margin-left: 10px;
|
|||
|
|
flex: 0 0 auto;
|
|||
|
|
display: block;
|
|||
|
|
width: 25px;
|
|||
|
|
}
|
|||
|
|
.rank-rows > view > text:nth-child(3) {
|
|||
|
|
width: 80px;
|
|||
|
|
}
|
|||
|
|
.rank-rows > view > text:nth-child(4) {
|
|||
|
|
color: #fed847;
|
|||
|
|
padding-right: 10px;
|
|||
|
|
border-right: 1px solid #fff3;
|
|||
|
|
width: 32px;
|
|||
|
|
}
|
|||
|
|
</style>
|