fix:优化完整成绩页面展示
This commit is contained in:
@@ -20,25 +20,47 @@ onLoad(async (options) => {
|
||||
const result = await getBattleAPI(battleId.value);
|
||||
data.value = result;
|
||||
if (result.mode > 3) {
|
||||
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);
|
||||
// 以 id 为 key 建立 teams 玩家快速查找表
|
||||
const teamPlayerMap = {};
|
||||
plist.forEach((p) => { teamPlayerMap[p.id] = p; });
|
||||
|
||||
// 处理有成绩的玩家(resultList 顺序即排名顺序)
|
||||
const rankedPlayers = (result.resultList || []).map((item, index) => {
|
||||
const playerId = item.userId || item.id;
|
||||
const p = teamPlayerMap[playerId] || item;
|
||||
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;
|
||||
result.rounds.forEach((r, rIndex) => {
|
||||
if (r.shoots[playerId]) {
|
||||
r.shoots[playerId].forEach((s, sIndex) => {
|
||||
arrows[sIndex + rIndex * 6] = s;
|
||||
});
|
||||
}
|
||||
});
|
||||
return {
|
||||
...item,
|
||||
id: playerId,
|
||||
rank: index + 1,
|
||||
name: p.name,
|
||||
avatar: p.avatar || "",
|
||||
name: (p && p.name) || item.name,
|
||||
avatar: (p && p.avatar) || item.avatar || "",
|
||||
arrows,
|
||||
};
|
||||
});
|
||||
|
||||
// 追加未出现在 resultList 中的玩家(未射箭),rank=0 隐藏角标
|
||||
const rankedIds = new Set(rankedPlayers.map((p) => p.id));
|
||||
const unrankedPlayers = plist
|
||||
.filter((p) => !rankedIds.has(p.id))
|
||||
.map((p) => ({
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
avatar: p.avatar || "",
|
||||
arrows: [],
|
||||
totalScore: 0,
|
||||
rank: 0,
|
||||
}));
|
||||
|
||||
players.value = [...rankedPlayers, ...unrankedPlayers];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -84,7 +106,7 @@ const checkBowData = (selected) => {
|
||||
:avatar="player.avatar"
|
||||
:arrows="player.arrows"
|
||||
:totalScore="player.totalScore"
|
||||
:rank="index + 1"
|
||||
:rank="player.rank"
|
||||
/>
|
||||
<view
|
||||
v-if="data.mode <= 3"
|
||||
|
||||
Reference in New Issue
Block a user