添加排位赛记录查询

This commit is contained in:
kron
2025-06-11 23:57:03 +08:00
parent 6614e44688
commit 749796bdd9
3 changed files with 102 additions and 56 deletions

View File

@@ -83,6 +83,10 @@ export const getRoomAPI = (number) => {
return request("GET", `/user/room?number=${number}`);
};
export const joinRoomAPI = (number) => {
return request("POST", `/user/room/join`, { number });
};
export const destroyRoomAPI = (roomNumber) => {
return request("POST", "/user/room/destroyRoom", {
roomNumber,
@@ -177,6 +181,37 @@ export const simulShootAPI = (device_id, x, y) => {
return request("POST", "/index/arrow", data);
};
export const getBattleListAPI = (battleType) => {
return request("POST", "/user/battle/list", { battleType });
export const getBattleListAPI = async (page, battleType) => {
const data = [];
const result = await request("POST", "/user/battle/details/list", {
page,
battleType,
modeType: 0,
});
(result.Battles || []).forEach((item) => {
let name = "";
if (item.battleStats.mode === 1) {
name = `${item.playerStats.length / 2}V${item.playerStats.length / 2}`;
}
if (item.battleStats.mode === 2) {
name = `${item.playerStats.length}人大乱斗`;
}
data.push({
name,
battleId: item.battleStats.battleId,
mode: item.battleStats.mode,
createdAt: item.battleStats.createdAt,
gameEndAt: item.battleStats.gameEndAt,
players: item.playerStats
.map((p) => p.playerBattleStats)
.sort((a, b) => b.totalScore - a.totalScore),
});
});
return data;
};
export const getBattleDetailAPI = (id) => {
return request("POST", "/user/battle/detail", {
id,
});
};

View File

@@ -4,9 +4,8 @@ import { onLoad } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue";
import BattleHeader from "@/components/BattleHeader.vue";
import Avatar from "@/components/Avatar.vue";
import { getBattleDetailAPI } from "@/apis";
const id = ref("");
const type = ref("");
const data = {
blueTeam: {
name: "选手1",
@@ -44,9 +43,11 @@ const result = ref([
},
]);
onLoad((options) => {
type.value = options.type;
id.value = options.id;
onLoad(async (options) => {
if (options.id) {
const result = await getBattleDetailAPI(options.id);
console.log(11111, result);
}
});
</script>

View File

@@ -7,14 +7,22 @@ import { getBattleListAPI, getPractiseResultListAPI } from "@/apis";
import { ref } from "vue";
const selectedIndex = ref(0);
const matchPage = ref(1);
const matchList = ref([]);
const practiseList = ref([]);
const battlePage = ref(1);
const battleList = ref([]);
const handleSelect = async (index) => {
if (index === 0) {
const result = await getBattleListAPI(1);
const result = await getBattleListAPI(matchPage.value, 2);
matchList.value = result.list;
matchPage.value += 1;
}
if (index === 1) {
const result = await getBattleListAPI(2);
// const result = await getBattleListAPI(battlePage.value, 1);
// battleList.value = result.list;
// battlePage.value += 1;
}
if (index === 2) {
const result = await getPractiseResultListAPI();
@@ -23,13 +31,15 @@ const handleSelect = async (index) => {
selectedIndex.value = index;
};
const toMatchDetail = () => {
const toMatchDetail = (id) => {
uni.navigateTo({
url: "/pages/match-detail",
url: `/pages/match-detail?id=${id}`,
});
};
onMounted(async () => {
const result = await getBattleListAPI(2);
const result = await getBattleListAPI(matchPage.value, 2);
matchList.value = result;
matchPage.value += 1;
});
</script>
@@ -53,57 +63,51 @@ onMounted(async () => {
<view class="contents">
<view
:style="{
display: selectedIndex !== 2 ? 'flex' : 'none',
display: selectedIndex === 0 ? 'flex' : 'none',
}"
>
<view @click="toMatchDetail">
<view
v-for="(item, index) in matchList"
:key="index"
@click="() => toMatchDetail(item.battleId)"
>
<view class="contest-header">
<text>1V1</text>
<text>2025.01.21 14:09:23</text>
<text>{{ item.name }}</text>
<text>{{ item.createdAt }}</text>
<image src="../static/back.png" mode="widthFix" />
</view>
<view class="contest-1v1">
<view class="player">
<Avatar frame src="../static/avatar.png" />
<text>选手1</text>
<image src="../static/winner-badge.png" mode="widthFix" />
</view>
<view class="player">
<Avatar frame src="../static/avatar.png" />
<text>选手2</text>
<view v-if="item.mode === 1" class="contest-team">
<view
class="player"
v-for="(p, index2) in item.players"
:key="index2"
>
<Avatar frame :src="p.avatar" />
<text>{{ p.name }}</text>
<image
v-if="index2 === 0"
src="../static/winner-badge.png"
mode="widthFix"
/>
</view>
</view>
</view>
<view @click="toMatchDetail">
<view class="contest-header">
<text>5v5</text>
<text>2025.01.21 14:09:23</text>
<image src="../static/back.png" mode="widthFix" />
</view>
<view class="contest-multi">
<view class="player">
<Avatar :rank="1" src="../static/avatar.png" />
<text>选手1</text>
</view>
<view class="player">
<Avatar :rank="2" src="../static/avatar.png" />
<text>选手2</text>
</view>
<view class="player">
<Avatar :rank="3" src="../static/avatar.png" />
<text>选手3</text>
</view>
<view class="player">
<Avatar :rank="4" src="../static/avatar.png" />
<text>选手4</text>
</view>
<view class="player">
<Avatar :rank="5" src="../static/avatar.png" />
<text>选手5</text>
<view v-if="item.mode === 2" class="contest-multi">
<view
class="player"
v-for="(p, index2) in item.players"
:key="index2"
>
<Avatar :rank="index2 + 1" :src="p.avatar" />
<text>{{ p.name }}</text>
</view>
</view>
</view>
</view>
<view
:style="{
display: selectedIndex === 1 ? 'flex' : 'none',
}"
></view>
<view
:style="{
display: selectedIndex === 2 ? 'flex' : 'none',
@@ -180,6 +184,12 @@ onMounted(async () => {
}
.player > text {
margin-top: 5px;
font-size: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 90%;
text-align: center;
}
.player > image:last-child {
position: absolute;
@@ -187,19 +197,19 @@ onMounted(async () => {
right: 0;
bottom: 0;
}
.contest-1v1,
.contest-team,
.contest-multi {
display: flex;
justify-content: space-around;
margin-bottom: 10px;
}
.contest-1v1 > view {
.contest-team > view {
width: 50%;
}
.contest-1v1 > view:first-child {
.contest-team > view:first-child {
background-color: #364469;
}
.contest-1v1 > view:last-child {
.contest-team > view:last-child {
background-color: #692735;
}
.contest-multi > view {