fix:优化完整成绩页面展示
This commit is contained in:
@@ -20,25 +20,47 @@ onLoad(async (options) => {
|
|||||||
const result = await getBattleAPI(battleId.value);
|
const result = await getBattleAPI(battleId.value);
|
||||||
data.value = result;
|
data.value = result;
|
||||||
if (result.mode > 3) {
|
if (result.mode > 3) {
|
||||||
players.value = result.resultList.map((item, index) => {
|
|
||||||
const plist = result.teams[0] ? result.teams[0].players : [];
|
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);
|
const arrows = new Array(12);
|
||||||
result.rounds.forEach((r, index) => {
|
result.rounds.forEach((r, rIndex) => {
|
||||||
if (r.shoots[item.userId]) {
|
if (r.shoots[playerId]) {
|
||||||
r.shoots[item.userId].forEach((s, index2) => {
|
r.shoots[playerId].forEach((s, sIndex) => {
|
||||||
arrows[index2 + index * 6] = s;
|
arrows[sIndex + rIndex * 6] = s;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
|
id: playerId,
|
||||||
rank: index + 1,
|
rank: index + 1,
|
||||||
name: p.name,
|
name: (p && p.name) || item.name,
|
||||||
avatar: p.avatar || "",
|
avatar: (p && p.avatar) || item.avatar || "",
|
||||||
arrows,
|
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"
|
:avatar="player.avatar"
|
||||||
:arrows="player.arrows"
|
:arrows="player.arrows"
|
||||||
:totalScore="player.totalScore"
|
:totalScore="player.totalScore"
|
||||||
:rank="index + 1"
|
:rank="player.rank"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
v-if="data.mode <= 3"
|
v-if="data.mode <= 3"
|
||||||
|
|||||||
Reference in New Issue
Block a user