完成打乱斗数据调试

This commit is contained in:
kron
2026-02-07 10:52:56 +08:00
parent 09d8e7b3da
commit 6101cd80ce
20 changed files with 444 additions and 473 deletions

View File

@@ -4,28 +4,39 @@ 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 { getGameAPI } from "@/apis";
import { getBattleAPI } 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({});
const onSelect = (userId) => {
const user = data.value.players.find((p) => p.playerId === userId);
currentUser.value = user;
if (user && user.arrowHistory) {
scores.value = user.arrowHistory;
}
};
const { user } = storeToRefs(useStore());
const currentUser = ref({
arrows: [],
});
const players = ref([]);
onLoad(async (options) => {
if (options.battleId) {
const result = await getGameAPI(options.battleId);
data.value = result;
if (result.players && result.players[0]) {
onSelect(result.players[0].playerId);
}
if (!options.id) return;
const result = await getBattleAPI(options.battleId || "59090720979554304");
players.value = result.resultList.map((item, index) => {
const plist = result.teams[0] ? result.teams[0].players : [];
const p = plist.find((p) => p.id === item.userId);
const arrows = new Array(12);
result.rounds.forEach((r, index) => {
if (r.shoots[item.userId]) {
r.shoots[item.userId].forEach((s, index2) => {
arrows[index2 + index * 6] = s;
});
}
});
return {
...item,
rank: index + 1,
name: p.name,
avatar: p.avatar || "",
arrows,
};
});
if (players.value[0]) {
currentUser.value = players.value[0];
}
});
</script>
@@ -33,22 +44,26 @@ onLoad(async (options) => {
<template>
<Container title="靶纸">
<view class="container">
<image src="../static/battle-header-melee.png" mode="widthFix" />
<view class="players" v-if="data.players">
<image
src="../static/battle-header-melee.png"
mode="widthFix"
:style="{ top: '-50rpx' }"
/>
<view class="players">
<view
v-for="(player, index) in data.players"
v-for="(player, index) in players"
:key="index"
:style="{
width: `${Math.max(100 / data.players.length, 18)}vw`,
color: player.playerId === currentUser.playerId ? '#000' : '#fff9',
width: `${Math.max(100 / players.length, 18)}vw`,
color: player.userId === currentUser.userId ? '#000' : '#fff9',
}"
@click="() => onSelect(player.playerId)"
@click="currentUser = player"
>
<image
v-if="player.playerId === currentUser.playerId"
v-if="player.userId === currentUser.userId"
src="../static/player-bg2.png"
:style="{
width: `${Math.max(100 / data.players.length, 18)}vw`,
width: `${Math.max(100 / players.length, 18)}vw`,
}"
class="player-bg"
/>
@@ -57,18 +72,20 @@ onLoad(async (options) => {
</view>
</view>
<view :style="{ marginTop: '10px' }">
<BowTarget :scores="scores" />
<BowTarget :scores="currentUser.arrows" />
</view>
<view class="score-text"
><text :style="{ color: '#fed847' }">{{ scores.length }}</text
><text :style="{ color: '#fed847' }">{{
currentUser.arrows.length
}}</text
>支箭<text :style="{ color: '#fed847' }">{{
scores.reduce((last, next) => last + next.ring, 0)
currentUser.arrows.reduce((last, next) => last + next.ring, 0)
}}</text
></view
>
<view class="score-row">
<view class="score-row" v-if="currentUser.arrows">
<view
v-for="(score, index) in scores"
v-for="(score, index) in currentUser.arrows"
:key="index"
class="score-item"
:style="{ width: '13vw', height: '13vw' }"
@@ -97,7 +114,7 @@ onLoad(async (options) => {
display: flex;
width: 100%;
overflow-x: auto;
margin-top: 25px;
margin-top: 50rpx;
}
.players::-webkit-scrollbar {
width: 0;