添加排位赛记录查询
This commit is contained in:
39
src/apis.js
39
src/apis.js
@@ -83,6 +83,10 @@ export const getRoomAPI = (number) => {
|
|||||||
return request("GET", `/user/room?number=${number}`);
|
return request("GET", `/user/room?number=${number}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const joinRoomAPI = (number) => {
|
||||||
|
return request("POST", `/user/room/join`, { number });
|
||||||
|
};
|
||||||
|
|
||||||
export const destroyRoomAPI = (roomNumber) => {
|
export const destroyRoomAPI = (roomNumber) => {
|
||||||
return request("POST", "/user/room/destroyRoom", {
|
return request("POST", "/user/room/destroyRoom", {
|
||||||
roomNumber,
|
roomNumber,
|
||||||
@@ -177,6 +181,37 @@ export const simulShootAPI = (device_id, x, y) => {
|
|||||||
return request("POST", "/index/arrow", data);
|
return request("POST", "/index/arrow", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBattleListAPI = (battleType) => {
|
export const getBattleListAPI = async (page, battleType) => {
|
||||||
return request("POST", "/user/battle/list", { 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,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import { onLoad } from "@dcloudio/uni-app";
|
|||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import BattleHeader from "@/components/BattleHeader.vue";
|
import BattleHeader from "@/components/BattleHeader.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
import { getBattleDetailAPI } from "@/apis";
|
||||||
|
|
||||||
const id = ref("");
|
|
||||||
const type = ref("");
|
|
||||||
const data = {
|
const data = {
|
||||||
blueTeam: {
|
blueTeam: {
|
||||||
name: "选手1",
|
name: "选手1",
|
||||||
@@ -44,9 +43,11 @@ const result = ref([
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad(async (options) => {
|
||||||
type.value = options.type;
|
if (options.id) {
|
||||||
id.value = options.id;
|
const result = await getBattleDetailAPI(options.id);
|
||||||
|
console.log(11111, result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,22 @@ import { getBattleListAPI, getPractiseResultListAPI } from "@/apis";
|
|||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
const selectedIndex = ref(0);
|
const selectedIndex = ref(0);
|
||||||
|
const matchPage = ref(1);
|
||||||
|
const matchList = ref([]);
|
||||||
const practiseList = ref([]);
|
const practiseList = ref([]);
|
||||||
|
const battlePage = ref(1);
|
||||||
|
const battleList = ref([]);
|
||||||
|
|
||||||
const handleSelect = async (index) => {
|
const handleSelect = async (index) => {
|
||||||
if (index === 0) {
|
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) {
|
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) {
|
if (index === 2) {
|
||||||
const result = await getPractiseResultListAPI();
|
const result = await getPractiseResultListAPI();
|
||||||
@@ -23,13 +31,15 @@ const handleSelect = async (index) => {
|
|||||||
selectedIndex.value = index;
|
selectedIndex.value = index;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toMatchDetail = () => {
|
const toMatchDetail = (id) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/match-detail",
|
url: `/pages/match-detail?id=${id}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const result = await getBattleListAPI(2);
|
const result = await getBattleListAPI(matchPage.value, 2);
|
||||||
|
matchList.value = result;
|
||||||
|
matchPage.value += 1;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -53,57 +63,51 @@ onMounted(async () => {
|
|||||||
<view class="contents">
|
<view class="contents">
|
||||||
<view
|
<view
|
||||||
:style="{
|
: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">
|
<view class="contest-header">
|
||||||
<text>1V1</text>
|
<text>{{ item.name }}</text>
|
||||||
<text>2025.01.21 14:09:23</text>
|
<text>{{ item.createdAt }}</text>
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
<view class="contest-1v1">
|
<view v-if="item.mode === 1" class="contest-team">
|
||||||
<view class="player">
|
<view
|
||||||
<Avatar frame src="../static/avatar.png" />
|
class="player"
|
||||||
<text>选手1</text>
|
v-for="(p, index2) in item.players"
|
||||||
<image src="../static/winner-badge.png" mode="widthFix" />
|
:key="index2"
|
||||||
</view>
|
>
|
||||||
<view class="player">
|
<Avatar frame :src="p.avatar" />
|
||||||
<Avatar frame src="../static/avatar.png" />
|
<text>{{ p.name }}</text>
|
||||||
<text>选手2</text>
|
<image
|
||||||
|
v-if="index2 === 0"
|
||||||
|
src="../static/winner-badge.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
<view v-if="item.mode === 2" class="contest-multi">
|
||||||
<view @click="toMatchDetail">
|
<view
|
||||||
<view class="contest-header">
|
class="player"
|
||||||
<text>5v5</text>
|
v-for="(p, index2) in item.players"
|
||||||
<text>2025.01.21 14:09:23</text>
|
:key="index2"
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
>
|
||||||
</view>
|
<Avatar :rank="index2 + 1" :src="p.avatar" />
|
||||||
<view class="contest-multi">
|
<text>{{ p.name }}</text>
|
||||||
<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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view
|
||||||
|
:style="{
|
||||||
|
display: selectedIndex === 1 ? 'flex' : 'none',
|
||||||
|
}"
|
||||||
|
></view>
|
||||||
<view
|
<view
|
||||||
:style="{
|
:style="{
|
||||||
display: selectedIndex === 2 ? 'flex' : 'none',
|
display: selectedIndex === 2 ? 'flex' : 'none',
|
||||||
@@ -180,6 +184,12 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
.player > text {
|
.player > text {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
width: 90%;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
.player > image:last-child {
|
.player > image:last-child {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -187,19 +197,19 @@ onMounted(async () => {
|
|||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
.contest-1v1,
|
.contest-team,
|
||||||
.contest-multi {
|
.contest-multi {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.contest-1v1 > view {
|
.contest-team > view {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
.contest-1v1 > view:first-child {
|
.contest-team > view:first-child {
|
||||||
background-color: #364469;
|
background-color: #364469;
|
||||||
}
|
}
|
||||||
.contest-1v1 > view:last-child {
|
.contest-team > view:last-child {
|
||||||
background-color: #692735;
|
background-color: #692735;
|
||||||
}
|
}
|
||||||
.contest-multi > view {
|
.contest-multi > view {
|
||||||
|
|||||||
Reference in New Issue
Block a user