Compare commits
4 Commits
select-tar
...
new-home
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9e7a5a758 | ||
|
|
d25181e5f9 | ||
|
|
f6f5793e41 | ||
|
|
a05ed12541 |
3
.vscode/settings.json
vendored
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"i18n-ally.localesPaths": []
|
|
||||||
}
|
|
||||||
206
src/App.vue
@@ -1,68 +1,45 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import { watch } from "vue";
|
||||||
watch
|
import { onShow, onHide } from "@dcloudio/uni-app";
|
||||||
} from "vue";
|
import websocket from "@/websocket";
|
||||||
import {
|
import { getDeviceBatteryAPI } from "@/apis";
|
||||||
onShow,
|
import useStore from "@/store";
|
||||||
onHide
|
import { storeToRefs } from "pinia";
|
||||||
} from "@dcloudio/uni-app";
|
const store = useStore();
|
||||||
import websocket from "@/websocket";
|
const { user } = storeToRefs(store);
|
||||||
import {
|
const { updateUser, updateOnline } = store;
|
||||||
getDeviceBatteryAPI
|
|
||||||
} from "@/apis";
|
|
||||||
import useStore from "@/store";
|
|
||||||
import {
|
|
||||||
storeToRefs
|
|
||||||
} from "pinia";
|
|
||||||
import audioManager from "./audioManager";
|
|
||||||
const store = useStore();
|
|
||||||
const {
|
|
||||||
user
|
|
||||||
} = storeToRefs(store);
|
|
||||||
const {
|
|
||||||
updateUser,
|
|
||||||
updateOnline
|
|
||||||
} = store;
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => user.value.id,
|
() => user.value.id,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
const token = uni.getStorageSync(
|
const token = uni.getStorageSync(
|
||||||
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
|
||||||
);
|
);
|
||||||
if (newVal && token) {
|
if (newVal && token) {
|
||||||
websocket.createWebSocket(token, onShootWsMsg);
|
websocket.createWebSocket(token, (content) => {
|
||||||
|
uni.$emit("socket-inbox", content);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
websocket.closeWebSocket();
|
websocket.closeWebSocket();
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
deep: false, // 如果 user 是一个对象或数组,建议开启
|
deep: false, // 如果 user 是一个对象或数组,建议开启
|
||||||
immediate: false, // 若想在初始化时立即执行一次回调,可开启。
|
immediate: false, // 若想在初始化时立即执行一次回调,可开启。
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
function emitUpdateUser(value) {
|
function emitUpdateUser(value) {
|
||||||
updateUser(value);
|
updateUser(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function emitUpdateOnline() {
|
async function emitUpdateOnline() {
|
||||||
const data = await getDeviceBatteryAPI();
|
const data = await getDeviceBatteryAPI();
|
||||||
updateOnline(data.online);
|
updateOnline(data.online);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDeviceShoot() {
|
onShow(() => {
|
||||||
audioManager.play("射箭声音")
|
|
||||||
}
|
|
||||||
|
|
||||||
function onShootWsMsg(content) {
|
|
||||||
if(content.type === 'shoot-trigger'){
|
|
||||||
onDeviceShoot()
|
|
||||||
}
|
|
||||||
uni.$emit("socket-inbox", content);
|
|
||||||
}
|
|
||||||
|
|
||||||
onShow(() => {
|
|
||||||
uni.$on("update-user", emitUpdateUser);
|
uni.$on("update-user", emitUpdateUser);
|
||||||
uni.$on("update-online", emitUpdateOnline);
|
uni.$on("update-online", emitUpdateOnline);
|
||||||
const token = uni.getStorageSync(
|
const token = uni.getStorageSync(
|
||||||
@@ -70,26 +47,28 @@
|
|||||||
);
|
);
|
||||||
if (user.value.id && token) {
|
if (user.value.id && token) {
|
||||||
console.log("回到前台,重新连接 websocket");
|
console.log("回到前台,重新连接 websocket");
|
||||||
websocket.createWebSocket(token, onShootWsMsg);
|
websocket.createWebSocket(token, (content) => {
|
||||||
}
|
uni.$emit("socket-inbox", content);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
uni.$off("update-user", emitUpdateUser);
|
uni.$off("update-user", emitUpdateUser);
|
||||||
uni.$off("update-online", emitUpdateOnline);
|
uni.$off("update-online", emitUpdateOnline);
|
||||||
websocket.closeWebSocket();
|
websocket.closeWebSocket();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
page {
|
page {
|
||||||
-webkit-touch-callout: none;
|
-webkit-touch-callout: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
background-color: #000;
|
background-color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -97,196 +76,181 @@
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
outline: none;
|
outline: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
view::-webkit-scrollbar {
|
view::-webkit-scrollbar {
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
color: transparent;
|
color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
button::after {
|
button::after {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.guide-tips {
|
.guide-tips {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
|
.guide-tips > text:first-child {
|
||||||
.guide-tips>text:first-child {
|
|
||||||
color: #fed847;
|
color: #fed847;
|
||||||
}
|
}
|
||||||
|
.guide-tips > text:nth-child(2) {
|
||||||
.guide-tips>text:nth-child(2) {
|
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeInOut {
|
@keyframes fadeInOut {
|
||||||
0% {
|
0% {
|
||||||
transform: translateY(20px);
|
transform: translateY(20px);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
30% {
|
30% {
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
80% {
|
80% {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
100% {
|
100% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fade-in-out {
|
.fade-in-out {
|
||||||
animation: fadeInOut 1.2s ease forwards;
|
animation: fadeInOut 1.2s ease forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeOut {
|
@keyframes fadeOut {
|
||||||
from {
|
from {
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: translateY(20px);
|
transform: translateY(20px);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fade-out {
|
.fade-out {
|
||||||
animation: fadeOut 0.3s ease forwards;
|
animation: fadeOut 0.3s ease forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes scaleIn {
|
@keyframes scaleIn {
|
||||||
from {
|
from {
|
||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.scale-in {
|
.scale-in {
|
||||||
animation: scaleIn 0.3s ease-out forwards;
|
animation: scaleIn 0.3s ease-out forwards;
|
||||||
transform-origin: center center;
|
transform-origin: center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes scaleOut {
|
@keyframes scaleOut {
|
||||||
from {
|
from {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.scale-out {
|
.scale-out {
|
||||||
animation: scaleOut 0.3s ease-out forwards;
|
animation: scaleOut 0.3s ease-out forwards;
|
||||||
transform-origin: center center;
|
transform-origin: center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes rotate {
|
@keyframes rotate {
|
||||||
from {
|
from {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pumpIn {
|
@keyframes pumpIn {
|
||||||
from {
|
from {
|
||||||
transform: scale(2);
|
transform: scale(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.pump-in {
|
.pump-in {
|
||||||
animation: pumpIn 0.3s ease-out forwards;
|
animation: pumpIn 0.3s ease-out forwards;
|
||||||
transform-origin: center center;
|
transform-origin: center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.share-canvas {
|
.share-canvas {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: 530px;
|
height: 530px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -1000px;
|
top: -1000px;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.truncate {
|
.truncate {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal {
|
.modal {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
.user-row {
|
||||||
.user-row {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
padding-top: 7px;
|
padding-top: 7px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
.half-time-tip {
|
||||||
.half-time-tip {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
.half-time-tip > text:last-child {
|
||||||
.half-time-tip>text:last-child {
|
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
color: #fff9;
|
color: #fff9;
|
||||||
}
|
}
|
||||||
|
.see-more {
|
||||||
.see-more {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
}
|
}
|
||||||
|
.see-more > text {
|
||||||
.see-more>text {
|
|
||||||
color: #39a8ff;
|
color: #39a8ff;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
.see-more > image {
|
||||||
.see-more>image {
|
|
||||||
width: 15px;
|
width: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "DINCondensed";
|
font-family: "DINCondensed";
|
||||||
src: url("https://static.shelingxingqiu.com/font/DIN-Condensed-Bold-2.ttf") format("truetype");
|
src: url("https://static.shelingxingqiu.com/font/DIN-Condensed-Bold-2.ttf")
|
||||||
|
format("truetype");
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
150
src/apis.js
@@ -6,8 +6,8 @@ try {
|
|||||||
|
|
||||||
switch (envVersion) {
|
switch (envVersion) {
|
||||||
case "develop": // 开发版
|
case "develop": // 开发版
|
||||||
BASE_URL = "http://localhost:8000/api/shoot";
|
// BASE_URL = "http://192.168.1.242:8000/api/shoot";
|
||||||
// BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
||||||
break;
|
break;
|
||||||
case "trial": // 体验版
|
case "trial": // 体验版
|
||||||
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
|
||||||
@@ -196,31 +196,24 @@ export const getMyDevicesAPI = () => {
|
|||||||
return request("GET", "/user/device/getBindings");
|
return request("GET", "/user/device/getBindings");
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createPractiseAPI = (arrows, time, target) => {
|
export const createPractiseAPI = (arrows, mode) => {
|
||||||
return request("POST", "/user/practice/create", {
|
return request("POST", "/user/practice/create", {
|
||||||
shootNumber: arrows,
|
arrows,
|
||||||
shootTime: time,
|
mode,
|
||||||
targetType: target*20,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const startPractiseAPI = () => {
|
|
||||||
return request("POST", "/user/practice/begin");
|
|
||||||
};
|
|
||||||
|
|
||||||
export const endPractiseAPI = () => {
|
|
||||||
return request("POST", "/user/practice/stop");
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getPractiseAPI = async (id) => {
|
export const getPractiseAPI = async (id) => {
|
||||||
return request("GET", `/user/practice/get?id=${id}`);
|
const result = await request("GET", `/user/practice/get?id=${id}`);
|
||||||
|
const data = { ...(result.UserPracticeRound || {}) };
|
||||||
|
if (data.arrows) data.arrows = JSON.parse(data.arrows);
|
||||||
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createRoomAPI = (gameType, teamSize, targetType) => {
|
export const createRoomAPI = (gameType, teamSize) => {
|
||||||
return request("POST", "/user/createroom", {
|
return request("POST", "/user/createroom", {
|
||||||
gameType,
|
gameType,
|
||||||
teamSize,
|
teamSize,
|
||||||
targetType,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -262,7 +255,6 @@ export const matchGameAPI = (match, gameType, teamSize) => {
|
|||||||
match,
|
match,
|
||||||
gameType,
|
gameType,
|
||||||
teamSize,
|
teamSize,
|
||||||
readyTime: 1.5,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -272,6 +264,78 @@ export const readyGameAPI = (battleId) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getGameAPI = async (battleId) => {
|
||||||
|
const result = await request("POST", "/user/battle/detail", {
|
||||||
|
id: battleId,
|
||||||
|
});
|
||||||
|
if (!result.battleStats) return {};
|
||||||
|
const {
|
||||||
|
battleStats = {},
|
||||||
|
playerStats = {},
|
||||||
|
goldenRoundRecords = [],
|
||||||
|
} = result;
|
||||||
|
const data = {
|
||||||
|
id: battleId,
|
||||||
|
mode: battleStats.mode, // 1.几V几 2.大乱斗
|
||||||
|
gameMode: battleStats.gameMode, // 1.约战 2.排位
|
||||||
|
teamSize: battleStats.teamSize,
|
||||||
|
};
|
||||||
|
if (battleStats && battleStats.mode === 1) {
|
||||||
|
data.winner = battleStats.winner;
|
||||||
|
data.roundsData = {};
|
||||||
|
data.redPlayers = {};
|
||||||
|
data.bluePlayers = {};
|
||||||
|
data.mvps = [];
|
||||||
|
data.goldenRounds =
|
||||||
|
goldenRoundRecords && goldenRoundRecords.length ? goldenRoundRecords : [];
|
||||||
|
playerStats.forEach((item) => {
|
||||||
|
const { playerBattleStats = {}, roundRecords = [] } = item;
|
||||||
|
if (playerBattleStats.team === 0) {
|
||||||
|
data.redPlayers[playerBattleStats.playerId] = playerBattleStats;
|
||||||
|
}
|
||||||
|
if (playerBattleStats.team === 1) {
|
||||||
|
data.bluePlayers[playerBattleStats.playerId] = playerBattleStats;
|
||||||
|
}
|
||||||
|
if (playerBattleStats.mvp) {
|
||||||
|
data.mvps.push(playerBattleStats);
|
||||||
|
}
|
||||||
|
roundRecords.forEach((round) => {
|
||||||
|
data.roundsData[round.roundNumber] = {
|
||||||
|
...data.roundsData[round.roundNumber],
|
||||||
|
[round.playerId]: round.arrowHistory,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const totalRounds = Object.keys(data.roundsData).length;
|
||||||
|
(goldenRoundRecords || []).forEach((item, index) => {
|
||||||
|
item.arrowHistory.forEach((arrow) => {
|
||||||
|
if (!data.roundsData[totalRounds + index + 1]) {
|
||||||
|
data.roundsData[totalRounds + index + 1] = {};
|
||||||
|
}
|
||||||
|
if (!data.roundsData[totalRounds + index + 1][arrow.playerId]) {
|
||||||
|
data.roundsData[totalRounds + index + 1][arrow.playerId] = [];
|
||||||
|
}
|
||||||
|
data.roundsData[totalRounds + index + 1][arrow.playerId].push(arrow);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
data.mvps.sort((a, b) => b.totalRings - a.totalRings);
|
||||||
|
}
|
||||||
|
if (battleStats && battleStats.mode === 2) {
|
||||||
|
data.players = [];
|
||||||
|
playerStats.forEach((item) => {
|
||||||
|
data.players.push({
|
||||||
|
...item.playerBattleStats,
|
||||||
|
arrowHistory: item.roundRecords[0].arrowHistory,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
data.players = data.players.sort((a, b) => b.totalScore - a.totalScore);
|
||||||
|
}
|
||||||
|
// console.log("game result:", result);
|
||||||
|
// console.log("format data:", data);
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
export const simulShootAPI = (device_id, x, y) => {
|
export const simulShootAPI = (device_id, x, y) => {
|
||||||
const data = {
|
const data = {
|
||||||
device_id,
|
device_id,
|
||||||
@@ -284,12 +348,39 @@ export const simulShootAPI = (device_id, x, y) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getBattleListAPI = async (page, battleType) => {
|
export const getBattleListAPI = async (page, battleType) => {
|
||||||
|
const data = [];
|
||||||
const result = await request("POST", "/user/battle/details/list", {
|
const result = await request("POST", "/user/battle/details/list", {
|
||||||
page,
|
page,
|
||||||
pageSize: 10,
|
|
||||||
battleType,
|
battleType,
|
||||||
|
modeType: 0,
|
||||||
});
|
});
|
||||||
return result.list;
|
(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,
|
||||||
|
winner: item.battleStats.winner,
|
||||||
|
players: item.playerStats
|
||||||
|
.map((p) => p.playerBattleStats)
|
||||||
|
.sort((a, b) => b.totalScore - a.totalScore),
|
||||||
|
redPlayers: item.playerStats
|
||||||
|
.filter((p) => p.playerBattleStats.team === 0)
|
||||||
|
.map((p) => p.playerBattleStats),
|
||||||
|
bluePlayers: item.playerStats
|
||||||
|
.filter((p) => p.playerBattleStats.team === 1)
|
||||||
|
.map((p) => p.playerBattleStats),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRankListAPI = () => {
|
export const getRankListAPI = () => {
|
||||||
@@ -326,6 +417,12 @@ export const getUserGameState = () => {
|
|||||||
return request("GET", "/user/state");
|
return request("GET", "/user/state");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getCurrentGameAPI = async () => {
|
||||||
|
uni.$emit("update-header-loading", true);
|
||||||
|
const result = await request("GET", "/user/join/battle");
|
||||||
|
return result.currentGame || {};
|
||||||
|
};
|
||||||
|
|
||||||
export const getPointBookConfigAPI = async () => {
|
export const getPointBookConfigAPI = async () => {
|
||||||
return request("GET", "/user/score/sheet/option");
|
return request("GET", "/user/score/sheet/option");
|
||||||
};
|
};
|
||||||
@@ -455,16 +552,3 @@ export const getReadyAPI = (roomId) => {
|
|||||||
roomId,
|
roomId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBattleAPI = async (battleId) => {
|
|
||||||
return request("POST", "/user/match/info", {
|
|
||||||
id: battleId,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const kickPlayerAPI = (number, userId) => {
|
|
||||||
return request("POST", "/user/room/kicking", {
|
|
||||||
number,
|
|
||||||
userId,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -40,26 +40,25 @@ export const audioFils = {
|
|||||||
未上靶:
|
未上靶:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6n45o3tsm1v4unam.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6n45o3tsm1v4unam.mp3",
|
||||||
"1环":
|
"1环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/1.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin1aq7gxjih5l.mp3",
|
||||||
"2环":
|
"2环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/2.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin64tdgx2s4at.mp3",
|
||||||
"3环":
|
"3环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/3.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinlmf87vt8z65.mp3",
|
||||||
"4环":
|
"4环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/4.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinniv97sx0q9u.mp3",
|
||||||
"5环":
|
"5环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/5.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin7j01kknpb7k.mp3",
|
||||||
"6环":
|
"6环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/6.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin4syy1015rtq.mp3",
|
||||||
"7环":
|
"7环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/7.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin3iz3dvmjdai.mp3",
|
||||||
"8环":
|
"8环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/8.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinnjd42lhpfiw.mp3",
|
||||||
"9环":
|
"9环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/9.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxin69nj1xh7yfz.mp3",
|
||||||
"10环":
|
"10环":
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v3/10.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-09-17/dcutxinnvsx0tt7ksa.mp3",
|
||||||
X环: "https://static.shelingxingqiu.com/shootaudio/v4/v4/X%E7%8E%AF.mp3",
|
|
||||||
向上调整:
|
向上调整:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6ellf5pfvu3l8dhr.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-12/de6ellf5pfvu3l8dhr.mp3",
|
||||||
向右上调整:
|
向右上调整:
|
||||||
@@ -80,10 +79,6 @@ export const audioFils = {
|
|||||||
"https://static.shelingxingqiu.com/attachment/2025-11-13/de7kzzllq0futwynso.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-13/de7kzzllq0futwynso.mp3",
|
||||||
练习开始:
|
练习开始:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-11-14/de88w0lmmt43nnfmoi.mp3",
|
"https://static.shelingxingqiu.com/attachment/2025-11-14/de88w0lmmt43nnfmoi.mp3",
|
||||||
射箭声音:
|
|
||||||
"https://static.shelingxingqiu.com/shootaudio/v4/v4/%E7%AE%AD%E9%A3%9E%E8%A1%8C.mp3",
|
|
||||||
命中:
|
|
||||||
"https://static.shelingxingqiu.com/shootaudio/%E5%91%BD%E4%B8%AD.mp3"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 版本控制日志函数
|
// 版本控制日志函数
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { formatTimestamp } from "@/util";
|
|
||||||
|
|
||||||
const loadImage = (src) =>
|
const loadImage = (src) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
@@ -637,7 +635,7 @@ export function renderScores(ctx, arrows = [], bgImg) {
|
|||||||
}
|
}
|
||||||
renderText(
|
renderText(
|
||||||
ctx,
|
ctx,
|
||||||
item.ringX ? "X" : item.ring,
|
item.ring,
|
||||||
18,
|
18,
|
||||||
"#fed847",
|
"#fed847",
|
||||||
29.5 + (i % 9) * 30,
|
29.5 + (i % 9) * 30,
|
||||||
@@ -659,7 +657,7 @@ export function renderScores(ctx, arrows = [], bgImg) {
|
|||||||
}
|
}
|
||||||
renderText(
|
renderText(
|
||||||
ctx,
|
ctx,
|
||||||
item.ringX ? "X" : item.ring,
|
item.ring,
|
||||||
23,
|
23,
|
||||||
"#fed847",
|
"#fed847",
|
||||||
43 + rowIndex * 42,
|
43 + rowIndex * 42,
|
||||||
@@ -739,7 +737,9 @@ export async function sharePractiseData(canvasId, type, user, data) {
|
|||||||
|
|
||||||
let subTitle = "正式开启弓箭手之路";
|
let subTitle = "正式开启弓箭手之路";
|
||||||
if (type > 1) {
|
if (type > 1) {
|
||||||
subTitle = `今日弓箭练习打卡 ${formatTimestamp(data.startTime)}`;
|
subTitle = `今日弓箭练习打卡 ${data.createdAt
|
||||||
|
.split(" ")[0]
|
||||||
|
.replaceAll("-", ".")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.drawImage(titleImg, (width - 160) / 2, 160, 160, 40);
|
ctx.drawImage(titleImg, (width - 160) / 2, 160, 160, 40);
|
||||||
@@ -748,14 +748,14 @@ export async function sharePractiseData(canvasId, type, user, data) {
|
|||||||
renderText(ctx, subTitle, 18, "#fff", width / 2, 224, "center");
|
renderText(ctx, subTitle, 18, "#fff", width / 2, 224, "center");
|
||||||
|
|
||||||
renderText(ctx, "共", 14, "#fff", 122, 300);
|
renderText(ctx, "共", 14, "#fff", 122, 300);
|
||||||
const totalRing = data.details.reduce((last, next) => last + next.ring, 0);
|
const totalRing = data.arrows.reduce((last, next) => last + next.ring, 0);
|
||||||
renderText(ctx, totalRing, 14, "#fed847", 148, 300, "center");
|
renderText(ctx, totalRing, 14, "#fed847", 148, 300, "center");
|
||||||
renderText(ctx, "环", 14, "#fff", 161, 300);
|
renderText(ctx, "环", 14, "#fff", 161, 300);
|
||||||
|
|
||||||
renderLine(ctx, 77);
|
renderLine(ctx, 77);
|
||||||
renderLine(ctx, 185);
|
renderLine(ctx, 185);
|
||||||
|
|
||||||
renderScores(ctx, data.details, scoreBgImg);
|
renderScores(ctx, data.arrows, scoreBgImg);
|
||||||
|
|
||||||
ctx.drawImage(qrCodeImg, width * 0.06, height * 0.87, 52, 52);
|
ctx.drawImage(qrCodeImg, width * 0.06, height * 0.87, 52, 52);
|
||||||
renderText(ctx, "射灵平台", 12, "#fff", width * 0.26, height * 0.9);
|
renderText(ctx, "射灵平台", 12, "#fff", width * 0.26, height * 0.9);
|
||||||
|
|||||||
@@ -1,83 +1,122 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const tabs = [
|
import { ref } from "vue";
|
||||||
{ image: "../static/tab-vip.png" },
|
|
||||||
{ image: "../static/tab-point-book.png" },
|
|
||||||
{ image: "../static/tab-mall.png" },
|
|
||||||
];
|
|
||||||
|
|
||||||
function handleTabClick(index) {
|
import useStore from "@/store";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
const { user } = storeToRefs(useStore());
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
selected: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
onSignin: {
|
||||||
|
type: Function,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
|
onChange: {
|
||||||
|
type: Function,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const isIOS = uni.getDeviceInfo().osName === "ios";
|
||||||
|
const tabs = {
|
||||||
|
VIP: "vip",
|
||||||
|
智能弓: "mall",
|
||||||
|
计分本: "tab-point-book",
|
||||||
|
勋章: "medal",
|
||||||
|
个人中心: "user",
|
||||||
|
};
|
||||||
|
const onTabChange = (index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url: "/pages/be-vip",
|
url: "/pages/be-vip",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (index === 1) {
|
if (index === 1) {
|
||||||
uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url: "/pages/point-book",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (index === 2) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: "/pages/device-intro",
|
url: "/pages/device-intro",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
if (index === 2) {
|
||||||
|
return uni.navigateTo({
|
||||||
|
url: "/pages/point-book",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (index === 4) {
|
||||||
|
if (!user.value.id) {
|
||||||
|
props.onSignin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return uni.navigateTo({
|
||||||
|
url: "/pages/user",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// props.onChange(index);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="footer">
|
<view class="footer" :style="{ paddingBottom: isIOS ? '30rpx' : '0' }">
|
||||||
<image class="footer-bg" src="../static/tab-bg.png" mode="widthFix" />
|
<button
|
||||||
<view
|
hover-class="none"
|
||||||
v-for="(tab, index) in tabs"
|
v-for="(key, index) in Object.keys(tabs)"
|
||||||
:key="index"
|
:key="key"
|
||||||
class="tab-item"
|
@click="onTabChange(index)"
|
||||||
@click="handleTabClick(index)"
|
:class="index === 2 ? 'point-book-tab' : ''"
|
||||||
:style="{
|
|
||||||
width: index === 1 ? '36%' : '20%',
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
<image :src="tab.image" mode="widthFix" />
|
<image
|
||||||
</view>
|
v-if="index !== 2"
|
||||||
|
:src="`../static/tab-${tabs[key]}.png`"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
<image v-else src="../static/tab-point-book.png" mode="widthFix" />
|
||||||
|
<text v-if="index !== 2">{{ key }}</text>
|
||||||
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.footer {
|
.footer {
|
||||||
height: 120px;
|
height: 140rpx;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
|
||||||
align-items: center;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.footer-bg {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
z-index: 0;
|
|
||||||
}
|
|
||||||
.tab-item {
|
|
||||||
z-index: 1;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
rgba(70, 55, 34, 0.75) 0%,
|
||||||
|
rgba(5, 11, 25, 0.58) 77%
|
||||||
|
),
|
||||||
|
#000000;
|
||||||
|
/* box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.06); */
|
||||||
}
|
}
|
||||||
.tab-item > image {
|
.footer > button {
|
||||||
width: 65rpx;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 19%;
|
||||||
|
color: #8e7d5c;
|
||||||
}
|
}
|
||||||
.tab-item:last-child > image {
|
.footer > button > image {
|
||||||
width: 85rpx;
|
width: 46rpx;
|
||||||
|
height: 46rpx;
|
||||||
}
|
}
|
||||||
.tab-item:nth-child(2) {
|
.footer > button > text {
|
||||||
transform: translate(10%, 40%);
|
font-weight: 500;
|
||||||
|
font-size: 20rpx;
|
||||||
|
margin-top: 10rpx;
|
||||||
}
|
}
|
||||||
.tab-item:nth-child(3) {
|
.point-book-tab {
|
||||||
margin-bottom: 25rpx;
|
overflow: unset;
|
||||||
|
margin: 0 1%;
|
||||||
}
|
}
|
||||||
.tab-item:nth-child(3) > image {
|
.point-book-tab > image {
|
||||||
width: 140rpx;
|
width: 144rpx !important;
|
||||||
}
|
height: 144rpx !important;
|
||||||
.tab-item:nth-child(4) {
|
transform: translateY(-20rpx);
|
||||||
transform: translate(-10%, 44%);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { onShow } from "@dcloudio/uni-app";
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
|
|
||||||
import { getBattleAPI, getUserGameState } from "@/apis";
|
import { getCurrentGameAPI, getUserGameState } from "@/apis";
|
||||||
import { debounce } from "@/util";
|
import { debounce } from "@/util";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
@@ -44,21 +44,10 @@ const onClick = debounce(async () => {
|
|||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const result = await getBattleAPI();
|
if (game.value.inBattle) {
|
||||||
if (result && result.matchId) {
|
|
||||||
await uni.$checkAudio();
|
await uni.$checkAudio();
|
||||||
if (result.mode <= 3) {
|
const result = await getCurrentGameAPI();
|
||||||
uni.navigateTo({
|
} else if (game.value.roomID) {
|
||||||
url: `/pages/team-battle?battleId=${result.matchId}`,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/melee-battle?battleId=${result.matchId}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (game.value.roomID) {
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/battle-room?roomNumber=" + game.value.roomID,
|
url: "/pages/battle-room?roomNumber=" + game.value.roomID,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,10 +22,9 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalRounds = computed(() => {
|
const normalRounds = computed(
|
||||||
const count = props.roundResults.findIndex((item) => !!item.ifGold);
|
() => props.roundResults.length - props.goldenRound
|
||||||
return count > 0 ? count : props.roundResults.length;
|
);
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -60,8 +59,8 @@ const normalRounds = computed(() => {
|
|||||||
</block>
|
</block>
|
||||||
<view>
|
<view>
|
||||||
<text>{{
|
<text>{{
|
||||||
result.shoots[1] && result.shoots[1].length
|
result.blueArrows.length
|
||||||
? result.shoots[1]
|
? result.blueArrows
|
||||||
.map((item) => item.ring)
|
.map((item) => item.ring)
|
||||||
.reduce((last, next) => last + next, 0)
|
.reduce((last, next) => last + next, 0)
|
||||||
: ""
|
: ""
|
||||||
@@ -95,8 +94,8 @@ const normalRounds = computed(() => {
|
|||||||
</block>
|
</block>
|
||||||
<view>
|
<view>
|
||||||
<text>{{
|
<text>{{
|
||||||
result.shoots[2] && result.shoots[2].length
|
result.redArrows.length
|
||||||
? result.shoots[2]
|
? result.redArrows
|
||||||
.map((item) => item.ring)
|
.map((item) => item.ring)
|
||||||
.reduce((last, next) => last + next, 0)
|
.reduce((last, next) => last + next, 0)
|
||||||
: ""
|
: ""
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ defineProps({
|
|||||||
<text class="player-name">{{ player.name }}</text>
|
<text class="player-name">{{ player.name }}</text>
|
||||||
</view>
|
</view>
|
||||||
<image
|
<image
|
||||||
v-if="winner === 2"
|
v-if="winner === 0"
|
||||||
src="../static/winner-badge.png"
|
src="../static/winner-badge.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
class="right-winner-badge"
|
class="right-winner-badge"
|
||||||
|
|||||||
@@ -49,16 +49,16 @@ const props = defineProps({
|
|||||||
<view class="desc">
|
<view class="desc">
|
||||||
<text>{{ arrows.length }}</text>
|
<text>{{ arrows.length }}</text>
|
||||||
<text>支箭,共</text>
|
<text>支箭,共</text>
|
||||||
<text>{{ arrows.reduce((a, b) => a + (b.ring || 0), 0) }}</text>
|
<text>{{ arrows.reduce((a, b) => a + b.ring, 0) }}</text>
|
||||||
<text>环</text>
|
<text>环</text>
|
||||||
</view>
|
</view>
|
||||||
<ScorePanel
|
<ScorePanel
|
||||||
:completeEffect="false"
|
:completeEffect="false"
|
||||||
:rowCount="total === 12 ? 6 : 9"
|
:rowCount="arrows.length === 12 ? 6 : 9"
|
||||||
:total="total"
|
:total="total"
|
||||||
:arrows="arrows"
|
:scores="arrows.map((a) => a.ring)"
|
||||||
:margin="total === 12 ? 4 : 1"
|
:margin="arrows.length === 12 ? 4 : 1"
|
||||||
:fontSize="total === 12 ? 25 : 22"
|
:fontSize="arrows.length === 12 ? 25 : 22"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||||
import PointSwitcher from "@/components/PointSwitcher.vue";
|
import PointSwitcher from "@/components/PointSwitcher.vue";
|
||||||
|
|
||||||
import { MESSAGETYPES, MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
import { simulShootAPI } from "@/apis";
|
import { simulShootAPI } from "@/apis";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -92,10 +92,7 @@ const simulShoot = async () => {
|
|||||||
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
if (device.value.deviceId) await simulShootAPI(device.value.deviceId);
|
||||||
};
|
};
|
||||||
const simulShoot2 = async () => {
|
const simulShoot2 = async () => {
|
||||||
if (device.value.deviceId) {
|
if (device.value.deviceId) await simulShootAPI(device.value.deviceId, 1, 1);
|
||||||
const r1 = Math.random() > 0.5 ? 0.01 : 0.02;
|
|
||||||
await simulShootAPI(device.value.deviceId, r1, r1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const env = computed(() => {
|
const env = computed(() => {
|
||||||
@@ -111,26 +108,28 @@ const arrowStyle = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onReceiveMessage(message) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (Array.isArray(message)) return;
|
messages.forEach((msg) => {
|
||||||
if (message.type === MESSAGETYPESV2.ShootResult && message.shootData) {
|
|
||||||
if (
|
if (
|
||||||
message.shootData.playerId === user.value.id &&
|
msg.constructor === MESSAGETYPES.ShootSyncMeArrowID ||
|
||||||
!message.shootData.ring &&
|
msg.constructor === MESSAGETYPES.ShootResult
|
||||||
message.shootData.angle >= 0
|
) {
|
||||||
|
if (
|
||||||
|
msg.userId === user.value.id &&
|
||||||
|
!msg.target.ring &&
|
||||||
|
msg.target.angle >= 0
|
||||||
) {
|
) {
|
||||||
angle.value = null;
|
angle.value = null;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (props.scores[0]) {
|
if (props.scores[0]) {
|
||||||
circleColor.value =
|
circleColor.value =
|
||||||
message.shootData.playerId === props.scores[0].playerId
|
msg.userId === props.scores[0].playerId ? "#ff4444" : "#1840FF";
|
||||||
? "#ff4444"
|
|
||||||
: "#1840FF";
|
|
||||||
}
|
}
|
||||||
angle.value = message.shootData.angle;
|
angle.value = msg.target.angle;
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -183,8 +182,7 @@ onBeforeUnmount(() => {
|
|||||||
left: calcRealX(latestOne.ring ? latestOne.x : 0, 28),
|
left: calcRealX(latestOne.ring ? latestOne.x : 0, 28),
|
||||||
top: calcRealY(latestOne.ring ? latestOne.y : 0, 28),
|
top: calcRealY(latestOne.ring ? latestOne.y : 0, 28),
|
||||||
}"
|
}"
|
||||||
>{{ latestOne.ringX ? "X" : latestOne.ring || "未上靶"
|
>{{ latestOne.ring || "未上靶" }}<text v-if="latestOne.ring">环</text>
|
||||||
}}<text v-if="latestOne.ring">环</text>
|
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
v-if="
|
v-if="
|
||||||
@@ -207,7 +205,7 @@ onBeforeUnmount(() => {
|
|||||||
left: calcRealX(bluelatestOne.ring ? bluelatestOne.x : 0, 28),
|
left: calcRealX(bluelatestOne.ring ? bluelatestOne.x : 0, 28),
|
||||||
top: calcRealY(bluelatestOne.ring ? bluelatestOne.y : 0, 28),
|
top: calcRealY(bluelatestOne.ring ? bluelatestOne.y : 0, 28),
|
||||||
}"
|
}"
|
||||||
>{{ bluelatestOne.ringX ? "X" : bluelatestOne.ring || "未上靶"
|
>{{ bluelatestOne.ring || "未上靶"
|
||||||
}}<text v-if="bluelatestOne.ring">环</text></view
|
}}<text v-if="bluelatestOne.ring">环</text></view
|
||||||
>
|
>
|
||||||
<block v-for="(bow, index) in scores" :key="index">
|
<block v-for="(bow, index) in scores" :key="index">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import AppBackground from "@/components/AppBackground.vue";
|
|||||||
import Header from "@/components/Header.vue";
|
import Header from "@/components/Header.vue";
|
||||||
import ScreenHint from "@/components/ScreenHint.vue";
|
import ScreenHint from "@/components/ScreenHint.vue";
|
||||||
import BackToGame from "@/components/BackToGame.vue";
|
import BackToGame from "@/components/BackToGame.vue";
|
||||||
import { laserAimAPI, getBattleAPI } from "@/apis";
|
import { getCurrentGameAPI, laserAimAPI } from "@/apis";
|
||||||
import { capsuleHeight, debounce } from "@/util";
|
import { capsuleHeight, debounce } from "@/util";
|
||||||
import AudioManager from "@/audioManager";
|
import AudioManager from "@/audioManager";
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -25,10 +25,6 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
isHome: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
showBackToGame: {
|
showBackToGame: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
@@ -111,19 +107,15 @@ const backToGame = debounce(async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
const result = await getBattleAPI();
|
const game = await getCurrentGameAPI();
|
||||||
if (result && result.matchId) {
|
if (!game || !game.gameId) {
|
||||||
await checkAudioProgress();
|
uni.showToast({
|
||||||
if (result.mode <= 3) {
|
title: "没有进行中的对局",
|
||||||
uni.navigateTo({
|
icon: "none",
|
||||||
url: `/pages/team-battle?battleId=${result.matchId}`,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/melee-battle?battleId=${result.matchId}`,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
showHint.value = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取当前游戏失败:", error);
|
console.error("获取当前游戏失败:", error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -146,12 +138,7 @@ const goCalibration = async () => {
|
|||||||
<template>
|
<template>
|
||||||
<view :style="{ paddingTop: capsuleHeight + 'px' }">
|
<view :style="{ paddingTop: capsuleHeight + 'px' }">
|
||||||
<AppBackground :type="bgType" :bgColor="bgColor" />
|
<AppBackground :type="bgType" :bgColor="bgColor" />
|
||||||
<Header
|
<Header :title="title" :onBack="onBack" :whiteBackArrow="whiteBackArrow" />
|
||||||
v-if="!isHome"
|
|
||||||
:title="title"
|
|
||||||
:onBack="onBack"
|
|
||||||
:whiteBackArrow="whiteBackArrow"
|
|
||||||
/>
|
|
||||||
<BackToGame v-if="showBackToGame" />
|
<BackToGame v-if="showBackToGame" />
|
||||||
<scroll-view
|
<scroll-view
|
||||||
:scroll-y="scroll"
|
:scroll-y="scroll"
|
||||||
@@ -159,7 +146,7 @@ const goCalibration = async () => {
|
|||||||
:bounces="false"
|
:bounces="false"
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
:style="{
|
:style="{
|
||||||
height: `calc(100vh - ${capsuleHeight + (isHome ? 0 : 50)}px - ${
|
height: `calc(100vh - ${capsuleHeight + 50}px - ${
|
||||||
$slots.bottom && showBottom ? (isIOS ? '75px' : '65px') : '0px'
|
$slots.bottom && showBottom ? (isIOS ? '75px' : '65px') : '0px'
|
||||||
})`,
|
})`,
|
||||||
}"
|
}"
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const battleMode = ref(1);
|
const battleMode = ref(1);
|
||||||
const targetMode = ref(1);
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const roomNumber = ref("");
|
const roomNumber = ref("");
|
||||||
|
|
||||||
@@ -33,33 +32,23 @@ const createRoom = debounce(async () => {
|
|||||||
if (battleMode.value === 2) size = 10;
|
if (battleMode.value === 2) size = 10;
|
||||||
if (battleMode.value === 3) size = 4;
|
if (battleMode.value === 3) size = 4;
|
||||||
if (battleMode.value === 4) size = 6;
|
if (battleMode.value === 4) size = 6;
|
||||||
try {
|
|
||||||
const result = await createRoomAPI(
|
const result = await createRoomAPI(
|
||||||
battleMode.value === 2 ? 2 : 1,
|
battleMode.value === 2 ? 2 : 1,
|
||||||
battleMode.value === 2 ? 10 : size,
|
battleMode.value === 2 ? 10 : size
|
||||||
targetMode.value*20,
|
|
||||||
);
|
);
|
||||||
if (result.number) {
|
if (result.number) {
|
||||||
props.onConfirm();
|
props.onConfirm();
|
||||||
await joinRoomAPI(result.number);
|
await joinRoomAPI(result.number);
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/battle-room?roomNumber=" + result.number + "&target=" + targetMode.value,
|
url: "/pages/battle-room?roomNumber=" + result.number,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="target-options-header">
|
<image src="../static/choose-battle-mode.png" mode="widthFix" />
|
||||||
<view class="target-options-header-line-left"></view>
|
|
||||||
<image class="target-options-header-title-img" src="../static/choose-battle-mode.png" mode="widthFix" />
|
|
||||||
<view class="target-options-header-line-right"></view>
|
|
||||||
</view>
|
|
||||||
<view class="create-options">
|
<view class="create-options">
|
||||||
<view
|
<view
|
||||||
:class="{ 'battle-btn': true, 'battle-choosen': battleMode === 1 }"
|
:class="{ 'battle-btn': true, 'battle-choosen': battleMode === 1 }"
|
||||||
@@ -86,25 +75,6 @@ const createRoom = debounce(async () => {
|
|||||||
<text>乱斗模式(3-10人)</text>
|
<text>乱斗模式(3-10人)</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="target-options-header">
|
|
||||||
<view class="target-options-header-line-left"></view>
|
|
||||||
<view class="target-options-header-title">选择靶纸</view>
|
|
||||||
<view class="target-options-header-line-right"></view>
|
|
||||||
</view>
|
|
||||||
<view class="target-options">
|
|
||||||
<view
|
|
||||||
:class="{ 'battle-btn': true, 'battle-choosen': targetMode === 1 }"
|
|
||||||
@click="() => (targetMode = 1)"
|
|
||||||
>
|
|
||||||
<text>20厘米全环靶</text>
|
|
||||||
</view>
|
|
||||||
<view
|
|
||||||
:class="{ 'battle-btn': true, 'battle-choosen': targetMode === 2 }"
|
|
||||||
@click="() => (targetMode = 2)"
|
|
||||||
>
|
|
||||||
<text>40厘米全环靶</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<SButton :onClick="createRoom">创建房间</SButton>
|
<SButton :onClick="createRoom">创建房间</SButton>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -116,7 +86,6 @@ const createRoom = debounce(async () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-top: 44rpx;
|
|
||||||
}
|
}
|
||||||
.container > image:first-child {
|
.container > image:first-child {
|
||||||
width: 45%;
|
width: 45%;
|
||||||
@@ -131,50 +100,6 @@ const createRoom = debounce(async () => {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
.target-options-header{
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 24rpx;
|
|
||||||
}
|
|
||||||
.target-options-header-title-img{
|
|
||||||
width: 196rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
}
|
|
||||||
.target-options-header-title{
|
|
||||||
width: 112rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
font-family: PingFang SC, PingFang SC;
|
|
||||||
font-weight: 400;
|
|
||||||
font-size: 28rpx;
|
|
||||||
text-align: center;
|
|
||||||
font-style: normal;
|
|
||||||
text-transform: none;
|
|
||||||
color: #FFEFBA;
|
|
||||||
margin: 0 18rpx;
|
|
||||||
}
|
|
||||||
.target-options-header-line-left{
|
|
||||||
width: 214rpx;
|
|
||||||
height: 0rpx;
|
|
||||||
border-radius: 0rpx 0rpx 0rpx 0rpx;
|
|
||||||
border: 1rpx solid;
|
|
||||||
border-image: linear-gradient(90deg, rgba(133, 119, 96, 0), rgba(133, 119, 96, 1)) 1 1;
|
|
||||||
}
|
|
||||||
.target-options-header-line-right{
|
|
||||||
width: 214rpx;
|
|
||||||
height: 0rpx;
|
|
||||||
border-radius: 0rpx 0rpx 0rpx 0rpx;
|
|
||||||
border: 1rpx solid;
|
|
||||||
border-image: linear-gradient(90deg, rgba(133, 119, 96, 1), rgba(133, 119, 96, 0)) 1 1;
|
|
||||||
}
|
|
||||||
.target-options {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0 10px;
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
.battle-btn {
|
.battle-btn {
|
||||||
width: 45%;
|
width: 45%;
|
||||||
height: 55px;
|
height: 55px;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ const signin = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const showLoader = ref(false);
|
||||||
const pointBook = ref(null);
|
const pointBook = ref(null);
|
||||||
const showProgress = ref(false);
|
const showProgress = ref(false);
|
||||||
const heat = ref(0);
|
const heat = ref(0);
|
||||||
@@ -79,12 +80,20 @@ onMounted(() => {
|
|||||||
pointBook.value = uni.getStorageSync("last-point-book");
|
pointBook.value = uni.getStorageSync("last-point-book");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
currentPage.route === "pages/team-battle" ||
|
||||||
|
currentPage.route === "pages/melee-match"
|
||||||
|
) {
|
||||||
|
showLoader.value = true;
|
||||||
|
}
|
||||||
if (currentPage.route === "pages/team-battle") {
|
if (currentPage.route === "pages/team-battle") {
|
||||||
showProgress.value = true;
|
showProgress.value = true;
|
||||||
}
|
}
|
||||||
|
uni.$on("update-header-loading", updateLoading);
|
||||||
uni.$on("update-hot", updateHot);
|
uni.$on("update-hot", updateHot);
|
||||||
});
|
});
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
uni.$off("update-header-loading", updateLoading);
|
||||||
uni.$off("update-hot", updateHot);
|
uni.$off("update-hot", updateHot);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -152,6 +161,12 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
|
<image
|
||||||
|
:style="{ opacity: showLoader && loading ? 0 : 0 }"
|
||||||
|
src="../static/btn-loading.png"
|
||||||
|
mode="widthFix"
|
||||||
|
class="loading"
|
||||||
|
/>
|
||||||
<view v-if="pointBook" class="point-book-info">
|
<view v-if="pointBook" class="point-book-info">
|
||||||
<text>{{ pointBook.bowType.name }}</text>
|
<text>{{ pointBook.bowType.name }}</text>
|
||||||
<text>{{ pointBook.distance }} 米</text>
|
<text>{{ pointBook.distance }} 米</text>
|
||||||
@@ -215,6 +230,14 @@ onBeforeUnmount(() => {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
.loading {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
margin-left: 10px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
background-blend-mode: darken;
|
||||||
|
animation: rotate 2s linear infinite;
|
||||||
|
}
|
||||||
.point-book-info {
|
.point-book-info {
|
||||||
color: #333;
|
color: #333;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText } from "@/util";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
@@ -26,8 +26,9 @@ watch(
|
|||||||
let key = [];
|
let key = [];
|
||||||
if (newVal.includes("重回")) return;
|
if (newVal.includes("重回")) return;
|
||||||
if (currentRoundEnded.value) {
|
if (currentRoundEnded.value) {
|
||||||
|
currentRound.value += 1;
|
||||||
// 播放当前轮次语音
|
// 播放当前轮次语音
|
||||||
key.push(`第${["一", "二", "三", "四", "五"][currentRound.value]}轮`);
|
key.push(`第${["一", "二", "三", "四", "五"][currentRound.value - 1]}轮`);
|
||||||
}
|
}
|
||||||
key.push(
|
key.push(
|
||||||
newVal.includes("你")
|
newVal.includes("你")
|
||||||
@@ -46,42 +47,80 @@ const updateSound = () => {
|
|||||||
audioManager.setMuted(!sound.value);
|
audioManager.setMuted(!sound.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onReceiveMessage(message) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (ended.value) return;
|
if (ended.value) return;
|
||||||
if (Array.isArray(message)) return;
|
messages.forEach((msg) => {
|
||||||
const { type, mode, current, shootData } = message;
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
if (type === MESSAGETYPESV2.BattleStart) {
|
if (melee.value && msg.userId !== user.value.id) return;
|
||||||
melee.value = Boolean(mode > 3);
|
if (msg.userId === user.value.id) currentShot.value++;
|
||||||
totalShot.value = mode === 1 ? 3 : 2;
|
if (msg.battleInfo && msg.userId === user.value.id) {
|
||||||
currentRoundEnded.value = true;
|
const players = [
|
||||||
audioManager.play("比赛开始");
|
...(msg.battleInfo.blueTeam || []),
|
||||||
} else if (type === MESSAGETYPESV2.BattleEnd) {
|
...(msg.battleInfo.redTeam || []),
|
||||||
audioManager.play("比赛结束");
|
];
|
||||||
} else if (type === MESSAGETYPESV2.ShootResult) {
|
const currentPlayer = players.find((p) => p.id === msg.userId);
|
||||||
if (melee.value && current.playerId !== user.value.id) return;
|
|
||||||
if (current.playerId === user.value.id) currentShot.value++;
|
|
||||||
if (message.shootData) {
|
|
||||||
let key = [];
|
|
||||||
key.push(
|
|
||||||
shootData.ring
|
|
||||||
? `${shootData.ringX ? "X" : shootData.ring}环`
|
|
||||||
: "未上靶"
|
|
||||||
);
|
|
||||||
if (shootData.angle !== null)
|
|
||||||
key.push(`向${getDirectionText(shootData.angle)}调整`);
|
|
||||||
audioManager.play(key, false);
|
|
||||||
}
|
|
||||||
} else if (type === MESSAGETYPESV2.NewRound) {
|
|
||||||
currentShot.value = 0;
|
currentShot.value = 0;
|
||||||
currentRound.value = current.round;
|
try {
|
||||||
currentRoundEnded.value = true;
|
if (
|
||||||
} else if (type === MESSAGETYPESV2.InvalidShot) {
|
currentPlayer &&
|
||||||
|
currentPlayer.shotHistory &&
|
||||||
|
currentPlayer.shotHistory[msg.battleInfo.currentRound]
|
||||||
|
) {
|
||||||
|
currentShot.value =
|
||||||
|
currentPlayer.shotHistory[msg.battleInfo.currentRound].length;
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
if (!halfTime.value && msg.target) {
|
||||||
|
let key = [];
|
||||||
|
key.push(msg.target.ring ? `${msg.target.ring}环` : "未上靶");
|
||||||
|
if (!msg.target.ring)
|
||||||
|
key.push(`向${getDirectionText(msg.target.angle)}调整`);
|
||||||
|
audioManager.play(key);
|
||||||
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.InvalidShot) {
|
||||||
|
if (msg.userId === user.value.id) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "距离不足,无效",
|
title: "距离不足,无效",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
audioManager.play("射击无效");
|
audioManager.play("射击无效");
|
||||||
}
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.AllReady) {
|
||||||
|
const { config } = msg.groupUserStatus;
|
||||||
|
if (config && config.mode === 1) {
|
||||||
|
totalShot.value = config.teamSize === 2 ? 3 : 2;
|
||||||
|
}
|
||||||
|
currentRoundEnded.value = true;
|
||||||
|
audioManager.play("比赛开始");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||||
|
melee.value = true;
|
||||||
|
halfTime.value = false;
|
||||||
|
audioManager.play("比赛开始");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||||
|
currentShot.value = 0;
|
||||||
|
if (msg.preRoundResult && msg.preRoundResult.currentRound) {
|
||||||
|
currentRound.value = msg.preRoundResult.currentRound;
|
||||||
|
currentRoundEnded.value = true;
|
||||||
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||||
|
halfTime.value = true;
|
||||||
|
audioManager.play("中场休息");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
audioManager.play("比赛结束");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||||
|
totalShot.value = 0;
|
||||||
|
audioManager.play("决金箭轮");
|
||||||
|
tips.value = "即将开始...";
|
||||||
|
currentRoundEnded.value = false;
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
ended.value = true;
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||||
|
if (msg.battleInfo) {
|
||||||
|
melee.value = msg.battleInfo.config.mode === 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const playSound = (key) => {
|
const playSound = (key) => {
|
||||||
|
|||||||
142
src/components/LiveItem.vue
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
|
||||||
|
const props = defineProps({});
|
||||||
|
|
||||||
|
onMounted(async () => {});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="live-item">
|
||||||
|
<view>
|
||||||
|
<image src="../static/user-icon-dark.png" mode="widthFix" />
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>陈百强姓陈</text>
|
||||||
|
<view>
|
||||||
|
<text>节奏迅猛</text>
|
||||||
|
<text>节奏迅猛</text>
|
||||||
|
</view>
|
||||||
|
<view class="live-item-avatars">
|
||||||
|
<view :style="{ width: `${25 * 5 + 25}rpx` }">
|
||||||
|
<image
|
||||||
|
v-for="(avatar, i) in [1, 2, 3, 4, 5]"
|
||||||
|
:key="avatar"
|
||||||
|
:src="'../static/user-icon.png'"
|
||||||
|
:style="{
|
||||||
|
zIndex: i,
|
||||||
|
transform: `translateX(-${10 * i}rpx)`,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text>观战中...</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<view>
|
||||||
|
<image src="../static/race-title-bg.png" mode="widthFix" />
|
||||||
|
<text>1v1对抗</text>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>本轮环数</text>
|
||||||
|
<text>62</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.live-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background: #252831;
|
||||||
|
padding: 25rpx;
|
||||||
|
border-radius: 25rpx;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(1) {
|
||||||
|
width: 150rpx;
|
||||||
|
height: 150rpx;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(1) > image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 25rpx;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(2) {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0 20rpx;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(2) > text {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(2) > view:nth-child(2) {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #ffa61b;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(2) > view:nth-child(2) > text {
|
||||||
|
line-height: 28rpx;
|
||||||
|
border-radius: 15rpx;
|
||||||
|
border: 2rpx solid #ffc05d;
|
||||||
|
padding: 0 10rpx;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
}
|
||||||
|
.live-item-avatars {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
.live-item-avatars > view {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.live-item-avatars > view > image {
|
||||||
|
width: 36rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border: 1rpx solid #000;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(3) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-around;
|
||||||
|
height: 150rpx;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(3) > view:first-child {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #c46e36;
|
||||||
|
transform: translateX(100rpx);
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(3) > view:first-child > text {
|
||||||
|
transform: translateX(-90rpx);
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(3) > view:first-child > image {
|
||||||
|
width: 160rpx;
|
||||||
|
height: 50rpx;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(3) > view:last-child {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
.live-item > view:nth-child(3) > view:last-child > text:last-child {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 48rpx;
|
||||||
|
color: #ffd299;
|
||||||
|
margin-left: 10rpx;
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
204
src/components/MyRank.vue
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, watch } from "vue";
|
||||||
|
|
||||||
|
import useStore from "@/store";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
const store = useStore();
|
||||||
|
const { getLvlName } = store;
|
||||||
|
const { config, user } = storeToRefs(store);
|
||||||
|
|
||||||
|
const props = defineProps({});
|
||||||
|
|
||||||
|
const nextLvlPoints = ref(0);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [config.value, user.value],
|
||||||
|
([n_config, n_user]) => {
|
||||||
|
const rankInfos = n_config.randInfos || [];
|
||||||
|
if (n_user.id && rankInfos.length) {
|
||||||
|
rankInfos.some((r, index) => {
|
||||||
|
if (r.upgrade_scores && r.upgrade_scores > n_user.scores) {
|
||||||
|
nextLvlPoints.value = r.upgrade_scores;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
deep: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="my-rank">
|
||||||
|
<view>
|
||||||
|
<image :src="user.avatar || '../static/user-icon.png'" mode="widthFix" />
|
||||||
|
<view>
|
||||||
|
<text class="score color1">积分榜:分</text>
|
||||||
|
<text class="score color2">Mvp榜:次</text>
|
||||||
|
<text class="score color3">十环榜:次</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text class="truncate">{{ user.nickName }}</text>
|
||||||
|
<image class="user-name-image" src="../static/vip1.png" mode="widthFix" />
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>lv{{ user.lvl }}</text>
|
||||||
|
<view>
|
||||||
|
<view
|
||||||
|
:style="{
|
||||||
|
width: `${(Math.max(user.scores, 0) / nextLvlPoints) * 100}%`,
|
||||||
|
}"
|
||||||
|
></view>
|
||||||
|
<text>{{ Math.max(user.scores, 0) }}/{{ nextLvlPoints }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<view>
|
||||||
|
<text>段位</text>
|
||||||
|
<text>{{ user.rankLvl ? getLvlName(user.rankLvl) : "暂无" }}</text>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>平均环数</text>
|
||||||
|
<text>{{ user.avg_ring ? user.avg_ring + "环" : "暂无" }}</text>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>胜率</text>
|
||||||
|
<text>{{
|
||||||
|
user.avg_win ? Number((user.avg_win * 100).toFixed(2)) + "%" : "暂无"
|
||||||
|
}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.my-rank {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-left: 40rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:first-child {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.my-rank > view:first-child > image {
|
||||||
|
width: 120rpx;
|
||||||
|
height: 120rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 30rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:first-child > view {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
.score {
|
||||||
|
line-height: 40rpx;
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #fff;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.score::before {
|
||||||
|
content: "";
|
||||||
|
width: calc(100% + 20rpx);
|
||||||
|
height: 10rpx;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
.color1::before {
|
||||||
|
background-color: #c9ff7e;
|
||||||
|
}
|
||||||
|
.color2::before {
|
||||||
|
background-color: #fff14b;
|
||||||
|
}
|
||||||
|
.color3::before {
|
||||||
|
background-color: #7efff7;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(2) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(2) > text {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
max-width: 80%;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(2) > image {
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(3) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 16rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(3) > text:first-child {
|
||||||
|
width: 80rpx;
|
||||||
|
height: 20rpx;
|
||||||
|
background: #978eff;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
line-height: 22rpx;
|
||||||
|
text-align: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(3) > view {
|
||||||
|
position: relative;
|
||||||
|
width: calc(100% - 100rpx);
|
||||||
|
height: 20rpx;
|
||||||
|
background: #c8c8c8;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(3) > view > view {
|
||||||
|
background-color: #c7a670;
|
||||||
|
height: 20rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(3) > view > text {
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(4) {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
column-gap: 20rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(4) > view {
|
||||||
|
height: 112rpx;
|
||||||
|
background: #f6f6f61a;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #999999;
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
.my-rank > view:nth-child(4) > view > text:last-child {
|
||||||
|
color: #fff;
|
||||||
|
font-size: 22rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
98
src/components/NoticeBar.vue
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
|
|
||||||
|
import useStore from "@/store";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
const { user } = storeToRefs(useStore());
|
||||||
|
|
||||||
|
const props = defineProps({});
|
||||||
|
const list = [1, 2, 3, 4, 5];
|
||||||
|
const timer = ref(null);
|
||||||
|
const offset = ref(0);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
timer.value = setInterval(() => {
|
||||||
|
if (offset.value <= -100 * list.length) {
|
||||||
|
offset.value = 100;
|
||||||
|
} else {
|
||||||
|
offset.value -= 0.2;
|
||||||
|
}
|
||||||
|
}, 10);
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
clearInterval(timer.value);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="notice-bar">
|
||||||
|
<image src="../static/announce.png" mode="heightFix" />
|
||||||
|
<view>
|
||||||
|
<view
|
||||||
|
v-for="(item, index) in list"
|
||||||
|
:key="item"
|
||||||
|
:style="{
|
||||||
|
transform: `translateX(${offset}%)`,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<image src="../static/user-icon.png" mode="widthFix" />
|
||||||
|
<text class="truncate">{{ index + 1 }}毛毛丛</text>
|
||||||
|
<text>成功晋升</text>
|
||||||
|
<text>荣耀王者</text>
|
||||||
|
<text>段位,从此横着走!</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<image src="../static/enter.png" mode="widthFix" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.notice-bar {
|
||||||
|
margin-top: 10rpx;
|
||||||
|
background: linear-gradient(180deg, #2f2d2b 0%, #252831 100%);
|
||||||
|
border-radius: 25rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.notice-bar > image:first-child {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.notice-bar > view {
|
||||||
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.notice-bar > view > view {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 24rpx;
|
||||||
|
padding-left: 15rpx;
|
||||||
|
color: #999;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.notice-bar > view > view > image {
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
.notice-bar > view > view > text {
|
||||||
|
word-break: keep-all;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.notice-bar > view > view > text:nth-child(2) {
|
||||||
|
color: #fff;
|
||||||
|
width: 100rpx;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.notice-bar > view > view > text:nth-child(4) {
|
||||||
|
color: #e7ba80;
|
||||||
|
}
|
||||||
|
.notice-bar > image:last-child {
|
||||||
|
width: 30rpx;
|
||||||
|
height: 30rpx;
|
||||||
|
margin: 0 20rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,7 +3,7 @@ import useStore from "@/store";
|
|||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const { user } = storeToRefs(useStore());
|
const { user } = storeToRefs(useStore());
|
||||||
|
|
||||||
const props = defineProps({
|
defineProps({
|
||||||
player: {
|
player: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
@@ -23,10 +23,7 @@ const rowCount = new Array(6).fill(0);
|
|||||||
:style="{ borderColor: player.id === user.id ? '#FED847' : '#fff3' }"
|
:style="{ borderColor: player.id === user.id ? '#FED847' : '#fff3' }"
|
||||||
>
|
>
|
||||||
<image
|
<image
|
||||||
:style="{
|
:style="{ opacity: scores.length === 12 ? 1 : 0 }"
|
||||||
opacity:
|
|
||||||
(scores[0] || []).length + (scores[1] || []).length === 12 ? 1 : 0,
|
|
||||||
}"
|
|
||||||
src="../static/checked-green.png"
|
src="../static/checked-green.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
@@ -35,24 +32,20 @@ const rowCount = new Array(6).fill(0);
|
|||||||
<view>
|
<view>
|
||||||
<view>
|
<view>
|
||||||
<view v-for="(_, index) in rowCount" :key="index">
|
<view v-for="(_, index) in rowCount" :key="index">
|
||||||
<text>{{
|
<text>{{ scores[index] ? `${scores[index].ring}环` : "-" }}</text>
|
||||||
scores[0] && scores[0][index] ? `${scores[0][index].ring}环` : "-"
|
|
||||||
}}</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<view v-for="(_, index) in rowCount" :key="index">
|
<view v-for="(_, index) in rowCount" :key="index">
|
||||||
<text>{{
|
<text>{{
|
||||||
scores[1] && scores[1][index] ? `${scores[0][index].ring}环` : "-"
|
scores[index + 6] ? `${scores[index + 6].ring}环` : "-"
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text
|
<text
|
||||||
>{{
|
>{{
|
||||||
scores
|
scores.map((s) => s.ring).reduce((last, next) => last + next, 0)
|
||||||
.map((s) => s.reduce((last, next) => last + next.ring, 0))
|
|
||||||
.reduce((last, next) => last + next, 0)
|
|
||||||
}}环</text
|
}}环</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: "",
|
default: "",
|
||||||
},
|
},
|
||||||
arrows: {
|
scores: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
@@ -21,6 +21,10 @@ defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
totalRing: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const rowCount = new Array(6).fill(0);
|
const rowCount = new Array(6).fill(0);
|
||||||
</script>
|
</script>
|
||||||
@@ -56,19 +60,19 @@ const rowCount = new Array(6).fill(0);
|
|||||||
<view>
|
<view>
|
||||||
<view>
|
<view>
|
||||||
<view v-for="(_, index) in rowCount" :key="index">
|
<view v-for="(_, index) in rowCount" :key="index">
|
||||||
<text>{{ arrows[index] ? `${arrows[index].ring}环` : "-" }}</text>
|
<text>{{ scores[index] ? `${scores[index].ring}环` : "-" }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<view v-for="(_, index) in rowCount" :key="index">
|
<view v-for="(_, index) in rowCount" :key="index">
|
||||||
<text>{{
|
<text>{{
|
||||||
arrows[index + 6] ? `${arrows[index + 6].ring}环` : "-"
|
scores[index + 6] ? `${scores[index + 6].ring}环` : "-"
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<text>{{ arrows.reduce((last, next) => last + next.ring, 0) }}环</text>
|
<text>{{ totalRing }}环</text>
|
||||||
<text>积分{{ totalScore }}</text>
|
<text>积分{{ totalScore }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Avatar from "@/components/Avatar.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
total: {
|
total: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -10,10 +8,6 @@ const props = defineProps({
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
removePlayer: {
|
|
||||||
type: Function,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const seats = new Array(props.total).fill(1);
|
const seats = new Array(props.total).fill(1);
|
||||||
</script>
|
</script>
|
||||||
@@ -22,16 +16,11 @@ const seats = new Array(props.total).fill(1);
|
|||||||
<view class="players">
|
<view class="players">
|
||||||
<view v-for="(_, index) in seats" :key="index">
|
<view v-for="(_, index) in seats" :key="index">
|
||||||
<image src="../static/player-bg.png" mode="widthFix" />
|
<image src="../static/player-bg.png" mode="widthFix" />
|
||||||
<view v-if="players[index] && players[index].name" class="avatar">
|
<image
|
||||||
<Avatar
|
v-if="players[index] && players[index].name"
|
||||||
:src="players[index].avatar || '../static/user-icon.png'"
|
:src="players[index].avatar || '../static/user-icon.png'"
|
||||||
:size="40"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
<text
|
|
||||||
:style="{ opacity: players[index] && !!players[index].state ? 1 : 0 }"
|
|
||||||
>已准备</text
|
|
||||||
>
|
|
||||||
</view>
|
|
||||||
<view v-else class="player-unknow">
|
<view v-else class="player-unknow">
|
||||||
<image src="../static/question-mark.png" mode="widthFix" />
|
<image src="../static/question-mark.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
@@ -39,68 +28,48 @@ const seats = new Array(props.total).fill(1);
|
|||||||
players[index].name
|
players[index].name
|
||||||
}}</text>
|
}}</text>
|
||||||
<text v-else :style="{ color: '#fff9' }">虚位以待</text>
|
<text v-else :style="{ color: '#fff9' }">虚位以待</text>
|
||||||
<view v-if="index === 0" class="founder">管理员</view>
|
<view v-if="index === 0" class="founder">创建者</view>
|
||||||
<!-- <image
|
<image
|
||||||
:src="`../static/player-${index + 1}.png`"
|
:src="`../static/player-${index + 1}.png`"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
class="player-bg"
|
class="player-bg"
|
||||||
/> -->
|
/>
|
||||||
<button
|
|
||||||
v-if="index > 0 && players[index]"
|
|
||||||
hover-class="none"
|
|
||||||
class="remove-player"
|
|
||||||
@click="() => removePlayer(players[index])"
|
|
||||||
>
|
|
||||||
<image src="../static/close-white.png" mode="widthFix" />
|
|
||||||
</button>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.players {
|
.players {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
flex-wrap: wrap;
|
||||||
row-gap: 20rpx;
|
justify-content: flex-start;
|
||||||
column-gap: 25rpx;
|
-moz-column-gap: 20px;
|
||||||
|
column-gap: 14px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
}
|
}
|
||||||
.players > view {
|
.players > view {
|
||||||
|
width: calc(50% - 7px);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
height: 176rpx;
|
height: 100px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.players > view > image:first-child {
|
.players > view > image:first-child {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
top: 0;
|
|
||||||
}
|
}
|
||||||
.avatar {
|
.players > view > image:nth-child(2) {
|
||||||
display: flex;
|
width: 40px;
|
||||||
flex-direction: column;
|
height: 40px;
|
||||||
align-items: center;
|
min-height: 40px;
|
||||||
padding: 0 24rpx;
|
margin: 0 10px;
|
||||||
margin-top: 16rpx;
|
border: 1px solid #fff;
|
||||||
}
|
border-radius: 50%;
|
||||||
.avatar > text {
|
|
||||||
background-color: #2c261fb3;
|
|
||||||
border: 1rpx solid #a3793f66;
|
|
||||||
color: #fed847;
|
|
||||||
font-size: 16rpx;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
width: 70rpx;
|
|
||||||
text-align: center;
|
|
||||||
margin-top: -16rpx;
|
|
||||||
position: relative;
|
|
||||||
height: 28rpx;
|
|
||||||
line-height: 28rpx;
|
|
||||||
}
|
}
|
||||||
.players > view > text:nth-child(3) {
|
.players > view > text:nth-child(3) {
|
||||||
width: 20vw;
|
width: 20vw;
|
||||||
@@ -111,48 +80,30 @@ const seats = new Array(props.total).fill(1);
|
|||||||
.founder {
|
.founder {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: #fed847;
|
background-color: #fed847;
|
||||||
top: 0;
|
top: 6px;
|
||||||
left: 0;
|
|
||||||
color: #000;
|
color: #000;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
border-top-left-radius: 10px;
|
border-top-left-radius: 10px;
|
||||||
border-bottom-right-radius: 10px;
|
border-bottom-right-radius: 10px;
|
||||||
}
|
}
|
||||||
/* .player-bg {
|
.player-bg {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 52px;
|
width: 52px;
|
||||||
right: 0;
|
right: 0;
|
||||||
} */
|
}
|
||||||
.player-unknow {
|
.player-unknow {
|
||||||
width: 84rpx;
|
width: 40px;
|
||||||
height: 84rpx;
|
height: 40px;
|
||||||
margin: 0 24rpx;
|
margin: 0 10px;
|
||||||
border: 1rpx solid #fff3;
|
border: 1px solid #fff3;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background-color: #69686866;
|
background-color: #69686866;
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
.player-unknow > image {
|
.player-unknow > image {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
}
|
}
|
||||||
.remove-player {
|
|
||||||
width: 48rpx;
|
|
||||||
height: 48rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
position: absolute;
|
|
||||||
top: 10rpx;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
.remove-player > image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
137
src/components/PlayersRow.vue
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
<script setup>
|
||||||
|
defineProps({
|
||||||
|
avatar: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
blueTeam: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
redTeam: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
currentShooterId: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<image v-if="avatar" class="avatar" :src="avatar" mode="widthFix" />
|
||||||
|
<view
|
||||||
|
v-if="blueTeam.length && redTeam.length"
|
||||||
|
:style="{ height: 20 + blueTeam.length * 20 + 'px' }"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
v-for="(player, index) in blueTeam"
|
||||||
|
:key="index"
|
||||||
|
:style="{
|
||||||
|
top: index * 20 + 'px',
|
||||||
|
zIndex: blueTeam.length - index,
|
||||||
|
left: 0,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<image
|
||||||
|
class="avatar"
|
||||||
|
:src="player.avatar || '../static/user-icon.png'"
|
||||||
|
mode="widthFix"
|
||||||
|
:style="{
|
||||||
|
borderColor: currentShooterId === player.id ? '#5fadff' : '#fff',
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<text
|
||||||
|
:style="{
|
||||||
|
color: currentShooterId === player.id ? '#5fadff' : '#fff',
|
||||||
|
fontSize: currentShooterId === player.id ? 16 : 12 + 'px',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ player.name }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-if="!avatar"
|
||||||
|
:style="{
|
||||||
|
height: 20 + redTeam.length * 20 + 'px',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
v-for="(player, index) in redTeam"
|
||||||
|
:key="index"
|
||||||
|
:style="{
|
||||||
|
top: index * 20 + 'px',
|
||||||
|
zIndex: redTeam.length - index,
|
||||||
|
right: 0,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<text
|
||||||
|
:style="{
|
||||||
|
color: currentShooterId === player.id ? '#ff6060' : '#fff',
|
||||||
|
fontSize: currentShooterId === player.id ? 16 : 12 + 'px',
|
||||||
|
textAlign: 'right',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ player.name }}
|
||||||
|
</text>
|
||||||
|
<image
|
||||||
|
class="avatar"
|
||||||
|
:src="player.avatar || '../static/user-icon.png'"
|
||||||
|
mode="widthFix"
|
||||||
|
:style="{
|
||||||
|
borderColor: currentShooterId === player.id ? '#ff6060' : '#fff',
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.container {
|
||||||
|
width: calc(100% - 30px);
|
||||||
|
margin: 0 15px;
|
||||||
|
margin-top: 5px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
.container > view {
|
||||||
|
width: 50%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.container > view > view {
|
||||||
|
position: absolute;
|
||||||
|
top: -20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: all 0.3s linear;
|
||||||
|
}
|
||||||
|
.container > view > view > text {
|
||||||
|
margin: 0 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
width: 120px;
|
||||||
|
transition: all 0.3s linear;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.avatar {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
min-width: 40px;
|
||||||
|
min-height: 40px;
|
||||||
|
border: 1px solid #fff;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
.red-avatar {
|
||||||
|
border: 1px solid #ff6060;
|
||||||
|
}
|
||||||
|
.blue-avatar {
|
||||||
|
border: 1px solid #5fadff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -52,14 +52,14 @@ onBeforeUnmount(() => {
|
|||||||
<view class="point-view1" v-if="bluePoint !== 0 || redPoint !== 0">
|
<view class="point-view1" v-if="bluePoint !== 0 || redPoint !== 0">
|
||||||
<text>本轮蓝队</text>
|
<text>本轮蓝队</text>
|
||||||
<text>{{
|
<text>{{
|
||||||
(roundData.shoots[1] || []).reduce(
|
(roundData.blueArrows || []).reduce(
|
||||||
(last, next) => last + next.ring,
|
(last, next) => last + next.ring,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
}}</text>
|
}}</text>
|
||||||
<text>环,红队</text>
|
<text>环,红队</text>
|
||||||
<text>{{
|
<text>{{
|
||||||
(roundData.shoots[2] || []).reduce(
|
(roundData.redArrows || []).reduce(
|
||||||
(last, next) => last + next.ring,
|
(last, next) => last + next.ring,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ watch(
|
|||||||
transform: translateY(100%);
|
transform: translateY(100%);
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: #372E1D;
|
|
||||||
}
|
}
|
||||||
.modal-content > image:first-child {
|
.modal-content > image:first-child {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
arrows: {
|
scores: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
@@ -51,7 +51,7 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<image
|
<image
|
||||||
v-if="total > 0 && arrows.length === total && completeEffect"
|
v-if="total > 0 && scores.length === total && completeEffect"
|
||||||
:src="bgImages[bgIndex]"
|
:src="bgImages[bgIndex]"
|
||||||
class="complete-light"
|
class="complete-light"
|
||||||
:style="{
|
:style="{
|
||||||
@@ -79,10 +79,8 @@ onBeforeUnmount(() => {
|
|||||||
>
|
>
|
||||||
<image src="../static/score-bg.png" mode="widthFix" />
|
<image src="../static/score-bg.png" mode="widthFix" />
|
||||||
<text
|
<text
|
||||||
:style="{ fontWeight: arrows[index] !== undefined ? 'bold' : 'normal' }"
|
:style="{ fontWeight: scores[index] !== undefined ? 'bold' : 'normal' }"
|
||||||
>{{
|
>{{ scores[index] !== undefined ? scores[index] : "-" }}</text
|
||||||
!arrows[index] ? "-" : arrows[index].ringX ? "X" : arrows[index].ring
|
|
||||||
}}</text
|
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
arrows: {
|
scores: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
@@ -10,34 +10,37 @@ const getSum = (a, b, c) => {
|
|||||||
return sum > 0 ? sum + "环" : "-";
|
return sum > 0 ? sum + "环" : "-";
|
||||||
};
|
};
|
||||||
const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"];
|
const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"];
|
||||||
const getShowText = (arrow = {}) => {
|
|
||||||
return arrow.ring ? (arrow.ringX ? "X" : arrow.ring + "环") : "-";
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view>
|
<view>
|
||||||
<text :style="{ transform: 'translateX(-10%)' }">总成绩</text>
|
<text :style="{ transform: 'translateX(-10%)' }">总成绩</text>
|
||||||
<text>{{ arrows.reduce((last, next) => last + next.ring, 0) }}环</text>
|
<text>{{ scores.reduce((last, next) => last + next, 0) }}环</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
v-for="(_, index) in new Array(
|
v-for="(_, index) in new Array(
|
||||||
Math.min(
|
Math.min(
|
||||||
Math.ceil(arrows.length / 3) + (arrows.length % 3 === 0 ? 1 : 0),
|
Math.ceil(scores.length / 3) + (scores.length % 3 === 0 ? 1 : 0),
|
||||||
4
|
4
|
||||||
)
|
)
|
||||||
).fill(1)"
|
).fill(1)"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<text>{{ roundsName[index] }}</text>
|
<text>{{ roundsName[index] }}</text>
|
||||||
<text>{{ getShowText(arrows[index * 3 + 0]) }}</text>
|
<text>{{
|
||||||
<text>{{ getShowText(arrows[index * 3 + 1]) }}</text>
|
scores[index * 3 + 0] ? scores[index * 3 + 0] + "环" : "-"
|
||||||
<text>{{ getShowText(arrows[index * 3 + 2]) }}</text>
|
}}</text>
|
||||||
|
<text>{{
|
||||||
|
scores[index * 3 + 1] ? scores[index * 3 + 1] + "环" : "-"
|
||||||
|
}}</text>
|
||||||
|
<text>{{
|
||||||
|
scores[index * 3 + 2] ? scores[index * 3 + 2] + "环" : "-"
|
||||||
|
}}</text>
|
||||||
<text :style="{ width: '40%', transform: 'translateX(20%)' }">{{
|
<text :style="{ width: '40%', transform: 'translateX(20%)' }">{{
|
||||||
getSum(
|
getSum(
|
||||||
arrows[index * 3 + 0],
|
scores[index * 3 + 0],
|
||||||
arrows[index * 3 + 1],
|
scores[index * 3 + 1],
|
||||||
arrows[index * 3 + 2]
|
scores[index * 3 + 2]
|
||||||
)
|
)
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -50,26 +50,22 @@ onMounted(() => {
|
|||||||
if (props.result.lvl > user.value.lvl) {
|
if (props.result.lvl > user.value.lvl) {
|
||||||
showUpgrade.value = true;
|
showUpgrade.value = true;
|
||||||
}
|
}
|
||||||
totalRing.value = (props.result.details || []).reduce(
|
totalRing.value = (props.result.arrows || []).reduce(
|
||||||
(last, next) => last + next.ring,
|
(last, next) => last + next.ring,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const getRing = (arrow) => {
|
const validArrows = computed(() => {
|
||||||
if (arrow.ringX) return "X";
|
return (props.result.arrows || []).filter(
|
||||||
return arrow.ring ? arrow.ring : "-";
|
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||||
};
|
).length;
|
||||||
|
|
||||||
const arrows = computed(() => {
|
|
||||||
const data = new Array(props.total).fill({ ring: 0 });
|
|
||||||
(props.result.details || []).forEach((arrow, index) => {
|
|
||||||
data[index] = arrow;
|
|
||||||
});
|
|
||||||
return data;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const validArrows = computed(() => arrows.value.filter((a) => !!a.ring).length);
|
const getRing = (arrow) => {
|
||||||
|
if (arrow && arrow.x !== -30 && arrow.y !== -30) return arrow.ring;
|
||||||
|
return "-";
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -100,8 +96,8 @@ const validArrows = computed(() => arrows.value.filter((a) => !!a.ring).length);
|
|||||||
</view>
|
</view>
|
||||||
<view :style="{ gridTemplateColumns: `repeat(${rowCount}, 1fr)` }">
|
<view :style="{ gridTemplateColumns: `repeat(${rowCount}, 1fr)` }">
|
||||||
<view v-for="(_, index) in new Array(total).fill(0)" :key="index">
|
<view v-for="(_, index) in new Array(total).fill(0)" :key="index">
|
||||||
{{ getRing(arrows[index])
|
{{ getRing(result.arrows[index])
|
||||||
}}<text v-if="getRing(arrows[index]) !== '-'">环</text>
|
}}<text v-if="getRing(result.arrows[index]) !== '-'">环</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
@@ -137,7 +133,7 @@ const validArrows = computed(() => arrows.value.filter((a) => !!a.ring).length);
|
|||||||
}}</text
|
}}</text
|
||||||
>环的成绩,所有箭支上靶后的平均点间距为<text
|
>环的成绩,所有箭支上靶后的平均点间距为<text
|
||||||
:style="{ color: '#fed847' }"
|
:style="{ color: '#fed847' }"
|
||||||
>{{ Number((result.average_distance || 0).toFixed(2)) }}</text
|
>{{ Number(result.average_distance.toFixed(2)) }}</text
|
||||||
>,{{
|
>,{{
|
||||||
result.spreadEvaluation === "Dispersed"
|
result.spreadEvaluation === "Dispersed"
|
||||||
? "还需要持续改进哦~"
|
? "还需要持续改进哦~"
|
||||||
@@ -164,8 +160,8 @@ const validArrows = computed(() => arrows.value.filter((a) => !!a.ring).length);
|
|||||||
</view>
|
</view>
|
||||||
</ScreenHint>
|
</ScreenHint>
|
||||||
<BowData
|
<BowData
|
||||||
:total="arrows.length"
|
:total="result.completed_arrows"
|
||||||
:arrows="result.details"
|
:arrows="result.arrows"
|
||||||
:show="showBowData"
|
:show="showBowData"
|
||||||
:onClose="() => (showBowData = false)"
|
:onClose="() => (showBowData = false)"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
import { getDirectionText } from "@/util";
|
import { getDirectionText } from "@/util";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
@@ -96,12 +96,8 @@ const resetTimer = (count) => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.start,
|
() => props.start,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal) {
|
if (newVal) resetTimer(props.total);
|
||||||
resetTimer(props.total);
|
else if (timer.value) clearInterval(timer.value);
|
||||||
} else {
|
|
||||||
remain.value = 0;
|
|
||||||
clearInterval(timer.value);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
@@ -120,36 +116,62 @@ const updateSound = () => {
|
|||||||
audioManager.setMuted(!sound.value);
|
audioManager.setMuted(!sound.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (Array.isArray(msg)) return;
|
if (ended.value) return;
|
||||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
messages.forEach((msg) => {
|
||||||
halfTime.value = false;
|
if (
|
||||||
audioManager.play("比赛开始");
|
(props.battleId && msg.constructor === MESSAGETYPES.ShootResult) ||
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
(!props.battleId && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID)
|
||||||
audioManager.play("比赛结束");
|
) {
|
||||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
if (props.melee && msg.userId !== user.value.id) return;
|
||||||
let arrow = {};
|
if (!halfTime.value && msg.target) {
|
||||||
if (msg.details && Array.isArray(msg.details)) {
|
|
||||||
arrow = msg.details[msg.details.length - 1];
|
|
||||||
} else {
|
|
||||||
if (msg.shootData.playerId !== user.value.id) return;
|
|
||||||
if (msg.shootData) arrow = msg.shootData;
|
|
||||||
}
|
|
||||||
let key = [];
|
let key = [];
|
||||||
key.push(arrow.ring ? `${arrow.ringX ? "X" : arrow.ring}环` : "未上靶");
|
key.push(msg.target.ring ? `${msg.target.ring}环` : "未上靶");
|
||||||
if (arrow.angle !== null)
|
if (!msg.target.ring)
|
||||||
key.push(`向${getDirectionText(arrow.angle)}调整`);
|
key.push(`向${getDirectionText(msg.target.angle)}调整`);
|
||||||
audioManager.play(key, false);
|
audioManager.play(key);
|
||||||
} else if (msg.type === MESSAGETYPESV2.HalfRest) {
|
}
|
||||||
halfTime.value = true;
|
} else if (msg.constructor === MESSAGETYPES.InvalidShot) {
|
||||||
audioManager.play("中场休息");
|
if (msg.userId === user.value.id) {
|
||||||
} else if (msg.type === MESSAGETYPESV2.InvalidShot) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "距离不足,无效",
|
title: "距离不足,无效",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
audioManager.play("射击无效");
|
audioManager.play("射击无效");
|
||||||
}
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.AllReady) {
|
||||||
|
audioManager.play("比赛开始");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||||
|
halfTime.value = false;
|
||||||
|
audioManager.play("比赛开始");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||||
|
currentRoundEnded.value = true;
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||||
|
if (props.battleId) {
|
||||||
|
halfTime.value = true;
|
||||||
|
audioManager.play("中场休息");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (wait.value !== msg.wait) {
|
||||||
|
setTimeout(() => {
|
||||||
|
wait.value = msg.wait;
|
||||||
|
if (msg.wait === 20) {
|
||||||
|
halfTime.value = true;
|
||||||
|
audioManager.play("中场休息", false);
|
||||||
|
}
|
||||||
|
if (msg.wait === 0) {
|
||||||
|
halfTime.value = false;
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
audioManager.play("比赛结束");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||||
|
audioManager.play("决金箭轮");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
ended.value = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const playSound = (key) => {
|
const playSound = (key) => {
|
||||||
@@ -157,13 +179,13 @@ const playSound = (key) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
uni.$on("update-remain", resetTimer);
|
uni.$on("update-ramain", resetTimer);
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
uni.$on("play-sound", playSound);
|
uni.$on("play-sound", playSound);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
uni.$off("update-remain", resetTimer);
|
uni.$off("update-ramain", resetTimer);
|
||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
uni.$off("play-sound", playSound);
|
uni.$off("play-sound", playSound);
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
|
|||||||
@@ -19,18 +19,6 @@ const props = defineProps({
|
|||||||
const barColor = ref("");
|
const barColor = ref("");
|
||||||
const remain = ref(15);
|
const remain = ref(15);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
const laoding = ref(false);
|
|
||||||
|
|
||||||
const updateRemain = (value) => {
|
|
||||||
// if (Math.ceil(value) === remain.value || Math.floor(value) === remain.value)
|
|
||||||
// return;
|
|
||||||
if (timer.value) clearInterval(timer.value);
|
|
||||||
remain.value = Math.round(value);
|
|
||||||
timer.value = setInterval(() => {
|
|
||||||
laoding.value = remain.value === 0;
|
|
||||||
if (remain.value > 0) remain.value--;
|
|
||||||
}, 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.tips,
|
() => props.tips,
|
||||||
@@ -41,7 +29,11 @@ watch(
|
|||||||
barColor.value = "linear-gradient( 180deg, #9AB3FF 0%, #4288FF 100%)";
|
barColor.value = "linear-gradient( 180deg, #9AB3FF 0%, #4288FF 100%)";
|
||||||
if (newVal.includes("重回")) return;
|
if (newVal.includes("重回")) return;
|
||||||
if (newVal.includes("红队") || newVal.includes("蓝队")) {
|
if (newVal.includes("红队") || newVal.includes("蓝队")) {
|
||||||
updateRemain(props.total);
|
if (timer.value) clearInterval(timer.value);
|
||||||
|
remain.value = props.total;
|
||||||
|
timer.value = setInterval(() => {
|
||||||
|
if (remain.value > 0) remain.value--;
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -49,12 +41,22 @@ watch(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const updateRemain = (value) => {
|
||||||
|
if (Math.ceil(value) === remain.value || Math.floor(value) === remain.value)
|
||||||
|
return;
|
||||||
|
if (timer.value) clearInterval(timer.value);
|
||||||
|
remain.value = Math.round(value);
|
||||||
|
timer.value = setInterval(() => {
|
||||||
|
if (remain.value > 0) remain.value--;
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
uni.$on("update-remain", updateRemain);
|
uni.$on("update-ramain", updateRemain);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
uni.$off("update-remain", updateRemain);
|
uni.$off("update-ramain", updateRemain);
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -74,8 +76,7 @@ onBeforeUnmount(() => {
|
|||||||
right: tips.includes('红队') ? 0 : 'unset',
|
right: tips.includes('红队') ? 0 : 'unset',
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<text v-if="!laoding">剩余{{ remain }}秒</text>
|
<text>剩余{{ remain }}秒</text>
|
||||||
<text v-else>···</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ const handleLogin = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
|
||||||
const wxResult = await wxLogin();
|
const wxResult = await wxLogin();
|
||||||
const fileManager = uni.getFileSystemManager();
|
const fileManager = uni.getFileSystemManager();
|
||||||
const avatarBase64 = fileManager.readFileSync(avatarUrl.value, "base64");
|
const avatarBase64 = fileManager.readFileSync(avatarUrl.value, "base64");
|
||||||
@@ -102,19 +101,14 @@ const handleLogin = async () => {
|
|||||||
if (data.user) updateUser(data.user);
|
if (data.user) updateUser(data.user);
|
||||||
const devices = await getMyDevicesAPI();
|
const devices = await getMyDevicesAPI();
|
||||||
if (devices.bindings && devices.bindings.length) {
|
if (devices.bindings && devices.bindings.length) {
|
||||||
updateDevice(
|
updateDevice(devices.bindings[0].deviceId, devices.bindings[0].deviceName);
|
||||||
devices.bindings[0].deviceId,
|
try {
|
||||||
devices.bindings[0].deviceName
|
|
||||||
);
|
|
||||||
const data = await getDeviceBatteryAPI();
|
const data = await getDeviceBatteryAPI();
|
||||||
updateOnline(data.online);
|
updateOnline(data.online);
|
||||||
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
props.onClose();
|
|
||||||
} catch (error) {
|
|
||||||
console.log("login error", error);
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
props.onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openServiceLink = () => {
|
const openServiceLink = () => {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const handleChange = (e) => {
|
|||||||
|
|
||||||
.dots {
|
.dots {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 5%;
|
bottom: 15%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -90,6 +90,6 @@ const handleChange = (e) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dot.active {
|
.dot.active {
|
||||||
background-color: #fed847;
|
background-color: #000;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,197 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { ref, watch } from "vue";
|
|
||||||
import SButton from "@/components/SButton.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
show: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
onClose: {
|
|
||||||
type: Function,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
onConfirm: {
|
|
||||||
type: Function,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectedTarget = ref(2);
|
|
||||||
const showContainer = ref(false);
|
|
||||||
const showContent = ref(false);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.show,
|
|
||||||
(newValue) => {
|
|
||||||
if (newValue) {
|
|
||||||
showContainer.value = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
showContent.value = true;
|
|
||||||
}, 100);
|
|
||||||
} else {
|
|
||||||
showContent.value = false;
|
|
||||||
setTimeout(() => {
|
|
||||||
showContainer.value = false;
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleConfirm = () => {
|
|
||||||
props.onConfirm(selectedTarget.value);
|
|
||||||
props.onClose();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view
|
|
||||||
class="container"
|
|
||||||
v-if="showContainer"
|
|
||||||
:class="{ 'container-show': showContent }"
|
|
||||||
@click="onClose"
|
|
||||||
>
|
|
||||||
<view
|
|
||||||
class="modal-content"
|
|
||||||
:class="{ 'modal-show': showContent }"
|
|
||||||
@click.stop=""
|
|
||||||
>
|
|
||||||
<view class="header">
|
|
||||||
<view class="header-title">
|
|
||||||
<view class="header-title-line-left"></view>
|
|
||||||
<text>选择靶型</text>
|
|
||||||
<view class="header-title-line-right"></view>
|
|
||||||
</view>
|
|
||||||
<view class="close-btn" @click="onClose">
|
|
||||||
<image src="../static/close-yellow.png" mode="widthFix" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="target-options">
|
|
||||||
<view
|
|
||||||
:class="{ 'target-btn': true, 'target-choosen': selectedTarget === 1 }"
|
|
||||||
@click="() => (selectedTarget = 1)"
|
|
||||||
>
|
|
||||||
<text>20厘米全环靶</text>
|
|
||||||
</view>
|
|
||||||
<view style="width: 30rpx"></view>
|
|
||||||
<view
|
|
||||||
:class="{ 'target-btn': true, 'target-choosen': selectedTarget === 2 }"
|
|
||||||
@click="() => (selectedTarget = 2)"
|
|
||||||
>
|
|
||||||
<text>40厘米全环靶</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<SButton width="694rpx" :onClick="handleConfirm">确定</SButton>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.container {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
background-color: #00000099;
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: flex-end;
|
|
||||||
align-items: center;
|
|
||||||
opacity: 0;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
z-index: 999;
|
|
||||||
}
|
|
||||||
.container-show {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
.modal-content {
|
|
||||||
width: 100%;
|
|
||||||
transform: translateY(100%);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
background: url("https://static.shelingxingqiu.com/attachment/2025-12-04/dep11770wzxg6o2alo.png")
|
|
||||||
no-repeat center top;
|
|
||||||
background-size: 100% auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
box-sizing: border-box;
|
|
||||||
padding-bottom: 68rpx;
|
|
||||||
padding-top: 44rpx;
|
|
||||||
}
|
|
||||||
.modal-show {
|
|
||||||
transform: translateY(0%);
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
position: relative;
|
|
||||||
margin-bottom: 44rpx;
|
|
||||||
}
|
|
||||||
.header-title{
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
.header-title text{
|
|
||||||
width: 196rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
font-family: PingFang SC, PingFang SC;
|
|
||||||
font-weight: 400;
|
|
||||||
font-size: 28rpx;
|
|
||||||
text-align: center;
|
|
||||||
font-style: normal;
|
|
||||||
text-transform: none;
|
|
||||||
color: #FFEFBA;
|
|
||||||
}
|
|
||||||
.header-title-line-left{
|
|
||||||
width: 214rpx;
|
|
||||||
height: 0rpx;
|
|
||||||
border-radius: 0rpx 0rpx 0rpx 0rpx;
|
|
||||||
border: 1rpx solid;
|
|
||||||
border-image: linear-gradient(90deg, rgba(133, 119, 96, 1), rgba(133, 119, 96, 0)) 1 1;
|
|
||||||
}
|
|
||||||
.header-title-line-right{
|
|
||||||
width: 214rpx;
|
|
||||||
height: 0rpx;
|
|
||||||
border-radius: 0rpx 0rpx 0rpx 0rpx;
|
|
||||||
border: 1rpx solid;
|
|
||||||
border-image: linear-gradient(90deg, rgba(133, 119, 96, 1), rgba(133, 119, 96, 0)) 1 1;
|
|
||||||
}
|
|
||||||
.close-btn {
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
top: -10px;
|
|
||||||
}
|
|
||||||
.close-btn > image {
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
}
|
|
||||||
.target-options {
|
|
||||||
width: 750rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 38rpx;
|
|
||||||
}
|
|
||||||
.target-btn {
|
|
||||||
width: 332rpx;
|
|
||||||
height: 92rpx;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 10px;
|
|
||||||
border: 2rpx solid #fff3;
|
|
||||||
box-sizing: border-box;
|
|
||||||
color: #fff;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.target-choosen {
|
|
||||||
color: #fed847;
|
|
||||||
border: 4rpx solid #fed847;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -5,7 +5,7 @@ import BowPower from "@/components/BowPower.vue";
|
|||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import { simulShootAPI } from "@/apis";
|
import { simulShootAPI } from "@/apis";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
@@ -19,15 +19,12 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
count: {
|
|
||||||
type: Number,
|
|
||||||
default: 15,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
const arrow = ref({});
|
const arrow = ref({});
|
||||||
const distance = ref(0);
|
const distance = ref(0);
|
||||||
|
const debugInfo = ref("");
|
||||||
const showsimul = ref(false);
|
const showsimul = ref(false);
|
||||||
const count = ref(props.count);
|
const count = ref(15);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
|
|
||||||
const updateTimer = (value) => {
|
const updateTimer = (value) => {
|
||||||
@@ -35,12 +32,10 @@ const updateTimer = (value) => {
|
|||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
audioManager.play("请射箭测试距离");
|
audioManager.play("请射箭测试距离");
|
||||||
if (props.isBattle) {
|
|
||||||
timer.value = setInterval(() => {
|
timer.value = setInterval(() => {
|
||||||
count.value -= 1;
|
if (count.value > 0) count.value -= 1;
|
||||||
if (count.value < 0) clearInterval(timer.value);
|
else clearInterval(timer.value);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
|
||||||
uni.$on("update-timer", updateTimer);
|
uni.$on("update-timer", updateTimer);
|
||||||
});
|
});
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -48,13 +43,18 @@ onBeforeUnmount(() => {
|
|||||||
uni.$off("update-timer", updateTimer);
|
uni.$off("update-timer", updateTimer);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (Array.isArray(msg)) return;
|
messages.forEach((msg) => {
|
||||||
if (msg.type === MESSAGETYPESV2.TestDistance) {
|
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||||
distance.value = Number((msg.shootData.distance / 100).toFixed(2));
|
arrow.value = msg.target;
|
||||||
if (distance.value >= 5) audioManager.play("距离合格");
|
distance.value = Number((msg.target.dst / 100).toFixed(2));
|
||||||
else audioManager.play("距离不足");
|
debugInfo.value = msg.target;
|
||||||
|
audioManager.play("距离合格");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.InvalidShot) {
|
||||||
|
distance.value = Number((msg.target.dst / 100).toFixed(2));
|
||||||
|
audioManager.play("距离不足");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const simulShoot = async () => {
|
const simulShoot = async () => {
|
||||||
@@ -112,12 +112,11 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
<view v-if="isBattle" class="ready-timer">
|
<view v-if="isBattle" class="ready-timer">
|
||||||
<image src="../static/test-tip.png" mode="widthFix" />
|
<image src="../static/test-tip.png" mode="widthFix" />
|
||||||
<view v-if="count >= 0">
|
<view>
|
||||||
<text>具体正式比赛还有</text>
|
<text>具体正式比赛还有</text>
|
||||||
<text>{{ count }}</text>
|
<text>{{ count }}</text>
|
||||||
<text>秒</text>
|
<text>秒</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-else> 进入中... </view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
162
src/components/TopRank.vue
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
data: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const titles = ["积分榜", "MVP榜", "十环榜"];
|
||||||
|
const selected = ref(0);
|
||||||
|
const timer = ref(0);
|
||||||
|
|
||||||
|
const onClick = (index) => {
|
||||||
|
selected.value = index;
|
||||||
|
clearInterval(timer.value);
|
||||||
|
timer.value = setInterval(() => {
|
||||||
|
selected.value = (selected.value + 1) % titles.length;
|
||||||
|
}, 3000);
|
||||||
|
};
|
||||||
|
onMounted(async () => {
|
||||||
|
timer.value = setInterval(() => {
|
||||||
|
selected.value = (selected.value + 1) % titles.length;
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
clearInterval(timer.value);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="top-rank">
|
||||||
|
<view>
|
||||||
|
<button
|
||||||
|
hover-class="none"
|
||||||
|
v-for="(name, index) in titles"
|
||||||
|
:key="index"
|
||||||
|
@click="onClick(index)"
|
||||||
|
:style="{ color: selected === index ? '#E7BA80' : '#999' }"
|
||||||
|
>
|
||||||
|
{{ name }}
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
<swiper
|
||||||
|
:current="selected"
|
||||||
|
@change="(e) => (selected = e.detail.current)"
|
||||||
|
:style="{ width: '100%' }"
|
||||||
|
>
|
||||||
|
<swiper-item v-for="(list, index1) in data" :key="index1">
|
||||||
|
<view v-for="(item, index2) in list" :key="index2" class="rank-item">
|
||||||
|
<view>
|
||||||
|
<text>{{ index2 + 1 }}</text>
|
||||||
|
<image
|
||||||
|
:src="item.avatar || '../static/user-icon-dark.png'"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text>{{ item.name }}</text>
|
||||||
|
<text>积分:{{ item.totalScore }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</swiper-item>
|
||||||
|
</swiper>
|
||||||
|
<view>
|
||||||
|
<view
|
||||||
|
v-for="(item, index) in data"
|
||||||
|
:key="index"
|
||||||
|
:style="{
|
||||||
|
width: selected === index ? '20rpx' : '6rpx',
|
||||||
|
backgroundColor: selected === index ? '#656565;' : '#e4e4e4',
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.top-rank {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
.top-rank > view:first-child {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.top-rank > view:first-child > button {
|
||||||
|
margin-right: 20rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
.rank-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 80rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
margin-left: 1rpx;
|
||||||
|
}
|
||||||
|
.rank-item > view:first-child {
|
||||||
|
position: relative;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
}
|
||||||
|
.rank-item > view:first-child > text {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 28rpx;
|
||||||
|
height: 28rpx;
|
||||||
|
line-height: 28rpx;
|
||||||
|
text-align: center;
|
||||||
|
background: #ffa711;
|
||||||
|
border-radius: 14rpx 0rpx 14rpx 0rpx;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 20rpx;
|
||||||
|
}
|
||||||
|
.rank-item > view:first-child > image {
|
||||||
|
width: 80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
}
|
||||||
|
.rank-item > view:last-child {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: flex-start;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.rank-item > view:last-child > text:first-child {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
line-height: 34rpx;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
max-width: 180rpx;
|
||||||
|
}
|
||||||
|
.rank-item > view:last-child > text:last-child {
|
||||||
|
background: rgb(255 250 234 / 0.1);
|
||||||
|
border-radius: 16rpx;
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #e7ba80;
|
||||||
|
line-height: 28rpx;
|
||||||
|
padding: 5rpx 10rpx;
|
||||||
|
}
|
||||||
|
.top-rank > view:last-child {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
.top-rank > view:last-child > view {
|
||||||
|
height: 6rpx;
|
||||||
|
border-radius: 3rpx;
|
||||||
|
background: #e4e4e4;
|
||||||
|
margin: 0 5rpx;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -30,29 +30,13 @@ export const MESSAGETYPES = {
|
|||||||
SomeoneIsReady: 4168086628,
|
SomeoneIsReady: 4168086628,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MESSAGETYPESV2 = {
|
|
||||||
AboutToStart: 1,
|
|
||||||
BattleStart: 2,
|
|
||||||
ToSomeoneShoot: 3,
|
|
||||||
ShootResult: 4,
|
|
||||||
NewRound: 5,
|
|
||||||
BattleEnd: 6,
|
|
||||||
HalfRest: 7,
|
|
||||||
TestDistance: 8,
|
|
||||||
MatchSuccess: 9,
|
|
||||||
InvalidShot: 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
||||||
|
|
||||||
export const getMessageTypeName = (id) => {
|
export const getMessageTypeName = (id) => {
|
||||||
for (let key in MESSAGETYPES) {
|
for (let key in MESSAGETYPES) {
|
||||||
if (MESSAGETYPES[key] === id) return key;
|
if (MESSAGETYPES[key] === id) return key;
|
||||||
}
|
}
|
||||||
for (let key in MESSAGETYPESV2) {
|
return null;
|
||||||
if (MESSAGETYPESV2[key] === id) return key;
|
|
||||||
}
|
|
||||||
return id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const roundsName = {
|
export const roundsName = {
|
||||||
@@ -118,7 +102,7 @@ export const getBattleResultTips = (
|
|||||||
) => {
|
) => {
|
||||||
const getRandomIndex = (len) => Math.floor(Math.random() * len);
|
const getRandomIndex = (len) => Math.floor(Math.random() * len);
|
||||||
if (gameMode === 1) {
|
if (gameMode === 1) {
|
||||||
if (mode <= 3) {
|
if (mode === 1) {
|
||||||
if (win) {
|
if (win) {
|
||||||
const tests = [
|
const tests = [
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fglywucyoh9zn.png",
|
"https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fglywucyoh9zn.png",
|
||||||
@@ -140,7 +124,7 @@ export const getBattleResultTips = (
|
|||||||
];
|
];
|
||||||
return tests[getRandomIndex(3)];
|
return tests[getRandomIndex(3)];
|
||||||
}
|
}
|
||||||
} else {
|
} else if (mode === 2) {
|
||||||
if (rank <= 3) {
|
if (rank <= 3) {
|
||||||
const tests = [
|
const tests = [
|
||||||
"好成绩!全国排位赛等着你!",
|
"好成绩!全国排位赛等着你!",
|
||||||
@@ -152,7 +136,7 @@ export const getBattleResultTips = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (gameMode === 2) {
|
} else if (gameMode === 2) {
|
||||||
if (mode <= 3) {
|
if (mode === 1) {
|
||||||
if (win) {
|
if (win) {
|
||||||
const tests = [
|
const tests = [
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtb29jbdus4g.png",
|
"https://static.shelingxingqiu.com/attachment/2025-08-01/dbqq1fgtb29jbdus4g.png",
|
||||||
@@ -174,7 +158,7 @@ export const getBattleResultTips = (
|
|||||||
];
|
];
|
||||||
return tests[getRandomIndex(3)];
|
return tests[getRandomIndex(3)];
|
||||||
}
|
}
|
||||||
} else {
|
} else if (mode === 2) {
|
||||||
if (score > 0) {
|
if (score > 0) {
|
||||||
const tests = [
|
const tests = [
|
||||||
"王者一定属于你!",
|
"王者一定属于你!",
|
||||||
|
|||||||
@@ -30,15 +30,12 @@
|
|||||||
"navigationBarTitleText": ""
|
"navigationBarTitleText": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "pages/team-battle"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/melee-battle"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pages/battle-result"
|
"path": "pages/battle-result"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/team-battle"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/point-book-edit"
|
"path": "pages/point-book-edit"
|
||||||
},
|
},
|
||||||
@@ -105,6 +102,9 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/rank-list"
|
"path": "pages/rank-list"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/melee-match"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/match-detail"
|
"path": "pages/match-detail"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import UserUpgrade from "@/components/UserUpgrade.vue";
|
import UserUpgrade from "@/components/UserUpgrade.vue";
|
||||||
import { getBattleAPI } from "@/apis";
|
import { getGameAPI } from "@/apis";
|
||||||
import { topThreeColors, getBattleResultTips } from "@/constants";
|
import { topThreeColors, getBattleResultTips } from "@/constants";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
@@ -16,10 +16,14 @@ const ifWin = ref(false);
|
|||||||
const data = ref({});
|
const data = ref({});
|
||||||
const totalPoints = ref(0);
|
const totalPoints = ref(0);
|
||||||
const rank = ref(0);
|
const rank = ref(0);
|
||||||
const players = ref([]);
|
|
||||||
|
|
||||||
function exit() {
|
function exit() {
|
||||||
if (data.value.roomId) {
|
const battleInfo = uni.getStorageSync("last-battle");
|
||||||
|
if (battleInfo && battleInfo.roomId) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/battle-room?roomNumber=${battleInfo.roomId}`,
|
||||||
|
});
|
||||||
|
} else if (data.value.roomId) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/battle-room?roomNumber=${data.value.roomId}`,
|
url: `/pages/battle-room?roomNumber=${data.value.roomId}`,
|
||||||
});
|
});
|
||||||
@@ -29,95 +33,128 @@ function exit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (!options.battleId) return;
|
|
||||||
const myId = user.value.id;
|
const myId = user.value.id;
|
||||||
const result = await getBattleAPI(options.battleId || "60049406950510592");
|
if (options.battleId) {
|
||||||
data.value = result;
|
const result = await getGameAPI(
|
||||||
if (result.winTeam) {
|
options.battleId || "BATTLE-1758270367040321900-868"
|
||||||
ifWin.value = result.teams[result.winTeam].players.some(
|
|
||||||
(p) => p.id === myId
|
|
||||||
);
|
);
|
||||||
}
|
data.value = {
|
||||||
if (result.mode <= 3) {
|
...result,
|
||||||
audioManager.play(ifWin.value ? "胜利" : "失败");
|
battleMode: result.gameMode,
|
||||||
} else {
|
|
||||||
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);
|
|
||||||
if (p.id === user.value.id) {
|
|
||||||
totalPoints.value = p.score;
|
|
||||||
rank.value = index + 1;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
rank: index + 1,
|
|
||||||
name: p.name,
|
|
||||||
avatar: p.avatar || "",
|
|
||||||
};
|
};
|
||||||
});
|
if (result.mode === 1) {
|
||||||
if (rank.value <= players.value * 0.3) {
|
data.value.redPlayers = Object.values(result.redPlayers);
|
||||||
audioManager.play("胜利");
|
data.value.bluePlayers = Object.values(result.bluePlayers);
|
||||||
|
if (result.redPlayers[myId]) {
|
||||||
|
totalPoints.value = result.redPlayers[myId].totalScore;
|
||||||
|
data.value.myTeam = result.redPlayers[myId].team;
|
||||||
|
ifWin.value = result.winner === 0;
|
||||||
|
}
|
||||||
|
if (result.bluePlayers[myId]) {
|
||||||
|
totalPoints.value = result.bluePlayers[myId].totalScore;
|
||||||
|
data.value.myTeam = result.bluePlayers[myId].team;
|
||||||
|
ifWin.value = result.winner === 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result.mode === 2) {
|
||||||
|
data.value.playerStats = result.players.map((p) => ({
|
||||||
|
...p,
|
||||||
|
id: p.playerId,
|
||||||
|
}));
|
||||||
|
const mine = result.players.find((p) => p.playerId === myId);
|
||||||
|
if (mine) totalPoints.value = mine.totalScore;
|
||||||
|
rank.value = result.players.findIndex((p) => p.playerId === myId) + 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
const battleInfo = uni.getStorageSync("last-battle");
|
||||||
|
if (!battleInfo) return;
|
||||||
|
data.value = {
|
||||||
|
mvps: [],
|
||||||
|
...battleInfo,
|
||||||
|
};
|
||||||
|
if (battleInfo.mode === 1) {
|
||||||
|
battleInfo.playerStats.forEach((p) => {
|
||||||
|
if (p.team === 1) data.value.bluePlayers = [p];
|
||||||
|
if (p.team === 0) data.value.redPlayers = [p];
|
||||||
|
if (p.mvp) data.value.mvps.push(p);
|
||||||
|
});
|
||||||
|
data.value.mvps.sort((a, b) => b.totalRings - a.totalRings);
|
||||||
|
}
|
||||||
|
rank.value = 0;
|
||||||
|
const mine = battleInfo.playerStats.find((p, index) => {
|
||||||
|
rank.value = index + 1;
|
||||||
|
return p.id === myId;
|
||||||
|
});
|
||||||
|
if (mine) {
|
||||||
|
data.value.myTeam = mine.team;
|
||||||
|
totalPoints.value = mine.totalScore;
|
||||||
|
if (battleInfo.mode === 1) {
|
||||||
|
ifWin.value = mine.team === battleInfo.winner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (data.value.mode === 1) {
|
||||||
|
audioManager.play(ifWin.value ? "胜利" : "失败");
|
||||||
|
} else if (data.value.mode === 2) {
|
||||||
|
if (data.value.battleMode === 1) {
|
||||||
|
if (rank.value <= data.value.playerStats.length * 0.3) {
|
||||||
audioManager.play("胜利");
|
audioManager.play("胜利");
|
||||||
}
|
}
|
||||||
|
} else if (data.value.battleMode === 2) {
|
||||||
|
if (totalPoints.value > 0) {
|
||||||
|
audioManager.play("胜利");
|
||||||
|
} else if (totalPoints.value < 0) {
|
||||||
|
audioManager.play("失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
const myTeam = computed(() => {
|
|
||||||
const teams = data.value.teams;
|
|
||||||
if (teams && teams.length) {
|
|
||||||
if (teams[1].players.some((p) => p.id === user.value.id)) return 1;
|
|
||||||
}
|
}
|
||||||
return 2;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkBowData = () => {
|
const checkBowData = () => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/match-detail?battleId=${data.value.matchId}`,
|
url: `/pages/match-detail?id=${data.value.id}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<block v-if="data.mode <= 3">
|
<block v-if="data.mode === 1">
|
||||||
<view class="header-team" :style="{ marginTop: '25%' }">
|
<view class="header-team" :style="{ marginTop: '25%' }">
|
||||||
<image src="../static/battle-result.png" mode="widthFix" />
|
<image src="../static/battle-result.png" mode="widthFix" />
|
||||||
<view class="header-solo" v-if="data.mode === 1">
|
<view class="header-solo" v-if="data.teamSize === 2">
|
||||||
<text
|
<text
|
||||||
:style="{
|
:style="{
|
||||||
background:
|
background:
|
||||||
data.winTeam === 1
|
data.winner === 1
|
||||||
? 'linear-gradient(270deg, #3597ff 0%, rgba(0,0,0,0) 100%);'
|
? 'linear-gradient(270deg, #3597ff 0%, rgba(0,0,0,0) 100%);'
|
||||||
: 'linear-gradient(270deg, #fd4444 0%, rgba(0, 0, 0, 0) 100%)',
|
: 'linear-gradient(270deg, #fd4444 0%, rgba(0, 0, 0, 0) 100%)',
|
||||||
}"
|
}"
|
||||||
>{{ data.winTeam === 1 ? "蓝队" : "红队" }}获胜</text
|
>{{ data.winner === 1 ? "蓝队" : "红队" }}获胜</text
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
:size="32"
|
:size="32"
|
||||||
:src="
|
:src="
|
||||||
data.winTeam === 1
|
data.winner === 1
|
||||||
? data.teams[1].players[0].avatar
|
? data.bluePlayers[0].avatar
|
||||||
: data.teams[2].players[0].avatar
|
: data.redPlayers[0].avatar
|
||||||
"
|
"
|
||||||
:borderColor="data.winTeam === 1 ? '#5FADFF' : '#FF5656'"
|
:borderColor="data.winner === 1 ? '#5FADFF' : '#FF5656'"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="header-mvp" v-if="data.mode === 2 || data.mode === 3">
|
<view class="header-mvp" v-if="data.teamSize !== 2">
|
||||||
<image
|
<image
|
||||||
:src="`../static/${data.winTeam === 1 ? 'blue' : 'red'}-team-win.png`"
|
:src="`../static/${data.winner === 1 ? 'blue' : 'red'}-team-win.png`"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
:style="{
|
:style="{
|
||||||
transform: `translateY(50px) rotate(-${
|
transform: `translateY(50px) rotate(-${5 + data.mvps.length}deg)`,
|
||||||
5 + (data.mvp || []).length
|
|
||||||
}deg)`,
|
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<view v-if="data.mvp && data.mvp[0].totalRings">
|
<view v-if="data.mvps && data.mvps[0].totalRings">
|
||||||
<image src="../static/title-mvp.png" mode="widthFix" />
|
<image src="../static/title-mvp.png" mode="widthFix" />
|
||||||
<text
|
<text
|
||||||
>斩获<text
|
>斩获<text
|
||||||
@@ -127,22 +164,22 @@ const checkBowData = () => {
|
|||||||
margin: '0 3px',
|
margin: '0 3px',
|
||||||
fontWeight: '600',
|
fontWeight: '600',
|
||||||
}"
|
}"
|
||||||
>{{ data.mvp[0].totalRings }}</text
|
>{{ data.mvps[0].totalRings }}</text
|
||||||
>环</text
|
>环</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="data.mvp && data.mvp.length">
|
<view v-if="data.mvps && data.mvps.length">
|
||||||
<view v-for="(player, index) in data.mvp" :key="index">
|
<view v-for="(player, index) in data.mvps" :key="index">
|
||||||
<view class="team-avatar">
|
<view class="team-avatar">
|
||||||
<Avatar
|
<Avatar
|
||||||
:src="player.avatar"
|
:src="player.avatar"
|
||||||
:size="40"
|
:size="40"
|
||||||
:borderColor="myTeam === 1 ? '#5fadff' : '#ff6060'"
|
:borderColor="data.myTeam === 1 ? '#5fadff' : '#ff6060'"
|
||||||
/>
|
/>
|
||||||
<text
|
<text
|
||||||
v-if="player.id === user.id"
|
v-if="player.id === user.id"
|
||||||
:style="{
|
:style="{
|
||||||
backgroundColor: myTeam === 1 ? '#5fadff' : '#ff6060',
|
backgroundColor: data.myTeam === 1 ? '#5fadff' : '#ff6060',
|
||||||
}"
|
}"
|
||||||
>自己</text
|
>自己</text
|
||||||
>
|
>
|
||||||
@@ -161,7 +198,7 @@ const checkBowData = () => {
|
|||||||
/>
|
/>
|
||||||
<image
|
<image
|
||||||
:src="
|
:src="
|
||||||
getBattleResultTips(data.way, data.mode, {
|
getBattleResultTips(data.battleMode, data.mode, {
|
||||||
win: ifWin,
|
win: ifWin,
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
@@ -170,7 +207,7 @@ const checkBowData = () => {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<block v-else>
|
<block v-if="data.mode === 2">
|
||||||
<view class="header-melee">
|
<view class="header-melee">
|
||||||
<view />
|
<view />
|
||||||
<image src="../static/battle-result.png" mode="widthFix" />
|
<image src="../static/battle-result.png" mode="widthFix" />
|
||||||
@@ -179,11 +216,11 @@ const checkBowData = () => {
|
|||||||
<view
|
<view
|
||||||
class="players"
|
class="players"
|
||||||
:style="{
|
:style="{
|
||||||
height: `${Math.max(players.length > 5 ? '330' : '300')}px`,
|
height: `${Math.max(data.playerStats.length > 5 ? '330' : '300')}px`,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
v-for="(player, index) in players"
|
v-for="(player, index) in data.playerStats"
|
||||||
:key="index"
|
:key="index"
|
||||||
:style="{
|
:style="{
|
||||||
border: player.id === user.id ? '1px solid #B04630' : 'none',
|
border: player.id === user.id ? '1px solid #B04630' : 'none',
|
||||||
@@ -238,7 +275,7 @@ const checkBowData = () => {
|
|||||||
<text>{{ getLvlName(player.rank_lvl) }}</text>
|
<text>{{ getLvlName(player.rank_lvl) }}</text>
|
||||||
</view>
|
</view>
|
||||||
<text
|
<text
|
||||||
><text :style="{ color: '#fff' }">{{ player.totalRing }}</text>
|
><text :style="{ color: '#fff' }">{{ player.totalRings }}</text>
|
||||||
环</text
|
环</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
@@ -246,36 +283,36 @@ const checkBowData = () => {
|
|||||||
</block>
|
</block>
|
||||||
<view
|
<view
|
||||||
class="battle-e"
|
class="battle-e"
|
||||||
:style="{ marginTop: data.mode > 3 ? '20px' : '20vw' }"
|
:style="{ marginTop: data.mode === 2 ? '20px' : '20vw' }"
|
||||||
>
|
>
|
||||||
<image src="../static/row-yellow-bg.png" mode="widthFix" />
|
<image src="../static/row-yellow-bg.png" mode="widthFix" />
|
||||||
<view class="team-avatar">
|
<view class="team-avatar">
|
||||||
<Avatar
|
<Avatar
|
||||||
:src="user.avatar"
|
:src="user.avatar"
|
||||||
:size="40"
|
:size="40"
|
||||||
:borderColor="myTeam === 1 ? '#5fadff' : '#ff6060'"
|
:borderColor="data.myTeam === 1 ? '#5fadff' : '#ff6060'"
|
||||||
/>
|
/>
|
||||||
<text
|
<text
|
||||||
:style="{ backgroundColor: '#5fadff' }"
|
:style="{ backgroundColor: '#5fadff' }"
|
||||||
v-if="data.mode <= 3 && myTeam === 1"
|
v-if="data.mode === 1 && data.myTeam === 1"
|
||||||
>蓝队</text
|
>蓝队</text
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
:style="{ backgroundColor: '#ff6060' }"
|
:style="{ backgroundColor: '#ff6060' }"
|
||||||
v-if="data.mode <= 3 && myTeam === 2"
|
v-if="data.mode === 1 && data.myTeam === 0"
|
||||||
>红队</text
|
>红队</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
<text v-if="data.way === 1">
|
<text v-if="data.battleMode === 1">
|
||||||
你的经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
|
你的经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
|
||||||
</text>
|
</text>
|
||||||
<text v-if="data.way === 2">
|
<text v-if="data.battleMode === 2">
|
||||||
你的积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
|
你的积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text v-if="data.mode > 3" class="description">
|
<text v-if="data.mode === 2" class="description">
|
||||||
{{
|
{{
|
||||||
getBattleResultTips(data.way, data.mode, {
|
getBattleResultTips(data.battleMode, data.mode, {
|
||||||
win: ifWin,
|
win: ifWin,
|
||||||
score: totalPoints,
|
score: totalPoints,
|
||||||
rank,
|
rank,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, computed, onBeforeUnmount } from "vue";
|
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { onShow, onLoad, onShareAppMessage } from "@dcloudio/uni-app";
|
import { onLoad, onShareAppMessage } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import PlayerSeats from "@/components/PlayerSeats.vue";
|
import PlayerSeats from "@/components/PlayerSeats.vue";
|
||||||
import Guide from "@/components/Guide.vue";
|
import Guide from "@/components/Guide.vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
|
import SModal from "@/components/SModal.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import {
|
import {
|
||||||
getRoomAPI,
|
getRoomAPI,
|
||||||
@@ -13,9 +14,9 @@ import {
|
|||||||
startRoomAPI,
|
startRoomAPI,
|
||||||
chooseTeamAPI,
|
chooseTeamAPI,
|
||||||
getReadyAPI,
|
getReadyAPI,
|
||||||
kickPlayerAPI,
|
|
||||||
} from "@/apis";
|
} from "@/apis";
|
||||||
import { MESSAGETYPES, MESSAGETYPESV2 } from "@/constants";
|
|
||||||
|
import { MESSAGETYPES } from "@/constants";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
@@ -29,18 +30,18 @@ const players = ref([]);
|
|||||||
const blueTeam = ref([]);
|
const blueTeam = ref([]);
|
||||||
const redTeam = ref([]);
|
const redTeam = ref([]);
|
||||||
|
|
||||||
|
const showModal = ref(false);
|
||||||
|
const battleType = ref(0);
|
||||||
|
const refreshRoomTimer = ref(null);
|
||||||
const ready = ref(false);
|
const ready = ref(false);
|
||||||
const allReady = ref(false);
|
const allReady = ref(false);
|
||||||
const timer = ref(null);
|
const timer = ref(null);
|
||||||
const goBattle = ref(false);
|
|
||||||
|
|
||||||
async function refreshRoomData() {
|
async function refreshRoomData() {
|
||||||
if (!roomNumber.value) return;
|
|
||||||
const result = await getRoomAPI(roomNumber.value);
|
const result = await getRoomAPI(roomNumber.value);
|
||||||
if (result.started) return;
|
if (result.started) return;
|
||||||
room.value = result;
|
room.value = result;
|
||||||
owner.value = {};
|
battleType.value = result.battleType;
|
||||||
opponent.value = {};
|
|
||||||
const members = result.members || [];
|
const members = result.members || [];
|
||||||
if (members.length === result.count) {
|
if (members.length === result.count) {
|
||||||
allReady.value = members.every((m) => !!m.userInfo.state);
|
allReady.value = members.every((m) => !!m.userInfo.state);
|
||||||
@@ -59,7 +60,6 @@ async function refreshRoomData() {
|
|||||||
name: m.userInfo.name,
|
name: m.userInfo.name,
|
||||||
avatar: m.userInfo.avatar,
|
avatar: m.userInfo.avatar,
|
||||||
rankLvl: m.userInfo.rankLvl,
|
rankLvl: m.userInfo.rankLvl,
|
||||||
ready: !!m.userInfo.state,
|
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,6 @@ async function refreshRoomData() {
|
|||||||
name: m.userInfo.name,
|
name: m.userInfo.name,
|
||||||
avatar: m.userInfo.avatar,
|
avatar: m.userInfo.avatar,
|
||||||
rankLvl: m.userInfo.rankLvl,
|
rankLvl: m.userInfo.rankLvl,
|
||||||
ready: !!m.userInfo.state,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -95,7 +94,7 @@ async function refreshRoomData() {
|
|||||||
refreshMembers(result.members);
|
refreshMembers(result.members);
|
||||||
}
|
}
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
// timer.value = setTimeout(refreshRoomData, 2000);
|
timer.value = setTimeout(refreshRoomData, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const startGame = async () => {
|
const startGame = async () => {
|
||||||
@@ -113,8 +112,8 @@ const refreshMembers = (members = []) => {
|
|||||||
players.value[index] = { ...m.userInfo, groupType: m.groupType };
|
players.value[index] = { ...m.userInfo, groupType: m.groupType };
|
||||||
if (m.groupType === 1) {
|
if (m.groupType === 1) {
|
||||||
blueTeam.value.push({ ...m.userInfo, groupType: 1 });
|
blueTeam.value.push({ ...m.userInfo, groupType: 1 });
|
||||||
} else if (m.groupType === 2) {
|
} else if (m.groupType === 0) {
|
||||||
redTeam.value.push({ ...m.userInfo, groupType: 2 });
|
redTeam.value.push({ ...m.userInfo, groupType: 0 });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (let i = 0; i < room.value.count / 2; i++) {
|
for (let i = 0; i < room.value.count / 2; i++) {
|
||||||
@@ -123,28 +122,66 @@ const refreshMembers = (members = []) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onReceiveMessage(message) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (Array.isArray(message)) {
|
messages.forEach((msg) => {
|
||||||
message.forEach((msg) => {
|
if (msg.roomNumber === roomNumber.value) {
|
||||||
if (msg.roomNumber !== roomNumber.value) return;
|
|
||||||
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
|
if (msg.constructor === MESSAGETYPES.UserEnterRoom) {
|
||||||
refreshRoomData();
|
if (battleType.value === 1) {
|
||||||
} else if (msg.constructor === MESSAGETYPES.UserExitRoom) {
|
if (msg.userId === room.value.creator) {
|
||||||
if (msg.userId === user.value.id) {
|
owner.value = {
|
||||||
uni.showToast({
|
id: msg.userId,
|
||||||
title: "你被踢出房间",
|
name: msg.name,
|
||||||
icon: "none",
|
avatar: msg.avatar,
|
||||||
});
|
rankLvl: msg.rankLvl,
|
||||||
setTimeout(() => {
|
};
|
||||||
uni.navigateBack();
|
|
||||||
}, 1000);
|
|
||||||
} else {
|
} else {
|
||||||
refreshRoomData();
|
opponent.value = {
|
||||||
|
id: msg.userId,
|
||||||
|
name: msg.name,
|
||||||
|
avatar: msg.avatar,
|
||||||
|
rankLvl: msg.rankLvl,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (battleType.value === 2) {
|
||||||
|
if (room.value.creator === msg.userId) {
|
||||||
|
players.value[0] = {
|
||||||
|
id: msg.userId,
|
||||||
|
name: msg.name,
|
||||||
|
avatar: msg.avatar,
|
||||||
|
rankLvl: msg.rankLvl,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
players.value.push({
|
||||||
|
id: msg.userId,
|
||||||
|
name: msg.name,
|
||||||
|
avatar: msg.avatar,
|
||||||
|
rankLvl: msg.rankLvl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.UserExitRoom) {
|
||||||
|
if (battleType.value === 1) {
|
||||||
|
if (msg.userId === room.value.creator) {
|
||||||
|
owner.value = {
|
||||||
|
id: "",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
opponent.value = {
|
||||||
|
id: "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (battleType.value === 2) {
|
||||||
|
players.value = players.value.filter((p) => p.id !== msg.userId);
|
||||||
|
}
|
||||||
|
if (msg.room && msg.room.members) {
|
||||||
|
refreshMembers(msg.room.members);
|
||||||
}
|
}
|
||||||
} else if (msg.constructor === MESSAGETYPES.TeamUpdate) {
|
} else if (msg.constructor === MESSAGETYPES.TeamUpdate) {
|
||||||
refreshRoomData();
|
if (msg.room && msg.room.members) {
|
||||||
} else if (msg.constructor === MESSAGETYPES.SomeoneIsReady) {
|
refreshMembers(msg.room.members);
|
||||||
refreshRoomData();
|
}
|
||||||
} else if (msg.constructor === MESSAGETYPES.RoomDestroy) {
|
} else if (msg.constructor === MESSAGETYPES.RoomDestroy) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "房间已解散",
|
title: "房间已解散",
|
||||||
@@ -153,25 +190,41 @@ async function onReceiveMessage(message) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.SomeoneIsReady) {
|
||||||
|
refreshRoomData();
|
||||||
}
|
}
|
||||||
});
|
} else if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||||
} else if (message.type === MESSAGETYPESV2.AboutToStart) {
|
if (msg.groupUserStatus) {
|
||||||
goBattle.value = true;
|
uni.setStorageSync("red-team", msg.groupUserStatus.redTeam);
|
||||||
if (message.mode <= 3) {
|
uni.setStorageSync("blue-team", msg.groupUserStatus.blueTeam);
|
||||||
uni.setStorageSync("blue-team", message.teams[1].players || []);
|
uni.setStorageSync("melee-players", [
|
||||||
uni.setStorageSync("red-team", message.teams[2].players || []);
|
...msg.groupUserStatus.redTeam,
|
||||||
|
...msg.groupUserStatus.blueTeam,
|
||||||
|
]);
|
||||||
|
uni.removeStorageSync("current-battle");
|
||||||
|
// 避免离开页面,触发退出房间
|
||||||
|
roomNumber.value = "";
|
||||||
|
if (msg.groupUserStatus.config.mode == 1) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pages/team-battle?battleId=" + message.matchId,
|
url: `/pages/team-battle?battleId=${msg.id}&gameMode=1`,
|
||||||
});
|
});
|
||||||
} else {
|
} else if (msg.groupUserStatus.config.mode == 2) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pages/melee-battle?battleId=" + message.matchId,
|
url: `/pages/melee-match?battleId=${msg.id}&gameMode=1`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const chooseTeam = async (team) => {
|
const chooseTeam = async (team) => {
|
||||||
|
if (team !== 2) {
|
||||||
|
const notInTeam = room.value.members.some(
|
||||||
|
(m) => m.userInfo.id === user.value.id && m.groupType === 2
|
||||||
|
);
|
||||||
|
if (!notInTeam) return;
|
||||||
|
}
|
||||||
const result = await chooseTeamAPI(roomNumber.value, team);
|
const result = await chooseTeamAPI(roomNumber.value, team);
|
||||||
refreshMembers(result.members);
|
refreshMembers(result.members);
|
||||||
};
|
};
|
||||||
@@ -184,22 +237,15 @@ const exitRoom = async () => {
|
|||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
const removePlayer = async (player) => {
|
const setClipboardData = () => {
|
||||||
await kickPlayerAPI(roomNumber.value, player.id);
|
uni.setClipboardData({
|
||||||
|
data: roomNumber.value,
|
||||||
|
success() {
|
||||||
|
uni.showToast({ title: "复制成功" });
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const canClick = computed(() => {
|
|
||||||
if (ready.value) return false;
|
|
||||||
const { members = [] } = room.value;
|
|
||||||
if (members.length < 2) return false;
|
|
||||||
if (
|
|
||||||
owner.value.id === user.value.id &&
|
|
||||||
members.some((m) => !m.userInfo.state && m.userInfo.id !== owner.value.id)
|
|
||||||
)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
onShareAppMessage(() => {
|
onShareAppMessage(() => {
|
||||||
return {
|
return {
|
||||||
title: "邀请您进入房间对战",
|
title: "邀请您进入房间对战",
|
||||||
@@ -208,13 +254,11 @@ onShareAppMessage(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
onShow(() => {
|
|
||||||
goBattle.value = false;
|
|
||||||
refreshRoomData();
|
|
||||||
});
|
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.roomNumber) roomNumber.value = options.roomNumber;
|
if (options.roomNumber) {
|
||||||
|
roomNumber.value = options.roomNumber;
|
||||||
|
refreshRoomData();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -225,11 +269,12 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
if (refreshRoomTimer.value) clearInterval(refreshRoomTimer.value);
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: false,
|
keepScreenOn: false,
|
||||||
});
|
});
|
||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
if (!goBattle.value) exitRoomAPI(roomNumber.value);
|
if (roomNumber.value) exitRoomAPI(roomNumber.value);
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
timer.value = null;
|
timer.value = null;
|
||||||
});
|
});
|
||||||
@@ -242,15 +287,15 @@ onBeforeUnmount(() => {
|
|||||||
<view class="battle-guide">
|
<view class="battle-guide">
|
||||||
<view class="guide-tips">
|
<view class="guide-tips">
|
||||||
<text>弓箭手们,人都到齐了吗?</text>
|
<text>弓箭手们,人都到齐了吗?</text>
|
||||||
<text v-if="room.battleType === 1">{{
|
<text v-if="battleType === 1">{{
|
||||||
`${room.count / 2}v${room.count / 2}比赛即将开始!`
|
`${room.count / 2}v${room.count / 2}比赛即将开始!`
|
||||||
}}</text>
|
}}</text>
|
||||||
<text v-if="room.battleType === 2">大乱斗即将开始! </text>
|
<text v-if="battleType === 2">大乱斗即将开始! </text>
|
||||||
</view>
|
</view>
|
||||||
<button hover-class="none" open-type="share">邀请</button>
|
<button hover-class="none" open-type="share">邀请</button>
|
||||||
</view>
|
</view>
|
||||||
</Guide>
|
</Guide>
|
||||||
<view v-if="room.battleType === 1 && room.count === 2" class="team-mode">
|
<view v-if="battleType === 1 && room.count === 2" class="team-mode">
|
||||||
<image
|
<image
|
||||||
src="https://static.shelingxingqiu.com/attachment/2025-08-05/dbua9nuf5fyeph7cxi.png"
|
src="https://static.shelingxingqiu.com/attachment/2025-08-05/dbua9nuf5fyeph7cxi.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@@ -261,9 +306,9 @@ onBeforeUnmount(() => {
|
|||||||
class="player"
|
class="player"
|
||||||
:style="{ transform: 'translateY(-60px)' }"
|
:style="{ transform: 'translateY(-60px)' }"
|
||||||
>
|
>
|
||||||
<Avatar :src="owner.avatar" :size="60" />
|
<Avatar :rankLvl="owner.rankLvl" :src="owner.avatar" :size="60" />
|
||||||
<text>管理员</text>
|
|
||||||
<text>{{ owner.name }}</text>
|
<text>{{ owner.name }}</text>
|
||||||
|
<text>创建者</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
v-else
|
v-else
|
||||||
@@ -278,26 +323,24 @@ onBeforeUnmount(() => {
|
|||||||
class="player"
|
class="player"
|
||||||
:style="{ transform: 'translateY(60px)' }"
|
:style="{ transform: 'translateY(60px)' }"
|
||||||
>
|
>
|
||||||
<Avatar :src="opponent.avatar" :size="60" />
|
<Avatar
|
||||||
<text class="ready" :style="{ opacity: opponent.ready ? 1 : 0 }">
|
:rankLvl="opponent.rankLvl"
|
||||||
已准备
|
:src="opponent.avatar"
|
||||||
</text>
|
:size="60"
|
||||||
<text>{{ opponent.name }}</text>
|
/>
|
||||||
<button
|
<text v-if="opponent.name">{{ opponent.name }}</text>
|
||||||
v-if="owner.id === user.id"
|
|
||||||
hover-class="none"
|
|
||||||
class="remove-player"
|
|
||||||
@click="() => removePlayer(opponent)"
|
|
||||||
>
|
|
||||||
<image src="../static/close-white.png" mode="widthFix" />
|
|
||||||
</button>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="no-player" v-else>
|
<view class="no-player" v-else>
|
||||||
<image src="../static/question-mark.png" mode="widthFix" />
|
<image src="../static/question-mark.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<block v-if="room.battleType === 1 && room.count >= 4">
|
<PlayerSeats
|
||||||
|
v-if="battleType === 2"
|
||||||
|
:total="room.count || 10"
|
||||||
|
:players="players"
|
||||||
|
/>
|
||||||
|
<block v-if="battleType === 1 && room.count >= 4">
|
||||||
<view class="all-players">
|
<view class="all-players">
|
||||||
<image
|
<image
|
||||||
src="https://static.shelingxingqiu.com/attachment/2025-08-13/dc0x1p59iab6cvbhqc.png"
|
src="https://static.shelingxingqiu.com/attachment/2025-08-13/dc0x1p59iab6cvbhqc.png"
|
||||||
@@ -316,61 +359,46 @@ onBeforeUnmount(() => {
|
|||||||
<view>
|
<view>
|
||||||
<view v-for="(item, index) in players" :key="index">
|
<view v-for="(item, index) in players" :key="index">
|
||||||
<Avatar v-if="item.id" :src="item.avatar" :size="36" />
|
<Avatar v-if="item.id" :src="item.avatar" :size="36" />
|
||||||
<text v-if="owner.id === item.id">管理员</text>
|
<text v-if="owner.id === item.id">创建者</text>
|
||||||
<button
|
|
||||||
v-if="owner.id !== item.id && item.id"
|
|
||||||
hover-class="none"
|
|
||||||
class="remove-player"
|
|
||||||
@click="() => removePlayer(item)"
|
|
||||||
:style="{ top: '-10rpx', right: '-10rpx' }"
|
|
||||||
>
|
|
||||||
<image src="../static/close-white.png" mode="widthFix" />
|
|
||||||
</button>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="choose-side">
|
<view class="choose-side">
|
||||||
<view>
|
<view>
|
||||||
<view
|
<view
|
||||||
v-for="(item, index) in redTeam"
|
v-for="(item, index) in blueTeam"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="choose-side-left-item"
|
class="choose-side-left-item"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
hover-class="none"
|
hover-class="none"
|
||||||
v-if="item.id === user.id"
|
v-if="item.id === user.id"
|
||||||
@click="chooseTeam(0)"
|
@click="chooseTeam(2)"
|
||||||
>
|
>
|
||||||
<image src="../static/close-grey.png" mode="widthFix" />
|
<image src="../static/close-grey.png" mode="widthFix" />
|
||||||
</button>
|
</button>
|
||||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||||
<view v-if="item.id">
|
<Avatar v-if="item.id" :src="item.avatar" :size="36" />
|
||||||
<Avatar :src="item.avatar" :size="36" />
|
<button v-else hover-class="none" @click="chooseTeam(1)">
|
||||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
|
||||||
</view>
|
|
||||||
<button v-else hover-class="none" @click="chooseTeam(2)">
|
|
||||||
<image src="../static/add-grey.png" mode="widthFix" />
|
<image src="../static/add-grey.png" mode="widthFix" />
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<view
|
<view
|
||||||
v-for="(item, index) in blueTeam"
|
v-for="(item, index) in redTeam"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="choose-side-right-item"
|
class="choose-side-right-item"
|
||||||
>
|
>
|
||||||
<view v-if="item.id">
|
<Avatar v-if="item.id" :src="item.avatar" :size="36" />
|
||||||
<Avatar :src="item.avatar" :size="36" />
|
<button v-else hover-class="none" @click="chooseTeam(0)">
|
||||||
<text :style="{ opacity: !!item.state ? 1 : 0 }">已准备</text>
|
|
||||||
</view>
|
|
||||||
<button v-else hover-class="none" @click="chooseTeam(1)">
|
|
||||||
<image src="../static/add-grey.png" mode="widthFix" />
|
<image src="../static/add-grey.png" mode="widthFix" />
|
||||||
</button>
|
</button>
|
||||||
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
<text class="truncate">{{ item.name || "我要加入" }}</text>
|
||||||
<button
|
<button
|
||||||
hover-class="none"
|
hover-class="none"
|
||||||
v-if="item.id === user.id"
|
v-if="item.id === user.id"
|
||||||
@click="chooseTeam(0)"
|
@click="chooseTeam(2)"
|
||||||
>
|
>
|
||||||
<image src="../static/close-grey.png" mode="widthFix" />
|
<image src="../static/close-grey.png" mode="widthFix" />
|
||||||
</button>
|
</button>
|
||||||
@@ -378,25 +406,51 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
<PlayerSeats
|
|
||||||
v-if="room.battleType === 2"
|
|
||||||
:total="room.count || 10"
|
|
||||||
:players="players"
|
|
||||||
:removePlayer="removePlayer"
|
|
||||||
/>
|
|
||||||
<view>
|
<view>
|
||||||
<SButton :disabled="!canClick" :onClick="getReady">
|
<!-- <SButton
|
||||||
{{
|
v-if="user.id === owner.id && battleType === 1 && room.count === 2"
|
||||||
allReady.value
|
:disabled="!opponent.id"
|
||||||
? "即将进入对局..."
|
:onClick="startGame"
|
||||||
: owner.id === user.id
|
>进入对战</SButton
|
||||||
? "开始对局"
|
>
|
||||||
: "我准备好了"
|
<SButton
|
||||||
}}
|
v-if="user.id === owner.id && battleType === 2"
|
||||||
|
:disabled="players.length < 3"
|
||||||
|
:onClick="startGame"
|
||||||
|
>进入大乱斗</SButton
|
||||||
|
>
|
||||||
|
<SButton
|
||||||
|
v-if="user.id === owner.id && battleType === 1 && room.count >= 4"
|
||||||
|
:disabled="
|
||||||
|
players.some((p) => p.groupType === undefined || p.groupType === 2)
|
||||||
|
"
|
||||||
|
:onClick="startGame"
|
||||||
|
>开启对局</SButton
|
||||||
|
>
|
||||||
|
<SButton v-if="user.id !== owner.id" disabled>等待房主开启对战</SButton> -->
|
||||||
|
<SButton :disabled="ready" :onClick="getReady">{{
|
||||||
|
allReady.value ? "即将进入对局..." : "我准备好了"
|
||||||
|
}}</SButton>
|
||||||
|
<!-- <text class="tips">创建者点击下一步,所有人即可进入游戏。</text> -->
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- <SModal
|
||||||
|
:show="showModal"
|
||||||
|
:onClose="() => (showModal = false)"
|
||||||
|
height="520rpx"
|
||||||
|
>
|
||||||
|
<view class="btns">
|
||||||
|
<SButton :onClick="exitRoom" width="200px" :rounded="20">
|
||||||
|
暂时离开
|
||||||
</SButton>
|
</SButton>
|
||||||
<text class="tips">所有人准备好后由房主点击开始</text>
|
<block v-if="owner.id === user.id">
|
||||||
</view>
|
<view :style="{ height: '20px' }"></view>
|
||||||
|
<SButton :onClick="destroyRoom" width="200px" :rounded="20">
|
||||||
|
解散房间
|
||||||
|
</SButton>
|
||||||
|
</block>
|
||||||
</view>
|
</view>
|
||||||
|
</SModal> -->
|
||||||
</Container>
|
</Container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -453,7 +507,6 @@ onBeforeUnmount(() => {
|
|||||||
transform: translateY(-60px);
|
transform: translateY(-60px);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
position: relative;
|
|
||||||
}
|
}
|
||||||
.player > image {
|
.player > image {
|
||||||
width: 70px;
|
width: 70px;
|
||||||
@@ -462,19 +515,6 @@ onBeforeUnmount(() => {
|
|||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
.player > text:nth-child(2) {
|
|
||||||
color: #000;
|
|
||||||
background-color: #fed847;
|
|
||||||
font-size: 16rpx;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
line-height: 26rpx;
|
|
||||||
padding: 0 10rpx;
|
|
||||||
margin-top: -16rpx;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.player > text:nth-child(3) {
|
|
||||||
margin-top: 6rpx;
|
|
||||||
}
|
|
||||||
.player > text {
|
.player > text {
|
||||||
max-width: 100px;
|
max-width: 100px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@@ -482,26 +522,12 @@ onBeforeUnmount(() => {
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.player .ready {
|
.player > text:nth-child(3) {
|
||||||
background-color: #2c261fb3 !important;
|
color: #000;
|
||||||
border: 1rpx solid #a3793f66 !important;
|
background-color: #fed847;
|
||||||
color: #fed847 !important;
|
font-size: 8px;
|
||||||
}
|
border-radius: 10px;
|
||||||
.remove-player {
|
padding: 2rpx 10rpx;
|
||||||
width: 40rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
background: linear-gradient(0deg, #996c29b8 0%, #201e1aaf 100%);
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
.remove-player > image {
|
|
||||||
width: 90%;
|
|
||||||
height: 90%;
|
|
||||||
}
|
}
|
||||||
.team-mode > view > image:nth-child(2) {
|
.team-mode > view > image:nth-child(2) {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
@@ -619,7 +645,6 @@ onBeforeUnmount(() => {
|
|||||||
left: calc(50% - 15px);
|
left: calc(50% - 15px);
|
||||||
width: 30px;
|
width: 30px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #333;
|
|
||||||
}
|
}
|
||||||
.choose-side {
|
.choose-side {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -678,28 +703,9 @@ onBeforeUnmount(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 14rpx;
|
|
||||||
}
|
}
|
||||||
.choose-side-left-item > button:last-child > image,
|
.choose-side-left-item > button:last-child > image,
|
||||||
.choose-side-right-item > button:first-child > image {
|
.choose-side-right-item > button:first-child > image {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
}
|
}
|
||||||
.choose-side-left-item > view,
|
|
||||||
.choose-side-right-item > view {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.choose-side-left-item > view > text,
|
|
||||||
.choose-side-right-item > view > text {
|
|
||||||
font-size: 16rpx;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
line-height: 26rpx;
|
|
||||||
padding: 0 10rpx;
|
|
||||||
margin-top: -16rpx;
|
|
||||||
position: relative;
|
|
||||||
background-color: #2c261fb3;
|
|
||||||
border: 1rpx solid #a3793f66;
|
|
||||||
color: #fed847;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ import SButton from "@/components/SButton.vue";
|
|||||||
import { capsuleHeight } from "@/util";
|
import { capsuleHeight } from "@/util";
|
||||||
|
|
||||||
const images = [
|
const images = [
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_01.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmf6yitekatwe.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_02.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmi475gqdtrvx.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_03.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmgy8ej5wuap5.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_04.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmg6y7nveaadv.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_05.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-12-04/depguhlqg9zxastyn3.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_06.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-12-04/depguhlfr041aedqmb.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_07.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-12-04/depguhlpnlyxndnor5.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_08.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-09-04/dcjmxsmg68a8mezgzx.jpg",
|
||||||
"https://static.shelingxingqiu.com/mall/images/mall_09.jpg",
|
"https://static.shelingxingqiu.com/attachment/2025-10-14/ddht51a3hiyw7ueli4.jpg",
|
||||||
];
|
];
|
||||||
|
|
||||||
const addBg = ref(false);
|
const addBg = ref(false);
|
||||||
|
|||||||
@@ -13,15 +13,10 @@ import BowPower from "@/components/BowPower.vue";
|
|||||||
import TestDistance from "@/components/TestDistance.vue";
|
import TestDistance from "@/components/TestDistance.vue";
|
||||||
import BubbleTip from "@/components/BubbleTip.vue";
|
import BubbleTip from "@/components/BubbleTip.vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import {
|
import { createPractiseAPI, getPractiseAPI } from "@/apis";
|
||||||
createPractiseAPI,
|
|
||||||
startPractiseAPI,
|
|
||||||
endPractiseAPI,
|
|
||||||
getPractiseAPI,
|
|
||||||
} from "@/apis";
|
|
||||||
import { sharePractiseData } from "@/canvas";
|
import { sharePractiseData } from "@/canvas";
|
||||||
import { wxShare, debounce } from "@/util";
|
import { wxShare, debounce } from "@/util";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
@@ -45,13 +40,14 @@ const practiseId = ref("");
|
|||||||
const showGuide = ref(false);
|
const showGuide = ref(false);
|
||||||
|
|
||||||
const guideImages = [
|
const guideImages = [
|
||||||
"https://static.shelingxingqiu.com/attachment/2026-02-08/dg9ev0wwdpgwt9e6du.png",
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x68bs7z5elwvw7.png",
|
||||||
"https://static.shelingxingqiu.com/attachment/2026-02-08/dg9ev0wvv9sw4zioqk.png",
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x68qmi7grgreen.png",
|
||||||
"https://static.shelingxingqiu.com/attachment/2026-02-08/dg9ev0ww3khaycallu.png",
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x68hgrw1ip4wae.png",
|
||||||
"https://static.shelingxingqiu.com/attachment/2026-02-08/dg9ev0wtkcvaxxv0s8.png",
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x684x8zmfrmbla.png",
|
||||||
"https://static.shelingxingqiu.com/attachment/2026-02-08/dg9ev0wry5tw7ltmxr.png",
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x67sding7fodnk.png",
|
||||||
"https://static.shelingxingqiu.com/attachment/2026-02-08/dg9ev0wu3kcdrwzwpd.png",
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x68mpug7cac4yt.png",
|
||||||
"https://static.shelingxingqiu.com/attachment/2026-02-08/dg9ev0wwr6hfjhyfn5.png",
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x68my783mlmgxv.png",
|
||||||
|
"https://static.shelingxingqiu.com/attachment/2025-07-09/db77x68p48ylzirtb0.png",
|
||||||
];
|
];
|
||||||
|
|
||||||
const onSwiperIndexChange = (index) => {
|
const onSwiperIndexChange = (index) => {
|
||||||
@@ -66,35 +62,24 @@ const createPractise = async (arrows) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onOver = async () => {
|
const onOver = async () => {
|
||||||
practiseResult.value = await getPractiseAPI(practiseId.value);
|
|
||||||
start.value = false;
|
start.value = false;
|
||||||
|
practiseResult.value = await getPractiseAPI(practiseId.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (msg.type === MESSAGETYPESV2.ShootResult) {
|
messages.forEach((msg) => {
|
||||||
scores.value = msg.details;
|
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
if (step.value === 2 && msg.target.dst / 100 >= 5) {
|
||||||
setTimeout(onOver, 1500);
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.TestDistance) {
|
|
||||||
if (msg.shootData.distance / 100 >= 5) {
|
|
||||||
audioManager.play("距离合格");
|
|
||||||
btnDisabled.value = false;
|
btnDisabled.value = false;
|
||||||
showGuide.value = true;
|
showGuide.value = true;
|
||||||
} else audioManager.play("距离不足");
|
} else if (scores.value.length < total) {
|
||||||
|
scores.value.push(msg.target);
|
||||||
}
|
}
|
||||||
// messages.forEach((msg) => {
|
if (scores.value.length === total) {
|
||||||
// if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
setTimeout(onOver, 1500);
|
||||||
// if (step.value === 2 && msg.target.dst / 100 >= 5) {
|
}
|
||||||
// btnDisabled.value = false;
|
}
|
||||||
// showGuide.value = true;
|
});
|
||||||
// } else if (scores.value.length < total) {
|
|
||||||
// scores.value.push(msg.target);
|
|
||||||
// }
|
|
||||||
// if (scores.value.length === total) {
|
|
||||||
// setTimeout(onOver, 1500);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClickShare = debounce(async () => {
|
const onClickShare = debounce(async () => {
|
||||||
@@ -117,7 +102,6 @@ onBeforeUnmount(() => {
|
|||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
uni.$off("share-image", onClickShare);
|
uni.$off("share-image", onClickShare);
|
||||||
audioManager.stopAll();
|
audioManager.stopAll();
|
||||||
endPractiseAPI();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const nextStep = async () => {
|
const nextStep = async () => {
|
||||||
@@ -129,15 +113,13 @@ const nextStep = async () => {
|
|||||||
btnDisabled.value = true;
|
btnDisabled.value = true;
|
||||||
step.value = 2;
|
step.value = 2;
|
||||||
title.value = "-感知距离";
|
title.value = "-感知距离";
|
||||||
const result = await createPractiseAPI(total, 120);
|
|
||||||
if (result) practiseId.value = result.id;
|
|
||||||
} else if (step.value === 2) {
|
} else if (step.value === 2) {
|
||||||
showGuide.value = false;
|
showGuide.value = false;
|
||||||
step.value = 3;
|
step.value = 3;
|
||||||
title.value = "-小试牛刀";
|
title.value = "-小试牛刀";
|
||||||
} else if (step.value === 3) {
|
} else if (step.value === 3) {
|
||||||
title.value = "小试牛刀";
|
title.value = "小试牛刀";
|
||||||
await startPractiseAPI();
|
await createPractise(total);
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
step.value = 4;
|
step.value = 4;
|
||||||
start.value = true;
|
start.value = true;
|
||||||
@@ -151,8 +133,8 @@ const nextStep = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClose = async () => {
|
const onClose = () => {
|
||||||
const validArrows = (practiseResult.value.details || []).filter(
|
const validArrows = (practiseResult.value.arrows || []).filter(
|
||||||
(a) => a.x !== -30 && a.y !== -30
|
(a) => a.x !== -30 && a.y !== -30
|
||||||
);
|
);
|
||||||
if (validArrows.length === total) {
|
if (validArrows.length === total) {
|
||||||
@@ -166,8 +148,6 @@ const onClose = async () => {
|
|||||||
start.value = false;
|
start.value = false;
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
step.value = 3;
|
step.value = 3;
|
||||||
const result = await createPractiseAPI(total, 120);
|
|
||||||
if (result) practiseId.value = result.id;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -262,16 +242,16 @@ const onClose = async () => {
|
|||||||
v-if="step === 4"
|
v-if="step === 4"
|
||||||
:total="total"
|
:total="total"
|
||||||
:rowCount="6"
|
:rowCount="6"
|
||||||
:arrows="scores"
|
:scores="scores.map((s) => s.ring)"
|
||||||
/>
|
/>
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
v-if="practiseResult.details"
|
v-if="practiseResult.arrows"
|
||||||
:rowCount="6"
|
:rowCount="6"
|
||||||
:total="total"
|
:total="total"
|
||||||
:onClose="onClose"
|
:onClose="onClose"
|
||||||
:result="practiseResult"
|
:result="practiseResult"
|
||||||
:tipSrc="`../static/${
|
:tipSrc="`../static/${
|
||||||
practiseResult.details.filter(
|
practiseResult.arrows.filter(
|
||||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||||
).length < total
|
).length < total
|
||||||
? 'un'
|
? 'un'
|
||||||
|
|||||||
@@ -23,10 +23,8 @@ const warnning = ref("");
|
|||||||
const roomNumber = ref("");
|
const roomNumber = ref("");
|
||||||
const data = ref({});
|
const data = ref({});
|
||||||
const roomID = ref("");
|
const roomID = ref("");
|
||||||
const loading = ref(false);
|
|
||||||
|
|
||||||
const enterRoom = debounce(async (number) => {
|
const enterRoom = debounce(async (number) => {
|
||||||
if (loading.value) return;
|
|
||||||
if (!canEenter(user.value, device.value, online.value)) return;
|
if (!canEenter(user.value, device.value, online.value)) return;
|
||||||
if (game.value.inBattle) {
|
if (game.value.inBattle) {
|
||||||
uni.$showHint(1);
|
uni.$showHint(1);
|
||||||
@@ -35,15 +33,9 @@ const enterRoom = debounce(async (number) => {
|
|||||||
if (!number) {
|
if (!number) {
|
||||||
warnning.value = "请输入房间号";
|
warnning.value = "请输入房间号";
|
||||||
showModal.value = true;
|
showModal.value = true;
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
try {
|
|
||||||
const room = await getRoomAPI(number);
|
const room = await getRoomAPI(number);
|
||||||
if (!room.number) {
|
if (room.number) {
|
||||||
warnning.value = room.started ? "该房间对战已开始,无法加入" : "查无此房";
|
|
||||||
showModal.value = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const alreadyIn = room.members.find(
|
const alreadyIn = room.members.find(
|
||||||
(item) => item.userInfo.id === user.value.id
|
(item) => item.userInfo.id === user.value.id
|
||||||
);
|
);
|
||||||
@@ -55,12 +47,13 @@ const enterRoom = debounce(async (number) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loading.value = true;
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/battle-room?roomNumber=" + number,
|
url: "/pages/battle-room?roomNumber=" + number,
|
||||||
});
|
});
|
||||||
} finally {
|
} else {
|
||||||
loading.value = false;
|
warnning.value = room.started ? "该房间对战已开始,无法加入" : "查无此房";
|
||||||
|
showModal.value = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const onCreateRoom = async () => {
|
const onCreateRoom = async () => {
|
||||||
@@ -169,7 +162,7 @@ onLoad(async (options) => {
|
|||||||
<SModal
|
<SModal
|
||||||
:show="showModal"
|
:show="showModal"
|
||||||
:onClose="() => (showModal = false)"
|
:onClose="() => (showModal = false)"
|
||||||
height="716rpx"
|
height="520rpx"
|
||||||
>
|
>
|
||||||
<view v-if="warnning" class="warnning">
|
<view v-if="warnning" class="warnning">
|
||||||
{{ warnning }}
|
{{ warnning }}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { onShow, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
|
import { onShow, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
|
||||||
import AppFooter from "@/components/AppFooter.vue";
|
import AppFooter from "@/components/AppFooter.vue";
|
||||||
import AppBackground from "@/components/AppBackground.vue";
|
|
||||||
import UserHeader from "@/components/UserHeader.vue";
|
|
||||||
import Signin from "@/components/Signin.vue";
|
import Signin from "@/components/Signin.vue";
|
||||||
import BubbleTip from "@/components/BubbleTip.vue";
|
import NoticeBar from "@/components/NoticeBar.vue";
|
||||||
|
import TopRank from "@/components/TopRank.vue";
|
||||||
|
import MyRank from "@/components/MyRank.vue";
|
||||||
|
import LiveItem from "@/components/LiveItem.vue";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getAppConfig,
|
getAppConfig,
|
||||||
@@ -15,35 +15,37 @@ import {
|
|||||||
getMyDevicesAPI,
|
getMyDevicesAPI,
|
||||||
getDeviceBatteryAPI,
|
getDeviceBatteryAPI,
|
||||||
} from "@/apis";
|
} from "@/apis";
|
||||||
import { topThreeColors } from "@/constants";
|
import { canEenter, capsuleHeight } from "@/util";
|
||||||
import { canEenter } from "@/util";
|
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const {
|
const { updateConfig, updateUser, updateDevice, updateRank, updateOnline } =
|
||||||
updateConfig,
|
store;
|
||||||
updateUser,
|
|
||||||
updateDevice,
|
|
||||||
updateRank,
|
|
||||||
getLvlName,
|
|
||||||
updateOnline,
|
|
||||||
} = store;
|
|
||||||
const { user, device, rankData, online, game } = storeToRefs(store);
|
const { user, device, rankData, online, game } = storeToRefs(store);
|
||||||
|
|
||||||
const showModal = ref(false);
|
const showModal = ref(false);
|
||||||
const showGuide = ref(false);
|
const selected = ref(0);
|
||||||
|
const liveType = ref(0);
|
||||||
|
const liveTypes = {
|
||||||
|
大神赛: "../static/dashen.png",
|
||||||
|
新人王: "../static/xinren.png",
|
||||||
|
女神赛: "../static/nvshen.png",
|
||||||
|
};
|
||||||
|
const ranks = ref([]);
|
||||||
|
|
||||||
const toPage = async (path) => {
|
const toPage = async (path) => {
|
||||||
if (!user.value.id) {
|
if (!user.value.id) {
|
||||||
showModal.value = true;
|
showModal.value = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if (path === "/pages/first-try") {
|
if (path === "/pages/first-try") {
|
||||||
// if (canEenter(user.value, device.value, online.value, path)) {
|
if (canEenter(user.value, device.value, online.value, path)) {
|
||||||
// await uni.$checkAudio();
|
await uni.$checkAudio();
|
||||||
// }
|
} else {
|
||||||
// }
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
uni.navigateTo({ url: path });
|
uni.navigateTo({ url: path });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,24 +68,22 @@ onShow(async () => {
|
|||||||
const [rankList, homeData] = await Promise.all(promises);
|
const [rankList, homeData] = await Promise.all(promises);
|
||||||
|
|
||||||
console.log("排行数据", rankList);
|
console.log("排行数据", rankList);
|
||||||
|
ranks.value = [];
|
||||||
|
ranks.value.push((rankList.rank || []).slice(0, 3));
|
||||||
|
ranks.value.push((rankList.mvpRank || []).slice(0, 3));
|
||||||
|
ranks.value.push((rankList.ringRank || []).slice(0, 3));
|
||||||
updateRank(rankList);
|
updateRank(rankList);
|
||||||
|
|
||||||
if (homeData) {
|
if (homeData) {
|
||||||
console.log("首页数据:", homeData);
|
console.log("首页数据:", homeData);
|
||||||
if (homeData.user) {
|
if (homeData.user) {
|
||||||
updateUser(homeData.user);
|
updateUser(homeData.user);
|
||||||
if ("823,209,293,257".indexOf(homeData.user.id) !== -1) {
|
// if (homeData.user.trio <= 0) {
|
||||||
const show = uni.getStorageSync("show-the-user");
|
// showGuide.value = true;
|
||||||
if (!show) {
|
// setTimeout(() => {
|
||||||
uni.setStorageSync("show-the-user", true);
|
// showGuide.value = false;
|
||||||
}
|
// }, 3000);
|
||||||
}
|
// }
|
||||||
if (homeData.user.trio <= 0) {
|
|
||||||
showGuide.value = true;
|
|
||||||
setTimeout(() => {
|
|
||||||
showGuide.value = false;
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
const devices = await getMyDevicesAPI();
|
const devices = await getMyDevicesAPI();
|
||||||
if (devices.bindings && devices.bindings.length) {
|
if (devices.bindings && devices.bindings.length) {
|
||||||
updateDevice(
|
updateDevice(
|
||||||
@@ -105,339 +105,293 @@ onMounted(async () => {
|
|||||||
|
|
||||||
onShareAppMessage(() => {
|
onShareAppMessage(() => {
|
||||||
return {
|
return {
|
||||||
title: "智能真弓:实时捕捉+毫秒级同步,弓箭选手全球竞技!", // 分享卡片的标题
|
title: "智能真弓:实时捕捉+毫秒级同步,弓箭选手全球竞技!",
|
||||||
path: "/pages/index", // 用户点击分享卡片后跳转的页面路径
|
path: "/pages/index",
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png", // 分享卡片的配图,可以是本地或网络图片
|
"https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
onShareTimeline(() => {
|
onShareTimeline(() => {
|
||||||
return {
|
return {
|
||||||
title: "智能真弓:实时捕捉+毫秒级同步,弓箭选手全球竞技!", // 分享到朋友圈的标题
|
title: "智能真弓:实时捕捉+毫秒级同步,弓箭选手全球竞技!",
|
||||||
query: "from=timeline", // 用户通过朋友圈点击后,在页面 onShow 的 options 中可以获取到的参数
|
query: "from=timeline",
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png", // 分享到朋友圈的配图
|
"https://static.shelingxingqiu.com/attachment/2025-09-12/dcqoz26q0268wxmzjg.png",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Container :isHome="true" :showBackToGame="true">
|
<view
|
||||||
<view class="container">
|
class="container"
|
||||||
<view class="top-theme">
|
:style="{
|
||||||
|
paddingTop: capsuleHeight + 'px',
|
||||||
|
height: 'calc(100vh - ' + capsuleHeight + 'px)',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<view :style="{ flex: 1, overflow: 'hidden' }">
|
||||||
<image
|
<image
|
||||||
src="https://static.shelingxingqiu.com/attachment/2025-12-31/dfc9dxrq4xn7e6y2pp.png"
|
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmg11wd20o1bagd4k.png"
|
||||||
|
mode="widthFix"
|
||||||
|
class="top-bg"
|
||||||
|
/>
|
||||||
|
<view class="header">
|
||||||
|
<image
|
||||||
|
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmf4cjlds7oxd0tqd.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<UserHeader showRank :onSignin="() => (showModal = true)" />
|
<scroll-view
|
||||||
<view :style="{ padding: '12px 10px' }">
|
class="body"
|
||||||
<view class="feature-grid">
|
scroll-y
|
||||||
<view class="bow-card">
|
:show-scrollbar="false"
|
||||||
|
:enhanced="true"
|
||||||
|
:bounces="false"
|
||||||
|
>
|
||||||
|
<view class="main-btns" :style="{ marginBottom: '10rpx' }">
|
||||||
|
<view @click="() => toPage('/pages/my-device')">
|
||||||
<image
|
<image
|
||||||
v-if="online"
|
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjhsjc19tl0t7c.png"
|
||||||
src="https://static.shelingxingqiu.com/attachment/2025-08-07/dbvt1o6dvhr2rop3kn.webp"
|
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click="() => toPage('/pages/my-device')"
|
|
||||||
/>
|
/>
|
||||||
<image
|
<view v-if="user.id" class="device-info">
|
||||||
v-else
|
|
||||||
src="https://static.shelingxingqiu.com/attachment/2026-01-04/dffohwtk1gwh0xfa6h.png"
|
|
||||||
mode="widthFix"
|
|
||||||
@click="() => toPage('/pages/my-device')"
|
|
||||||
/>
|
|
||||||
<block v-if="user.id">
|
|
||||||
<text v-if="!device.deviceId">绑定我的智能弓</text>
|
<text v-if="!device.deviceId">绑定我的智能弓</text>
|
||||||
<text v-else-if="!online">设备离线</text>
|
<text v-else-if="!online">设备离线</text>
|
||||||
<text v-else-if="online">设备在线</text>
|
<text v-else-if="online">设备在线</text>
|
||||||
</block>
|
|
||||||
<image
|
|
||||||
src="../static/first-try.png"
|
|
||||||
mode="widthFix"
|
|
||||||
@click="() => toPage('/pages/first-try')"
|
|
||||||
/>
|
|
||||||
<BubbleTip v-if="showGuide" :location="{ top: '60%', left: '47%' }">
|
|
||||||
<text>新人必刷!</text>
|
|
||||||
<text>快来报到吧~</text>
|
|
||||||
</BubbleTip>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="play-card">
|
</view>
|
||||||
|
<view class="main-sub-btns">
|
||||||
|
<view @click="() => toPage('/pages/first-try')">
|
||||||
|
<image
|
||||||
|
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjhren1tfefi7k.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
<view @click="() => toPage('/pages/practise')">
|
<view @click="() => toPage('/pages/practise')">
|
||||||
<image src="../static/my-practise.png" mode="widthFix" />
|
<image
|
||||||
|
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjht6q8l8zcduq.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="main-btns">
|
||||||
|
<view @click="() => toPage('/pages/ranking')">
|
||||||
|
<image
|
||||||
|
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjhsi4s5qa7hch.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view @click="() => toPage('/pages/friend-battle')">
|
<view @click="() => toPage('/pages/friend-battle')">
|
||||||
<image src="../static/friend-battle.png" mode="widthFix" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="ranking-section">
|
|
||||||
<image
|
<image
|
||||||
src="https://static.shelingxingqiu.com/attachment/2025-09-25/dd1p9ci9v7frcrsxhj.png"
|
src="https://static.shelingxingqiu.com/attachment/2026-01-12/dfmgwjht17th6vl9a6.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- <NoticeBar /> -->
|
||||||
|
<view class="rank-info">
|
||||||
|
<image
|
||||||
|
src="../static/trophy-bg.png"
|
||||||
|
mode="widthFix"
|
||||||
|
class="trophy-bg"
|
||||||
|
/>
|
||||||
|
<view class="rank-info-header">
|
||||||
|
<view>
|
||||||
|
<image src="../static/rank-title.png" mode="widthFix" />
|
||||||
|
<text>星球榜</text>
|
||||||
|
</view>
|
||||||
|
<button hover-class="none" @click="toRankListPage">
|
||||||
|
<text>更多榜单</text>
|
||||||
|
<image src="../static/enter.png" mode="widthFix" />
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
<view class="rank-info-body">
|
||||||
|
<view :style="{ width: '45%' }">
|
||||||
|
<TopRank :data="ranks" />
|
||||||
|
</view>
|
||||||
|
<view :style="{ width: '55%' }">
|
||||||
|
<MyRank />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- <view class="live-bar">
|
||||||
<button
|
<button
|
||||||
class="into-btn"
|
|
||||||
@click="() => toPage('/pages/ranking')"
|
|
||||||
hover-class="none"
|
hover-class="none"
|
||||||
></button>
|
v-for="(item, index) in Object.keys(liveTypes)"
|
||||||
<view class="ranking-players" @click="toRankListPage">
|
:key="index"
|
||||||
<img src="../static/juezhanbang.png" mode="widthFix" />
|
@click="liveType = index"
|
||||||
<view class="divide-line"></view>
|
|
||||||
<view class="player-avatars">
|
|
||||||
<view
|
|
||||||
v-for="i in 6"
|
|
||||||
:key="i"
|
|
||||||
class="player-avatar"
|
|
||||||
:style="{
|
:style="{
|
||||||
zIndex: 8 - i,
|
color: liveType === index ? '#fff' : '#fff9',
|
||||||
borderColor: rankData.rank[i - 1]
|
background:
|
||||||
? topThreeColors[i - 1] || '#000'
|
liveType === index
|
||||||
: '#000',
|
? 'linear-gradient( 133deg, #FFD19A 0%, #A17636 100%)'
|
||||||
|
: '#252831',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<image v-if="i === 1" src="../static/champ1.png" />
|
<image :src="liveTypes[item]" mode="widthFix" />
|
||||||
<image v-if="i === 2" src="../static/champ2.png" />
|
<text>{{ item }}</text>
|
||||||
<image v-if="i === 3" src="../static/champ3.png" />
|
</button>
|
||||||
<view v-if="i > 3">{{ i }}</view>
|
|
||||||
<image
|
|
||||||
:src="
|
|
||||||
rankData.rank[i - 1]
|
|
||||||
? rankData.rank[i - 1].avatar
|
|
||||||
: '../static/user-icon-dark.png'
|
|
||||||
"
|
|
||||||
mode="aspectFill"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
<view class="more-players">
|
|
||||||
<text>{{ rankData.rank.length }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="my-data">
|
|
||||||
<view @click="() => toPage('/pages/my-growth')">
|
|
||||||
<image src="../static/my-growth.png" mode="widthFix" />
|
|
||||||
</view>
|
|
||||||
<view @click="() => toPage('/pages/ranking')">
|
|
||||||
<view>
|
|
||||||
<text>段位</text>
|
|
||||||
<text>{{
|
|
||||||
user.rankLvl ? getLvlName(user.rankLvl) : "暂无"
|
|
||||||
}}</text>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<text>赛季平均环数</text>
|
|
||||||
<text>{{ user.avg_ring ? user.avg_ring + "环" : "暂无" }}</text>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<text>赛季胜率</text>
|
|
||||||
<text>{{
|
|
||||||
user.avg_win
|
|
||||||
? Number((user.avg_win * 100).toFixed(2)) + "%"
|
|
||||||
: "暂无"
|
|
||||||
}}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
<swiper
|
||||||
|
:current="liveType"
|
||||||
|
@change="(e) => (liveType = e.detail.current)"
|
||||||
|
>
|
||||||
|
<swiper-item>
|
||||||
|
<LiveItem />
|
||||||
|
</swiper-item>
|
||||||
|
<swiper-item>
|
||||||
|
<LiveItem />
|
||||||
|
</swiper-item>
|
||||||
|
<swiper-item>
|
||||||
|
<LiveItem />
|
||||||
|
</swiper-item>
|
||||||
|
</swiper> -->
|
||||||
|
</scroll-view>
|
||||||
<Signin :show="showModal" :onClose="() => (showModal = false)" />
|
<Signin :show="showModal" :onClose="() => (showModal = false)" />
|
||||||
</view>
|
</view>
|
||||||
<AppFooter />
|
<AppFooter
|
||||||
</Container>
|
:selected="selected"
|
||||||
|
:onChange="(index) => (selected = index)"
|
||||||
|
:onSignin="() => (showModal = true)"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
.container {
|
.container {
|
||||||
width: 100%;
|
width: 100vw;
|
||||||
height: calc(100% - 120px);
|
height: 100vh;
|
||||||
}
|
|
||||||
|
|
||||||
.feature-grid {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feature-grid > view {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
background-color: #000;
|
||||||
}
|
}
|
||||||
|
.top-bg {
|
||||||
.bow-card {
|
|
||||||
width: 50%;
|
|
||||||
border-radius: 25rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.feature-grid > view > image {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
position: fixed;
|
||||||
|
|
||||||
.bow-card > text {
|
|
||||||
position: absolute;
|
|
||||||
top: 66%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
white-space: nowrap;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #b3b3b3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bow-card > image:nth-child(3) {
|
|
||||||
transform: translateY(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.play-card {
|
|
||||||
width: 48%;
|
|
||||||
margin-left: 2%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.play-card > view > image {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ranking-section {
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 15px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ranking-section > image {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
}
|
||||||
|
.header {
|
||||||
.into-btn {
|
height: 50px;
|
||||||
position: absolute;
|
|
||||||
top: 40px;
|
|
||||||
left: calc(50% - 100px);
|
|
||||||
width: 200px;
|
|
||||||
height: 100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ranking-players {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
margin-top: 42%;
|
|
||||||
border-bottom: 1rpx solid rgba(255, 255, 255, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ranking-players > image:first-child {
|
|
||||||
width: 28%;
|
|
||||||
transform: translateX(-10px) translateY(-8px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.player-avatars {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divide-line {
|
|
||||||
width: 1px;
|
|
||||||
height: 35px;
|
|
||||||
background-color: #80808033;
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.player-avatar,
|
|
||||||
.more-players {
|
|
||||||
width: 82rpx;
|
|
||||||
height: 82rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
margin-right: -20rpx;
|
|
||||||
border: 1rpx solid #312f35;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.player-avatar > image:first-child,
|
|
||||||
.player-avatar > view:first-child {
|
|
||||||
position: absolute;
|
|
||||||
top: -24rpx;
|
|
||||||
left: 22rpx;
|
|
||||||
width: 32rpx;
|
|
||||||
height: 32rpx;
|
|
||||||
}
|
|
||||||
.player-avatar > view:first-child {
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #777777;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 10px;
|
|
||||||
line-height: 18px;
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.player-avatar > image:last-child {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.more-players {
|
|
||||||
background: #3c445a;
|
|
||||||
font-size: 9px;
|
|
||||||
line-height: 80rpx;
|
|
||||||
text-align: center;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.more-players > text {
|
|
||||||
margin-left: 2px;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.my-data {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: 20px;
|
align-items: center;
|
||||||
justify-content: space-between;
|
padding-left: 30rpx;
|
||||||
}
|
}
|
||||||
.my-data > view:first-child {
|
.header > image {
|
||||||
width: 28%;
|
width: 200rpx;
|
||||||
|
height: 50rpx;
|
||||||
}
|
}
|
||||||
.my-data > view:first-child > image {
|
.body {
|
||||||
|
width: calc(100vw - 50rpx);
|
||||||
|
height: calc(100% - 25rpx);
|
||||||
|
padding: 0 25rpx;
|
||||||
|
position: relative;
|
||||||
|
margin-bottom: 25rpx;
|
||||||
|
}
|
||||||
|
.main-btns {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
transform: translateX(-8px);
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 20rpx;
|
||||||
}
|
}
|
||||||
.my-data > view:nth-child(2) {
|
.main-btns > view {
|
||||||
width: 68%;
|
position: relative;
|
||||||
font-size: 12px;
|
|
||||||
color: #fff6;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
}
|
||||||
.my-data > view:nth-child(2) > view:nth-child(2) {
|
.main-btns image {
|
||||||
width: 38%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.my-data > view:nth-child(2) > view {
|
.main-sub-btns {
|
||||||
width: 28%;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: linear-gradient(180deg, #303b4c 30%, #2c384a 100%);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.device-info {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
bottom: 50rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #fff9;
|
||||||
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
.my-data > view:nth-child(2) > view > text:last-child {
|
.rank-info {
|
||||||
color: #fff;
|
margin-top: 10rpx;
|
||||||
line-height: 25px;
|
background: linear-gradient(180deg, #2f2d2b 0%, #252831 100%);
|
||||||
font-weight: 500;
|
border-radius: 20rpx;
|
||||||
|
position: relative;
|
||||||
|
padding: 20rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-top: 20rpx;
|
||||||
}
|
}
|
||||||
.top-theme {
|
.trophy-bg {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 188rpx;
|
||||||
|
height: 192rpx;
|
||||||
|
}
|
||||||
|
.rank-info-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
}
|
||||||
|
.rank-info-header > view {
|
||||||
|
width: 186rpx;
|
||||||
|
height: 56rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.rank-info-header > view > image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.rank-info-header > view > text {
|
||||||
|
line-height: 56rpx;
|
||||||
|
display: block;
|
||||||
|
transform: translate(75rpx, -65rpx);
|
||||||
|
}
|
||||||
|
.rank-info-header > button {
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #999999;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.rank-info-header > button > image {
|
||||||
|
width: 30rpx;
|
||||||
|
height: 30rpx;
|
||||||
|
}
|
||||||
|
.rank-info-body {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.rank-info-body > view:first-child {
|
||||||
|
border-right: 1rpx solid #e8e8e81a;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.live-bar {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 20rpx;
|
||||||
|
margin: 20rpx 0;
|
||||||
|
}
|
||||||
|
.live-bar > button {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
height: 68rpx;
|
||||||
height: 60px;
|
border-radius: 34rpx;
|
||||||
z-index: -1;
|
font-weight: 600;
|
||||||
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
.top-theme > image {
|
.live-bar > button > image {
|
||||||
width: 300rpx;
|
width: 46rpx;
|
||||||
transform: translate(-4%, -14%);
|
height: 40rpx;
|
||||||
|
margin-right: 15rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -5,49 +5,87 @@ 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 PlayerScore2 from "@/components/PlayerScore2.vue";
|
import PlayerScore2 from "@/components/PlayerScore2.vue";
|
||||||
import { getBattleAPI } from "@/apis";
|
import { getGameAPI } from "@/apis";
|
||||||
|
|
||||||
|
const blueTeam = ref([]);
|
||||||
|
const redTeam = ref([]);
|
||||||
|
const roundsData = ref([]);
|
||||||
|
const goldenRoundsData = ref([]);
|
||||||
const battleId = ref("");
|
const battleId = ref("");
|
||||||
const data = ref({
|
const data = ref({
|
||||||
teams: [],
|
players: [],
|
||||||
rounds: [],
|
|
||||||
});
|
});
|
||||||
const players = ref([]);
|
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (!options.battleId) return;
|
if (options.id) {
|
||||||
battleId.value = options.battleId || "60510101693403136";
|
battleId.value = options.id || "BATTLE-1755484626207409508-955";
|
||||||
const result = await getBattleAPI(battleId.value);
|
const result = await getGameAPI(battleId.value);
|
||||||
data.value = result;
|
data.value = result;
|
||||||
if (result.mode > 3) {
|
if (result.mode === 1) {
|
||||||
players.value = result.resultList.map((item, index) => {
|
blueTeam.value = Object.values(result.bluePlayers || {});
|
||||||
const plist = result.teams[0] ? result.teams[0].players : [];
|
redTeam.value = Object.values(result.redPlayers || {});
|
||||||
const p = plist.find((p) => p.id === item.userId);
|
Object.values(result.roundsData).forEach((item) => {
|
||||||
const arrows = new Array(12);
|
let bluePoint = 1;
|
||||||
result.rounds.forEach((r, index) => {
|
let redPoint = 1;
|
||||||
if (r.shoots[item.userId]) {
|
let blueTotalRings = 0;
|
||||||
r.shoots[item.userId].forEach((s, index2) => {
|
let redTotalRings = 0;
|
||||||
arrows[index2 + index * 6] = s;
|
let blueArrows = [];
|
||||||
|
let redArrows = [];
|
||||||
|
blueTeam.value.forEach((p) => {
|
||||||
|
if (!item[p.playerId]) return;
|
||||||
|
blueTotalRings += item[p.playerId].reduce((a, b) => a + b.ring, 0);
|
||||||
|
blueArrows = [...blueArrows, ...item[p.playerId]];
|
||||||
|
});
|
||||||
|
redTeam.value.forEach((p) => {
|
||||||
|
if (!item[p.playerId]) return;
|
||||||
|
redTotalRings += item[p.playerId].reduce((a, b) => a + b.ring, 0);
|
||||||
|
redArrows = [...redArrows, ...item[p.playerId]];
|
||||||
|
});
|
||||||
|
if (blueTotalRings > redTotalRings) {
|
||||||
|
bluePoint = 2;
|
||||||
|
redPoint = 0;
|
||||||
|
} else if (blueTotalRings < redTotalRings) {
|
||||||
|
bluePoint = 0;
|
||||||
|
redPoint = 2;
|
||||||
|
}
|
||||||
|
roundsData.value.push({
|
||||||
|
blue: {
|
||||||
|
avatars: blueTeam.value.map((p) => p.avatar),
|
||||||
|
arrows: blueArrows,
|
||||||
|
totalRing: blueTotalRings,
|
||||||
|
totalScore: bluePoint,
|
||||||
|
},
|
||||||
|
red: {
|
||||||
|
avatars: redTeam.value.map((p) => p.avatar),
|
||||||
|
arrows: redArrows,
|
||||||
|
totalRing: redTotalRings,
|
||||||
|
totalScore: redPoint,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
result.goldenRounds.forEach((round) => {
|
||||||
|
goldenRoundsData.value.push({
|
||||||
|
blue: {
|
||||||
|
avatars: blueTeam.value.map((p) => p.avatar),
|
||||||
|
arrows: round.arrowHistory.filter((a) => a.team === 1),
|
||||||
|
},
|
||||||
|
red: {
|
||||||
|
avatars: redTeam.value.map((p) => p.avatar),
|
||||||
|
arrows: round.arrowHistory.filter((a) => a.team === 0),
|
||||||
|
},
|
||||||
|
winner: round.winner,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
rank: index + 1,
|
|
||||||
name: p.name,
|
|
||||||
avatar: p.avatar || "",
|
|
||||||
arrows,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkBowData = (selected) => {
|
const checkBowData = () => {
|
||||||
if (data.value.mode <= 3) {
|
if (data.value.mode === 1) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/team-bow-data?battleId=${battleId.value}&selected=${selected}`,
|
url: `/pages/team-bow-data?battleId=${battleId.value}`,
|
||||||
});
|
});
|
||||||
} else {
|
} else if (data.value.mode === 2) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/melee-bow-data?battleId=${battleId.value}`,
|
url: `/pages/melee-bow-data?battleId=${battleId.value}`,
|
||||||
});
|
});
|
||||||
@@ -59,13 +97,13 @@ const checkBowData = (selected) => {
|
|||||||
<Container title="详情">
|
<Container title="详情">
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<BattleHeader
|
<BattleHeader
|
||||||
:winner="data.winTeam"
|
:winner="data.winner"
|
||||||
:blueTeam="data.teams[1] ? data.teams[1].players : []"
|
:blueTeam="blueTeam"
|
||||||
:redTeam="data.teams[2] ? data.teams[2].players : []"
|
:redTeam="redTeam"
|
||||||
:players="players"
|
:players="data.players"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
v-if="data.mode >= 3"
|
v-if="data.players && data.players.length"
|
||||||
class="score-header"
|
class="score-header"
|
||||||
:style="{ border: 'none', padding: '5px 15px' }"
|
:style="{ border: 'none', padding: '5px 15px' }"
|
||||||
>
|
>
|
||||||
@@ -76,61 +114,141 @@ const checkBowData = (selected) => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<PlayerScore2
|
<PlayerScore2
|
||||||
v-if="data.mode >= 3"
|
v-if="data.players && data.players.length"
|
||||||
v-for="(player, index) in players"
|
v-for="(player, index) in data.players"
|
||||||
:key="index"
|
:key="index"
|
||||||
:name="player.name"
|
:name="player.name"
|
||||||
:avatar="player.avatar"
|
:avatar="player.avatar"
|
||||||
:arrows="player.arrows"
|
:scores="player.arrowHistory"
|
||||||
:totalScore="player.totalScore"
|
:totalScore="player.totalScore"
|
||||||
|
:totalRing="player.totalRings"
|
||||||
:rank="index + 1"
|
:rank="index + 1"
|
||||||
/>
|
/>
|
||||||
<view
|
<block v-for="(round, index) in goldenRoundsData" :key="index">
|
||||||
v-if="data.mode <= 3"
|
|
||||||
v-for="(round, index) in data.rounds"
|
|
||||||
:key="index"
|
|
||||||
:style="{ marginBottom: '5px' }"
|
|
||||||
>
|
|
||||||
<view class="score-header">
|
<view class="score-header">
|
||||||
<text>{{ round.ifGold ? "决金箭" : `第${index + 1}轮` }}</text>
|
<text>决金箭轮(环数)</text>
|
||||||
<view @click="() => checkBowData(index)">
|
<view @click="checkBowData">
|
||||||
<text>查看靶纸</text>
|
<text>查看靶纸</text>
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="score-row">
|
||||||
class="score-row"
|
|
||||||
v-for="team in Object.keys(round.shoots)"
|
|
||||||
:key="team"
|
|
||||||
>
|
|
||||||
<view>
|
<view>
|
||||||
<view>
|
<view>
|
||||||
<image
|
<image
|
||||||
v-for="(p, index) in data.teams[team].players"
|
v-for="(src, index) in round.blue.avatars"
|
||||||
:style="{
|
:style="{
|
||||||
borderColor: '#64BAFF',
|
borderColor: '#64BAFF',
|
||||||
transform: `translateX(-${index * 15}px)`,
|
transform: `translateX(-${index * 15}px)`,
|
||||||
}"
|
}"
|
||||||
:src="p.avatar || '../static/user-icon.png'"
|
:src="src"
|
||||||
:key="index"
|
:key="index"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<text
|
<text v-for="(arrow, index) in round.blue.arrows" :key="index">
|
||||||
v-for="(arrow, index2) in round.shoots[team]"
|
{{ arrow.ring }}环
|
||||||
:key="index2"
|
</text>
|
||||||
:style="{ color: arrow.ringX ? '#fed847' : '#ccc' }"
|
</view>
|
||||||
|
<image
|
||||||
|
v-if="round.winner === 1"
|
||||||
|
src="../static/winner-badge.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="score-row" :style="{ marginBottom: '5px' }">
|
||||||
|
<view>
|
||||||
|
<view>
|
||||||
|
<image
|
||||||
|
v-for="(src, index) in round.red.avatars"
|
||||||
|
:style="{
|
||||||
|
borderColor: '#FF6767',
|
||||||
|
transform: `translateX(-${index * 15}px)`,
|
||||||
|
}"
|
||||||
|
:src="src || '../static/user-icon.png'"
|
||||||
|
:key="index"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text v-for="(arrow, index) in round.red.arrows" :key="index">
|
||||||
|
{{ arrow.ring }}环
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<image
|
||||||
|
v-if="round.winner === 0"
|
||||||
|
src="../static/winner-badge.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
<view
|
||||||
|
v-for="(round, index) in roundsData"
|
||||||
|
:key="index"
|
||||||
|
:style="{ marginBottom: '5px' }"
|
||||||
>
|
>
|
||||||
{{ arrow.ringX ? "X" : `${arrow.ring}环` }}
|
<block
|
||||||
|
v-if="
|
||||||
|
index < Object.keys(roundsData).length - goldenRoundsData.length
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<view class="score-header">
|
||||||
|
<text>第{{ index + 1 }}轮</text>
|
||||||
|
<view @click="checkBowData">
|
||||||
|
<text>查看靶纸</text>
|
||||||
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="score-row">
|
||||||
|
<view>
|
||||||
|
<view>
|
||||||
|
<image
|
||||||
|
v-for="(src, index) in round.blue.avatars"
|
||||||
|
:style="{
|
||||||
|
borderColor: '#64BAFF',
|
||||||
|
transform: `translateX(-${index * 15}px)`,
|
||||||
|
}"
|
||||||
|
:src="src || '../static/user-icon.png'"
|
||||||
|
:key="index"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text v-for="(arrow, index2) in round.blue.arrows" :key="index2">
|
||||||
|
{{ arrow.ring }}环
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<text :style="{ color: team == 1 ? '#64BAFF' : '#FF6767' }">
|
<text :style="{ color: '#64BAFF' }">
|
||||||
{{ round.shoots[team].reduce((acc, cur) => acc + cur.ring, 0) }}环
|
{{ round.blue.totalRing }}环
|
||||||
</text>
|
</text>
|
||||||
<text>得分 {{ round.scores[team].score }}</text>
|
<text>得分 {{ round.blue.totalScore }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="score-row">
|
||||||
|
<view>
|
||||||
|
<view>
|
||||||
|
<image
|
||||||
|
v-for="(src, index) in round.red.avatars"
|
||||||
|
:style="{
|
||||||
|
borderColor: '#FF6767',
|
||||||
|
transform: `translateX(-${index * 15}px)`,
|
||||||
|
}"
|
||||||
|
:src="src || '../static/user-icon.png'"
|
||||||
|
:key="index"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text v-for="(arrow, index2) in round.red.arrows" :key="index2">
|
||||||
|
{{ arrow.ring }}环
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text :style="{ color: '#FF6767' }">
|
||||||
|
{{ round.red.totalRing }}环
|
||||||
|
</text>
|
||||||
|
<text>得分 {{ round.red.totalScore }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
</view>
|
</view>
|
||||||
<view :style="{ height: '20px' }"></view>
|
<view :style="{ height: '20px' }"></view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -6,32 +6,43 @@ import Matching from "@/components/Matching.vue";
|
|||||||
import RoundEndTip from "@/components/RoundEndTip.vue";
|
import RoundEndTip from "@/components/RoundEndTip.vue";
|
||||||
import TestDistance from "@/components/TestDistance.vue";
|
import TestDistance from "@/components/TestDistance.vue";
|
||||||
import { matchGameAPI } from "@/apis";
|
import { matchGameAPI } from "@/apis";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
|
|
||||||
const gameType = ref(0);
|
const gameType = ref(0);
|
||||||
const teamSize = ref(0);
|
const teamSize = ref(0);
|
||||||
const onComplete = ref(null);
|
const onComplete = ref(null);
|
||||||
const matchSuccess = ref(false);
|
|
||||||
|
|
||||||
async function stopMatch() {
|
async function stopMatch() {
|
||||||
uni.$showHint(3);
|
uni.$showHint(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (msg.type === MESSAGETYPESV2.MatchSuccess) {
|
messages.forEach((msg) => {
|
||||||
matchSuccess.value = true;
|
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||||
|
if (!onComplete.value) {
|
||||||
onComplete.value = () => {
|
onComplete.value = () => {
|
||||||
|
if (msg.groupUserStatus) {
|
||||||
|
uni.setStorageSync("red-team", msg.groupUserStatus.redTeam);
|
||||||
|
uni.setStorageSync("blue-team", msg.groupUserStatus.blueTeam);
|
||||||
|
uni.setStorageSync("melee-players", [
|
||||||
|
...msg.groupUserStatus.redTeam,
|
||||||
|
...msg.groupUserStatus.blueTeam,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
uni.removeStorageSync("current-battle");
|
||||||
if (gameType.value == 1) {
|
if (gameType.value == 1) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/team-battle?battleId=${msg.id}&gameMode=2`,
|
url: `/pages/team-battle?battleId=${msg.id}&gameMode=2`,
|
||||||
});
|
});
|
||||||
} else if (gameType.value == 2) {
|
} else if (gameType.value == 2) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/melee-battle?battleId=${msg.id}&gameMode=2`,
|
url: `/pages/melee-match?battleId=${msg.id}&gameMode=2`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
@@ -53,7 +64,7 @@ onBeforeUnmount(() => {
|
|||||||
keepScreenOn: false,
|
keepScreenOn: false,
|
||||||
});
|
});
|
||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
if (gameType.value && teamSize.value && !matchSuccess.value) {
|
if (gameType.value && teamSize.value) {
|
||||||
matchGameAPI(false, gameType.value, teamSize.value);
|
matchGameAPI(false, gameType.value, teamSize.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -65,7 +76,7 @@ onShow(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
if (gameType.value && teamSize.value && !matchSuccess.value) {
|
if (gameType.value && teamSize.value) {
|
||||||
matchGameAPI(false, gameType.value, teamSize.value);
|
matchGameAPI(false, gameType.value, teamSize.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,199 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
|
||||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
|
||||||
import Container from "@/components/Container.vue";
|
|
||||||
import BowTarget from "@/components/BowTarget.vue";
|
|
||||||
import ShootProgress from "@/components/ShootProgress.vue";
|
|
||||||
import BattleHeader from "@/components/BattleHeader.vue";
|
|
||||||
import PlayerScore from "@/components/PlayerScore.vue";
|
|
||||||
import SButton from "@/components/SButton.vue";
|
|
||||||
import Avatar from "@/components/Avatar.vue";
|
|
||||||
import ScreenHint from "@/components/ScreenHint.vue";
|
|
||||||
import TestDistance from "@/components/TestDistance.vue";
|
|
||||||
import audioManager from "@/audioManager";
|
|
||||||
import { getBattleAPI, laserCloseAPI } from "@/apis";
|
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
|
||||||
import useStore from "@/store";
|
|
||||||
import { storeToRefs } from "pinia";
|
|
||||||
const store = useStore();
|
|
||||||
const { user } = storeToRefs(store);
|
|
||||||
const title = ref("");
|
|
||||||
const start = ref(null);
|
|
||||||
const battleId = ref("");
|
|
||||||
const currentRound = ref(1);
|
|
||||||
const tips = ref("即将开始...");
|
|
||||||
const players = ref([]);
|
|
||||||
const playersSorted = ref([]);
|
|
||||||
const playersScores = ref([]);
|
|
||||||
const halfTimeTip = ref(false);
|
|
||||||
const halfRest = ref(false);
|
|
||||||
|
|
||||||
function recoverData(battleInfo, { force = false } = {}) {
|
|
||||||
if (battleInfo.way === 1) title.value = "好友约战 - 大乱斗";
|
|
||||||
if (battleInfo.way === 2) title.value = "排位赛 - 大乱斗";
|
|
||||||
players.value = battleInfo.teams[0].players;
|
|
||||||
start.value = battleInfo.status !== 0;
|
|
||||||
if (battleInfo.status === 0) {
|
|
||||||
const readyRemain = (Date.now() - battleInfo.createTime) / 1000;
|
|
||||||
console.log(`对局已进行${readyRemain}秒`);
|
|
||||||
if (readyRemain > 0 && readyRemain < 15) {
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.$emit("update-timer", 15 - readyRemain - 0.2);
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tips.value =
|
|
||||||
(battleInfo.rounds.length !== 2 ? "上" : "下") + "半场:请先射6箭";
|
|
||||||
playersScores.value = battleInfo.rounds.map((r) => ({ ...r.shoots }));
|
|
||||||
const totals = {};
|
|
||||||
players.value.forEach((p) => {
|
|
||||||
const total = playersScores.value.reduce((acc, round) => {
|
|
||||||
const arr = round[p.id] || [];
|
|
||||||
return acc + arr.length;
|
|
||||||
}, 0);
|
|
||||||
totals[p.id] = total;
|
|
||||||
});
|
|
||||||
playersSorted.value = players.value.slice().sort((a, b) => {
|
|
||||||
return totals[b.id] - totals[a.id];
|
|
||||||
});
|
|
||||||
if (battleInfo.status === 3) {
|
|
||||||
halfTimeTip.value = true;
|
|
||||||
halfRest.value = true;
|
|
||||||
tips.value = "准备下半场";
|
|
||||||
// 剩余休息时间
|
|
||||||
// const remain = (Date.now() - battleInfo.timeoutTime) / 1000;
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.$emit("update-remain", 0);
|
|
||||||
}, 200);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (force) {
|
|
||||||
const remain = (Date.now() - battleInfo.current.startTime) / 1000;
|
|
||||||
console.log(`当前轮已进行${remain}秒`);
|
|
||||||
if (remain > 0 && remain < 90) {
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.$emit("update-remain", 90 - remain - 0.2);
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoad(async (options) => {
|
|
||||||
if (options.battleId) battleId.value = options.battleId;
|
|
||||||
// uni.enableAlertBeforeUnload({
|
|
||||||
// message: "离开比赛可能导致比赛失败,是否继续?",
|
|
||||||
// success: (res) => {
|
|
||||||
// console.log("已启用离开提示");
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
|
||||||
if (Array.isArray(msg)) return;
|
|
||||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
|
||||||
halfTimeTip.value = false;
|
|
||||||
halfRest.value = false;
|
|
||||||
recoverData(msg);
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
|
||||||
recoverData(msg);
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.HalfRest) {
|
|
||||||
halfTimeTip.value = true;
|
|
||||||
halfRest.value = true;
|
|
||||||
tips.value = "准备下半场";
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.redirectTo({
|
|
||||||
url: "/pages/battle-result?battleId=" + msg.matchId,
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onMounted(async () => {
|
|
||||||
uni.setKeepScreenOn({
|
|
||||||
keepScreenOn: true,
|
|
||||||
});
|
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
|
||||||
await laserCloseAPI();
|
|
||||||
});
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
uni.setKeepScreenOn({
|
|
||||||
keepScreenOn: false,
|
|
||||||
});
|
|
||||||
uni.$off("socket-inbox", onReceiveMessage);
|
|
||||||
audioManager.stopAll();
|
|
||||||
});
|
|
||||||
|
|
||||||
onShow(async () => {
|
|
||||||
if (battleId.value) {
|
|
||||||
const result = await getBattleAPI(battleId.value);
|
|
||||||
if (result.status === 2) {
|
|
||||||
uni.showToast({
|
|
||||||
title: "比赛已结束",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
uni.navigateBack({
|
|
||||||
delta: 2,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
recoverData(result, { force: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Container :title="title" :bgType="1">
|
|
||||||
<view class="container">
|
|
||||||
<BattleHeader v-if="!start" :players="players" />
|
|
||||||
<TestDistance v-if="start === false" :guide="false" :isBattle="true" />
|
|
||||||
<ShootProgress
|
|
||||||
:show="start"
|
|
||||||
:start="start && !halfRest"
|
|
||||||
:tips="tips"
|
|
||||||
:total="90"
|
|
||||||
:melee="true"
|
|
||||||
:battleId="battleId"
|
|
||||||
/>
|
|
||||||
<view v-if="start" class="user-row">
|
|
||||||
<Avatar :src="user.avatar" :size="35" />
|
|
||||||
<BowPower />
|
|
||||||
</view>
|
|
||||||
<BowTarget
|
|
||||||
v-if="start"
|
|
||||||
:currentRound="
|
|
||||||
playersScores.map((s) => s[user.id].length).reduce((a, b) => a + b, 0)
|
|
||||||
"
|
|
||||||
:totalRound="12"
|
|
||||||
:scores="playersScores.map((r) => r[user.id]).flat()"
|
|
||||||
:stop="halfRest"
|
|
||||||
/>
|
|
||||||
<view :style="{ paddingBottom: '20px' }">
|
|
||||||
<PlayerScore
|
|
||||||
v-if="start"
|
|
||||||
v-for="(player, index) in playersSorted"
|
|
||||||
:key="index"
|
|
||||||
:player="player"
|
|
||||||
:scores="playersScores.map((s) => s[player.id])"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
<ScreenHint
|
|
||||||
:show="halfTimeTip"
|
|
||||||
mode="small"
|
|
||||||
:onClose="() => (halfTimeTip = false)"
|
|
||||||
>
|
|
||||||
<view class="half-time-tip">
|
|
||||||
<text>上半场结束,休息一下吧:)</text>
|
|
||||||
<text>20秒后开始下半场</text>
|
|
||||||
</view>
|
|
||||||
</ScreenHint>
|
|
||||||
</view>
|
|
||||||
</Container>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.container {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -4,39 +4,28 @@ import { onLoad } from "@dcloudio/uni-app";
|
|||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import BowTarget from "@/components/BowTarget.vue";
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import { getBattleAPI } from "@/apis";
|
import { getGameAPI } from "@/apis";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const { user } = storeToRefs(useStore());
|
const store = useStore();
|
||||||
const currentUser = ref({
|
const { user } = storeToRefs(store);
|
||||||
arrows: [],
|
const scores = ref([]);
|
||||||
});
|
const currentUser = ref({});
|
||||||
const players = ref([]);
|
const data = ref({});
|
||||||
|
const onSelect = (userId) => {
|
||||||
onLoad(async (options) => {
|
const user = data.value.players.find((p) => p.playerId === userId);
|
||||||
if (!options.battleId) return;
|
currentUser.value = user;
|
||||||
const result = await getBattleAPI(options.battleId || "59348111700660224");
|
if (user && user.arrowHistory) {
|
||||||
players.value = result.resultList.map((item, index) => {
|
scores.value = user.arrowHistory;
|
||||||
const plist = result.teams[0] ? result.teams[0].players : [];
|
}
|
||||||
const p = plist.find((p) => p.id === item.userId);
|
};
|
||||||
const arrows = new Array(12);
|
onLoad(async (options) => {
|
||||||
result.rounds.forEach((r, index) => {
|
if (options.battleId) {
|
||||||
if (r.shoots[item.userId]) {
|
const result = await getGameAPI(options.battleId);
|
||||||
r.shoots[item.userId].forEach((s, index2) => {
|
data.value = result;
|
||||||
arrows[index2 + index * 6] = s;
|
if (result.players && result.players[0]) {
|
||||||
});
|
onSelect(result.players[0].playerId);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
rank: index + 1,
|
|
||||||
name: p.name,
|
|
||||||
avatar: p.avatar || "",
|
|
||||||
arrows,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
if (players.value[0]) {
|
|
||||||
currentUser.value = players.value[0];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -44,26 +33,22 @@ onLoad(async (options) => {
|
|||||||
<template>
|
<template>
|
||||||
<Container title="靶纸">
|
<Container title="靶纸">
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<image
|
<image src="../static/battle-header-melee.png" mode="widthFix" />
|
||||||
src="../static/battle-header-melee.png"
|
<view class="players" v-if="data.players">
|
||||||
mode="widthFix"
|
|
||||||
:style="{ top: '-50rpx' }"
|
|
||||||
/>
|
|
||||||
<view class="players">
|
|
||||||
<view
|
<view
|
||||||
v-for="(player, index) in players"
|
v-for="(player, index) in data.players"
|
||||||
:key="index"
|
:key="index"
|
||||||
:style="{
|
:style="{
|
||||||
width: `${Math.max(100 / players.length, 18)}vw`,
|
width: `${Math.max(100 / data.players.length, 18)}vw`,
|
||||||
color: player.userId === currentUser.userId ? '#000' : '#fff9',
|
color: player.playerId === currentUser.playerId ? '#000' : '#fff9',
|
||||||
}"
|
}"
|
||||||
@click="currentUser = player"
|
@click="() => onSelect(player.playerId)"
|
||||||
>
|
>
|
||||||
<image
|
<image
|
||||||
v-if="player.userId === currentUser.userId"
|
v-if="player.playerId === currentUser.playerId"
|
||||||
src="../static/player-bg2.png"
|
src="../static/player-bg2.png"
|
||||||
:style="{
|
:style="{
|
||||||
width: `${Math.max(100 / players.length, 18)}vw`,
|
width: `${Math.max(100 / data.players.length, 18)}vw`,
|
||||||
}"
|
}"
|
||||||
class="player-bg"
|
class="player-bg"
|
||||||
/>
|
/>
|
||||||
@@ -72,25 +57,23 @@ onLoad(async (options) => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view :style="{ marginTop: '10px' }">
|
<view :style="{ marginTop: '10px' }">
|
||||||
<BowTarget :scores="currentUser.arrows" />
|
<BowTarget :scores="scores" />
|
||||||
</view>
|
</view>
|
||||||
<view class="score-text"
|
<view class="score-text"
|
||||||
><text :style="{ color: '#fed847' }">{{
|
><text :style="{ color: '#fed847' }">{{ scores.length }}</text
|
||||||
currentUser.arrows.length
|
|
||||||
}}</text
|
|
||||||
>支箭,共<text :style="{ color: '#fed847' }">{{
|
>支箭,共<text :style="{ color: '#fed847' }">{{
|
||||||
currentUser.arrows.reduce((last, next) => last + next.ring, 0)
|
scores.reduce((last, next) => last + next.ring, 0)
|
||||||
}}</text
|
}}</text
|
||||||
>环</view
|
>环</view
|
||||||
>
|
>
|
||||||
<view class="score-row" v-if="currentUser.arrows">
|
<view class="score-row">
|
||||||
<view
|
<view
|
||||||
v-for="(score, index) in currentUser.arrows"
|
v-for="(score, index) in scores"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="score-item"
|
class="score-item"
|
||||||
:style="{ width: '13vw', height: '13vw' }"
|
:style="{ width: '13vw', height: '13vw' }"
|
||||||
>
|
>
|
||||||
{{ score.ringX ? "X" : score.ring }}
|
{{ score.ring }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -114,7 +97,7 @@ onLoad(async (options) => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
margin-top: 50rpx;
|
margin-top: 25px;
|
||||||
}
|
}
|
||||||
.players::-webkit-scrollbar {
|
.players::-webkit-scrollbar {
|
||||||
width: 0;
|
width: 0;
|
||||||
|
|||||||
248
src/pages/melee-match.vue
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
|
||||||
|
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
|
import ShootProgress from "@/components/ShootProgress.vue";
|
||||||
|
import BattleHeader from "@/components/BattleHeader.vue";
|
||||||
|
import PlayerScore from "@/components/PlayerScore.vue";
|
||||||
|
import SButton from "@/components/SButton.vue";
|
||||||
|
import Avatar from "@/components/Avatar.vue";
|
||||||
|
import ScreenHint from "@/components/ScreenHint.vue";
|
||||||
|
import TestDistance from "@/components/TestDistance.vue";
|
||||||
|
import audioManager from "@/audioManager";
|
||||||
|
import { getCurrentGameAPI, laserCloseAPI } from "@/apis";
|
||||||
|
import { isGameEnded } from "@/util";
|
||||||
|
import { MESSAGETYPES } from "@/constants";
|
||||||
|
import useStore from "@/store";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
const store = useStore();
|
||||||
|
const { user } = storeToRefs(store);
|
||||||
|
const title = ref("大乱斗");
|
||||||
|
const start = ref(false);
|
||||||
|
const startCount = ref(true);
|
||||||
|
const battleId = ref("");
|
||||||
|
const currentRound = ref(1);
|
||||||
|
const scores = ref([]);
|
||||||
|
const tips = ref("即将开始...");
|
||||||
|
const players = ref([]);
|
||||||
|
const playersSorted = ref([]);
|
||||||
|
const playersScores = ref({});
|
||||||
|
const halfTimeTip = ref(false);
|
||||||
|
const isEnded = ref(false);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [players.value, playersScores.value],
|
||||||
|
([n_players, n_scores]) => {
|
||||||
|
if (n_players.length) {
|
||||||
|
playersSorted.value = Object.keys(n_scores)
|
||||||
|
.sort((a, b) => n_scores[b].length - n_scores[a].length)
|
||||||
|
.map((pid) => n_players.find((p) => p.id == pid));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true, // 添加深度监听
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
function recoverData(battleInfo) {
|
||||||
|
uni.removeStorageSync("last-awake-time");
|
||||||
|
// 注释用于测试
|
||||||
|
battleId.value = battleInfo.id;
|
||||||
|
players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
|
||||||
|
players.value.forEach((p) => {
|
||||||
|
playersScores.value[p.id] = [...p.arrows];
|
||||||
|
if (p.id === user.value.id) scores.value = [...p.arrows];
|
||||||
|
});
|
||||||
|
const remain = Date.now() / 1000 - battleInfo.startTime;
|
||||||
|
console.log(`当前局已进行${remain}秒`);
|
||||||
|
if (battleInfo.status === 0) {
|
||||||
|
if (remain > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.$emit("update-timer", 15 - remain);
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
start.value = true;
|
||||||
|
}
|
||||||
|
if (battleInfo.status === 2) {
|
||||||
|
const elapsedTime = (Date.now() - Date.parse(battleInfo.createdAt)) / 1000;
|
||||||
|
console.log("elapsedTime:", elapsedTime);
|
||||||
|
startCount.value = true;
|
||||||
|
// 这里的开始时间不是游戏开始时间,而是上半场或者下半场或者中场的开始时间,还要根据状态来判断
|
||||||
|
tips.value = battleInfo.halfGame
|
||||||
|
? "下半场:请再射6箭"
|
||||||
|
: "上半场:请先射6箭";
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.$emit("update-ramain", 90 - remain);
|
||||||
|
}, 200);
|
||||||
|
} else if (battleInfo.status === 9) {
|
||||||
|
startCount.value = false;
|
||||||
|
tips.value = "准备下半场";
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.$emit("update-ramain", 0);
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad(async (options) => {
|
||||||
|
if (options.gameMode == 1) title.value = "好友约战 - 大乱斗";
|
||||||
|
if (options.gameMode == 2) title.value = "排位赛 - 大乱斗";
|
||||||
|
if (options.battleId) {
|
||||||
|
battleId.value = options.battleId;
|
||||||
|
const players = uni.getStorageSync("melee-players");
|
||||||
|
if (players) {
|
||||||
|
players.value = players;
|
||||||
|
players.value.forEach((p) => {
|
||||||
|
playersScores.value[p.id] = [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const battleInfo = uni.getStorageSync("current-battle");
|
||||||
|
if (battleInfo) {
|
||||||
|
recoverData(battleInfo);
|
||||||
|
setTimeout(getCurrentGameAPI, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uni.enableAlertBeforeUnload({
|
||||||
|
message: "离开比赛可能导致比赛失败,是否继续?",
|
||||||
|
success: (res) => {
|
||||||
|
console.log("已启用离开提示");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
async function onReceiveMessage(messages = []) {
|
||||||
|
messages.forEach((msg) => {
|
||||||
|
if (msg.id !== battleId.value) return;
|
||||||
|
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||||
|
start.value = true;
|
||||||
|
startCount.value = true;
|
||||||
|
tips.value = scores.value.length
|
||||||
|
? "下半场:请再射6箭"
|
||||||
|
: "上半场:请先射6箭";
|
||||||
|
halfTimeTip.value = false;
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
|
if (!start.value) getCurrentGameAPI();
|
||||||
|
if (msg.userId === user.value.id) {
|
||||||
|
scores.value.push({ ...msg.target });
|
||||||
|
}
|
||||||
|
playersScores.value[msg.userId].push({ ...msg.target });
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||||
|
uni.$emit("update-ramain", 0);
|
||||||
|
[...msg.groupUserStatus.redTeam, ...msg.groupUserStatus.blueTeam].forEach(
|
||||||
|
(player) => {
|
||||||
|
playersScores.value[player.id] = [...player.arrows];
|
||||||
|
if (player.id === user.value.id) scores.value = [...player.arrows];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
startCount.value = false;
|
||||||
|
halfTimeTip.value = true;
|
||||||
|
tips.value = "准备下半场";
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
isEnded.value = true;
|
||||||
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/battle-result",
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||||
|
uni.$emit("update-header-loading", false);
|
||||||
|
if (msg.battleInfo) recoverData(msg.battleInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
onMounted(async () => {
|
||||||
|
uni.setKeepScreenOn({
|
||||||
|
keepScreenOn: true,
|
||||||
|
});
|
||||||
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
|
await laserCloseAPI();
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
uni.setKeepScreenOn({
|
||||||
|
keepScreenOn: false,
|
||||||
|
});
|
||||||
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
|
audioManager.stopAll();
|
||||||
|
});
|
||||||
|
const refreshTimer = ref(null);
|
||||||
|
onShow(async () => {
|
||||||
|
if (battleId.value) {
|
||||||
|
if (!isEnded.value && (await isGameEnded(battleId.value))) return;
|
||||||
|
getCurrentGameAPI();
|
||||||
|
const refreshData = () => {
|
||||||
|
const lastAwakeTime = uni.getStorageSync("last-awake-time");
|
||||||
|
if (lastAwakeTime) {
|
||||||
|
getCurrentGameAPI();
|
||||||
|
} else {
|
||||||
|
clearInterval(refreshTimer.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
refreshTimer.value = setInterval(refreshData, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
onHide(() => {
|
||||||
|
if (refreshTimer.value) clearInterval(refreshTimer.value);
|
||||||
|
uni.setStorageSync("last-awake-time", Date.now());
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container :title="title" :bgType="1">
|
||||||
|
<view class="container">
|
||||||
|
<BattleHeader v-if="!start" :players="players" />
|
||||||
|
<TestDistance v-if="!start" :guide="false" :isBattle="true" />
|
||||||
|
<ShootProgress
|
||||||
|
:show="start"
|
||||||
|
:start="start && startCount"
|
||||||
|
:tips="tips"
|
||||||
|
:total="90"
|
||||||
|
:melee="true"
|
||||||
|
:battleId="battleId"
|
||||||
|
/>
|
||||||
|
<view v-if="start" class="user-row">
|
||||||
|
<Avatar :src="user.avatar" :size="35" />
|
||||||
|
<BowPower />
|
||||||
|
</view>
|
||||||
|
<BowTarget
|
||||||
|
v-if="start"
|
||||||
|
:currentRound="scores.length"
|
||||||
|
:totalRound="12"
|
||||||
|
:scores="scores"
|
||||||
|
:stop="!startCount"
|
||||||
|
/>
|
||||||
|
<view :style="{ paddingBottom: '20px' }">
|
||||||
|
<PlayerScore
|
||||||
|
v-if="start"
|
||||||
|
v-for="(player, index) in playersSorted"
|
||||||
|
:key="index"
|
||||||
|
:player="player"
|
||||||
|
:scores="playersScores[player.id] || []"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<ScreenHint
|
||||||
|
:show="halfTimeTip"
|
||||||
|
mode="small"
|
||||||
|
:onClose="() => (halfTimeTip = false)"
|
||||||
|
>
|
||||||
|
<view class="half-time-tip">
|
||||||
|
<text>上半场结束,休息一下吧:)</text>
|
||||||
|
<text>20秒后开始下半场</text>
|
||||||
|
</view>
|
||||||
|
</ScreenHint>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -14,10 +14,11 @@ const arrows = ref([]);
|
|||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (!options.id) return;
|
if (options.id) {
|
||||||
const result = await getPractiseAPI(options.id || 176);
|
const result = await getPractiseAPI(options.id);
|
||||||
arrows.value = result.details;
|
arrows.value = result.arrows;
|
||||||
total.value = result.details.length;
|
total.value = result.completed_arrows;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ onLoad(async (options) => {
|
|||||||
:completeEffect="false"
|
:completeEffect="false"
|
||||||
:rowCount="total === 12 ? 6 : 9"
|
:rowCount="total === 12 ? 6 : 9"
|
||||||
:total="total"
|
:total="total"
|
||||||
:arrows="arrows"
|
:scores="arrows.map((a) => a.ring)"
|
||||||
:margin="arrows.length === 12 ? 4 : 1"
|
:margin="arrows.length === 12 ? 4 : 1"
|
||||||
:fontSize="arrows.length === 12 ? 25 : 22"
|
:fontSize="arrows.length === 12 ? 25 : 22"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const practiseList = ref([]);
|
|||||||
|
|
||||||
const toMatchDetail = (id) => {
|
const toMatchDetail = (id) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/match-detail?battleId=${id}`,
|
url: `/pages/match-detail?id=${id}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const getPractiseDetail = async (id) => {
|
const getPractiseDetail = async (id) => {
|
||||||
@@ -52,10 +52,6 @@ const onPractiseLoading = async (page) => {
|
|||||||
}
|
}
|
||||||
return result.length;
|
return result.length;
|
||||||
};
|
};
|
||||||
const getName = (battle) => {
|
|
||||||
if (battle.mode <= 3) return `${battle.mode}V${battle.mode}`;
|
|
||||||
return battle.mode + "人大乱斗";
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -84,19 +80,19 @@ const getName = (battle) => {
|
|||||||
<view
|
<view
|
||||||
v-for="(item, index) in matchList"
|
v-for="(item, index) in matchList"
|
||||||
:key="index"
|
:key="index"
|
||||||
@click="() => toMatchDetail(item.id)"
|
@click="() => toMatchDetail(item.battleId)"
|
||||||
>
|
>
|
||||||
<view class="contest-header">
|
<view class="contest-header">
|
||||||
<text>{{ getName(item) }}</text>
|
<text>{{ item.name }}</text>
|
||||||
<text>{{ item.createTime }}</text>
|
<text>{{ item.createdAt }}</text>
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
<BattleHeader
|
<BattleHeader
|
||||||
:players="item.teams[0] ? item.teams[0].players : []"
|
:players="item.mode === 1 ? [] : item.players"
|
||||||
:blueTeam="item.teams[1] ? item.teams[1].players : []"
|
:blueTeam="item.bluePlayers"
|
||||||
:redTeam="item.teams[2] ? item.teams[2].players : []"
|
:redTeam="item.redPlayers"
|
||||||
:winner="item.winTeam"
|
:winner="item.winner"
|
||||||
:showRank="item.teams[0]"
|
:showRank="item.mode === 2"
|
||||||
:showHeader="false"
|
:showHeader="false"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
@@ -107,19 +103,19 @@ const getName = (battle) => {
|
|||||||
<view
|
<view
|
||||||
v-for="(item, index) in battleList"
|
v-for="(item, index) in battleList"
|
||||||
:key="index"
|
:key="index"
|
||||||
@click="() => toMatchDetail(item.id)"
|
@click="() => toMatchDetail(item.battleId)"
|
||||||
>
|
>
|
||||||
<view class="contest-header">
|
<view class="contest-header">
|
||||||
<text>{{ getName(item) }}</text>
|
<text>{{ item.name }}</text>
|
||||||
<text>{{ item.createTime }}</text>
|
<text>{{ item.createdAt }}</text>
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
<BattleHeader
|
<BattleHeader
|
||||||
:players="item.teams[0] ? item.teams[0].players : []"
|
:players="item.mode === 1 ? [] : item.players"
|
||||||
:blueTeam="item.teams[1] ? item.teams[1].players : []"
|
:blueTeam="item.bluePlayers"
|
||||||
:redTeam="item.teams[2] ? item.teams[2].players : []"
|
:redTeam="item.redPlayers"
|
||||||
:winner="item.winTeam"
|
:winner="item.winner"
|
||||||
:showRank="item.teams[0]"
|
:showRank="item.mode === 2"
|
||||||
:showHeader="false"
|
:showHeader="false"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
@@ -135,7 +131,7 @@ const getName = (battle) => {
|
|||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
>{{ item.completed_arrows === 36 ? "耐力挑战" : "单组练习" }}
|
>{{ item.completed_arrows === 36 ? "耐力挑战" : "单组练习" }}
|
||||||
{{ item.createTime }}</text
|
{{ item.createdAt }}</text
|
||||||
>
|
>
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import ShootProgress from "@/components/ShootProgress.vue";
|
import ShootProgress from "@/components/ShootProgress.vue";
|
||||||
import BowTarget from "@/components/BowTarget.vue";
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
@@ -13,15 +13,10 @@ import TestDistance from "@/components/TestDistance.vue";
|
|||||||
import BubbleTip from "@/components/BubbleTip.vue";
|
import BubbleTip from "@/components/BubbleTip.vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
|
|
||||||
import {
|
import { createPractiseAPI, getPractiseAPI } from "@/apis";
|
||||||
createPractiseAPI,
|
|
||||||
startPractiseAPI,
|
|
||||||
endPractiseAPI,
|
|
||||||
getPractiseAPI,
|
|
||||||
} from "@/apis";
|
|
||||||
import { sharePractiseData } from "@/canvas";
|
import { sharePractiseData } from "@/canvas";
|
||||||
import { wxShare, debounce } from "@/util";
|
import { wxShare, debounce } from "@/util";
|
||||||
import { MESSAGETYPESV2, roundsName } from "@/constants";
|
import { MESSAGETYPES, roundsName } from "@/constants";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -31,40 +26,51 @@ const { user } = storeToRefs(store);
|
|||||||
const start = ref(false);
|
const start = ref(false);
|
||||||
const scores = ref([]);
|
const scores = ref([]);
|
||||||
const total = 12;
|
const total = 12;
|
||||||
|
const currentRound = ref(0);
|
||||||
const practiseResult = ref({});
|
const practiseResult = ref({});
|
||||||
const practiseId = ref("");
|
const practiseId = ref("");
|
||||||
const showGuide = ref(false);
|
const showGuide = ref(false);
|
||||||
const tips = ref("");
|
const tips = ref("");
|
||||||
const targetType = ref(1);
|
|
||||||
|
|
||||||
onLoad((options) => {
|
|
||||||
if (options.target) {
|
|
||||||
targetType.value = Number(options.target);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const onReady = async () => {
|
const onReady = async () => {
|
||||||
await startPractiseAPI();
|
const result = await createPractiseAPI(total, 2);
|
||||||
|
if (result) practiseId.value = result.id;
|
||||||
|
currentRound.value = 0;
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
start.value = true;
|
start.value = true;
|
||||||
audioManager.play("练习开始");
|
audioManager.play("练习开始");
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOver = async () => {
|
const onOver = async () => {
|
||||||
practiseResult.value = await getPractiseAPI(practiseId.value);
|
|
||||||
start.value = false;
|
start.value = false;
|
||||||
|
practiseResult.value = await getPractiseAPI(practiseId.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (msg.type === MESSAGETYPESV2.ShootResult) {
|
messages.forEach((msg) => {
|
||||||
scores.value = msg.details;
|
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
if (scores.value.length < total) {
|
||||||
|
scores.value.push(msg.target);
|
||||||
|
currentRound.value += 1;
|
||||||
|
if (currentRound.value === 4) {
|
||||||
|
currentRound.value = 1;
|
||||||
|
}
|
||||||
|
if (practiseId && scores.value.length === total / 2) {
|
||||||
|
showGuide.value = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
showGuide.value = false;
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
if (scores.value.length === total) {
|
||||||
setTimeout(onOver, 1500);
|
setTimeout(onOver, 1500);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onComplete() {
|
async function onComplete() {
|
||||||
const validArrows = (practiseResult.value.details || []).filter(
|
const validArrows = (practiseResult.value.arrows || []).filter(
|
||||||
(a) => a.x !== -30 && a.y !== -30
|
(a) => a.x !== -30 && a.y !== -30
|
||||||
);
|
);
|
||||||
if (validArrows.length === total) {
|
if (validArrows.length === total) {
|
||||||
@@ -74,8 +80,7 @@ async function onComplete() {
|
|||||||
practiseResult.value = {};
|
practiseResult.value = {};
|
||||||
start.value = false;
|
start.value = false;
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
const result = await createPractiseAPI(total, 120);
|
currentRound.value = 0;
|
||||||
if (result) practiseId.value = result.id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,15 +89,13 @@ const onClickShare = debounce(async () => {
|
|||||||
await wxShare("shareCanvas");
|
await wxShare("shareCanvas");
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(() => {
|
||||||
// audioManager.play("第一轮");
|
audioManager.play("第一轮");
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
});
|
});
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
uni.$on("share-image", onClickShare);
|
uni.$on("share-image", onClickShare);
|
||||||
const result = await createPractiseAPI(total, 120, targetType.value);
|
|
||||||
if (result) practiseId.value = result.id;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -102,19 +105,14 @@ onBeforeUnmount(() => {
|
|||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
uni.$off("share-image", onClickShare);
|
uni.$off("share-image", onClickShare);
|
||||||
audioManager.stopAll();
|
audioManager.stopAll();
|
||||||
endPractiseAPI();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Container
|
<Container :bgType="1" title="个人单组练习" :showBottom="!start && !scores.length">
|
||||||
:bgType="1"
|
|
||||||
title="个人单组练习"
|
|
||||||
:showBottom="!start && !scores.length"
|
|
||||||
>
|
|
||||||
<view>
|
<view>
|
||||||
<TestDistance v-if="!start && !practiseResult.id" />
|
<TestDistance v-if="!practiseId" />
|
||||||
<block v-else>
|
<block v-if="practiseId">
|
||||||
<ShootProgress
|
<ShootProgress
|
||||||
:tips="`${
|
:tips="`${
|
||||||
!start || scores.length === 12
|
!start || scores.length === 12
|
||||||
@@ -136,18 +134,18 @@ onBeforeUnmount(() => {
|
|||||||
</view>
|
</view>
|
||||||
<BowTarget
|
<BowTarget
|
||||||
:totalRound="start ? total / 4 : 0"
|
:totalRound="start ? total / 4 : 0"
|
||||||
:currentRound="scores.length % 3"
|
:currentRound="currentRound"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
/>
|
/>
|
||||||
<ScorePanel2 :arrows="scores" />
|
<ScorePanel2 :scores="scores.map((s) => s.ring)" />
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
v-if="practiseResult.details"
|
v-if="practiseResult.arrows"
|
||||||
:rowCount="6"
|
:rowCount="6"
|
||||||
:total="total"
|
:total="total"
|
||||||
:onClose="onComplete"
|
:onClose="onComplete"
|
||||||
:result="practiseResult"
|
:result="practiseResult"
|
||||||
:tipSrc="`../static/${
|
:tipSrc="`../static/${
|
||||||
practiseResult.details.filter(
|
practiseResult.arrows.filter(
|
||||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||||
).length < total
|
).length < total
|
||||||
? 'un'
|
? 'un'
|
||||||
|
|||||||
@@ -12,19 +12,13 @@ import TestDistance from "@/components/TestDistance.vue";
|
|||||||
import BubbleTip from "@/components/BubbleTip.vue";
|
import BubbleTip from "@/components/BubbleTip.vue";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
|
|
||||||
import {
|
import { createPractiseAPI, getPractiseAPI } from "@/apis";
|
||||||
createPractiseAPI,
|
|
||||||
startPractiseAPI,
|
|
||||||
endPractiseAPI,
|
|
||||||
getPractiseAPI,
|
|
||||||
} from "@/apis";
|
|
||||||
import { sharePractiseData } from "@/canvas";
|
import { sharePractiseData } from "@/canvas";
|
||||||
import { wxShare, debounce } from "@/util";
|
import { wxShare, debounce } from "@/util";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { MESSAGETYPES } from "@/constants";
|
||||||
|
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import {onLoad} from "@dcloudio/uni-app";
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user } = storeToRefs(store);
|
const { user } = storeToRefs(store);
|
||||||
|
|
||||||
@@ -34,52 +28,43 @@ const total = 36;
|
|||||||
const practiseResult = ref({});
|
const practiseResult = ref({});
|
||||||
const practiseId = ref("");
|
const practiseId = ref("");
|
||||||
const showGuide = ref(false);
|
const showGuide = ref(false);
|
||||||
const targetType = ref(1);
|
|
||||||
|
|
||||||
onLoad((options) => {
|
|
||||||
if (options.target) {
|
|
||||||
targetType.value = Number(options.target);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const onReady = async () => {
|
const onReady = async () => {
|
||||||
await startPractiseAPI();
|
const result = await createPractiseAPI(total, 3);
|
||||||
|
if (result) practiseId.value = result.id;
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
start.value = true;
|
start.value = true;
|
||||||
|
setTimeout(() => {
|
||||||
audioManager.play("练习开始");
|
audioManager.play("练习开始");
|
||||||
|
}, 300);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOver = async () => {
|
const onOver = async () => {
|
||||||
practiseResult.value = await getPractiseAPI(practiseId.value);
|
|
||||||
start.value = false;
|
start.value = false;
|
||||||
|
practiseResult.value = await getPractiseAPI(practiseId.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
async function onReceiveMessage(messages = []) {
|
||||||
if (msg.type === MESSAGETYPESV2.ShootResult) {
|
messages.forEach((msg) => {
|
||||||
scores.value = msg.details;
|
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
if (scores.value.length < total) {
|
||||||
|
scores.value.push(msg.target);
|
||||||
|
if (practiseId && scores.value.length === total / 2) {
|
||||||
|
showGuide.value = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
showGuide.value = false;
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
if (scores.value.length === total) {
|
||||||
setTimeout(onOver, 1500);
|
setTimeout(onOver, 1500);
|
||||||
}
|
}
|
||||||
// messages.forEach((msg) => {
|
}
|
||||||
// if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
}
|
||||||
// if (scores.value.length < total) {
|
});
|
||||||
// scores.value.push(msg.target);
|
|
||||||
// if (practiseId && scores.value.length === total / 2) {
|
|
||||||
// showGuide.value = true;
|
|
||||||
// setTimeout(() => {
|
|
||||||
// showGuide.value = false;
|
|
||||||
// }, 3000);
|
|
||||||
// }
|
|
||||||
// if (scores.value.length === total) {
|
|
||||||
// setTimeout(onOver, 1500);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onComplete() {
|
async function onComplete() {
|
||||||
const validArrows = (practiseResult.value.details || []).filter(
|
const validArrows = (practiseResult.value.arrows || []).filter(
|
||||||
(a) => a.x !== -30 && a.y !== -30
|
(a) => a.x !== -30 && a.y !== -30
|
||||||
);
|
);
|
||||||
if (validArrows.length === total) {
|
if (validArrows.length === total) {
|
||||||
@@ -89,8 +74,7 @@ async function onComplete() {
|
|||||||
practiseResult.value = {};
|
practiseResult.value = {};
|
||||||
start.value = false;
|
start.value = false;
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
const result = await createPractiseAPI(total, 360);
|
currentRound.value = 0;
|
||||||
if (result) practiseId.value = result.id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,14 +83,12 @@ const onClickShare = debounce(async () => {
|
|||||||
await wxShare("shareCanvas");
|
await wxShare("shareCanvas");
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(() => {
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
});
|
});
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
uni.$on("share-image", onClickShare);
|
uni.$on("share-image", onClickShare);
|
||||||
const result = await createPractiseAPI(total, 360, targetType.value);
|
|
||||||
if (result) practiseId.value = result.id;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -116,19 +98,14 @@ onBeforeUnmount(() => {
|
|||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
uni.$off("share-image", onClickShare);
|
uni.$off("share-image", onClickShare);
|
||||||
audioManager.stopAll();
|
audioManager.stopAll();
|
||||||
endPractiseAPI();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Container
|
<Container :bgType="1" title="日常耐力挑战" :showBottom="!start && !scores.length">
|
||||||
:bgType="1"
|
|
||||||
title="日常耐力挑战"
|
|
||||||
:showBottom="!start && !scores.length"
|
|
||||||
>
|
|
||||||
<view>
|
<view>
|
||||||
<TestDistance v-if="!start && !practiseResult.id" />
|
<TestDistance v-if="!practiseId" />
|
||||||
<block v-else>
|
<block v-if="practiseId">
|
||||||
<ShootProgress
|
<ShootProgress
|
||||||
:tips="`请连续射${total}支箭`"
|
:tips="`请连续射${total}支箭`"
|
||||||
:start="start"
|
:start="start"
|
||||||
@@ -150,20 +127,20 @@ onBeforeUnmount(() => {
|
|||||||
/>
|
/>
|
||||||
<ScorePanel
|
<ScorePanel
|
||||||
v-if="start"
|
v-if="start"
|
||||||
:arrows="scores"
|
:scores="scores.map((s) => s.ring)"
|
||||||
:total="total"
|
:total="total"
|
||||||
:rowCount="total / 4"
|
:rowCount="total / 4"
|
||||||
:margin="1.5"
|
:margin="1.5"
|
||||||
:font-size="20"
|
:font-size="20"
|
||||||
/>
|
/>
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
v-if="practiseResult.details"
|
v-if="practiseResult.arrows"
|
||||||
:total="total"
|
:total="total"
|
||||||
:rowCount="9"
|
:rowCount="9"
|
||||||
:onClose="onComplete"
|
:onClose="onComplete"
|
||||||
:result="practiseResult"
|
:result="practiseResult"
|
||||||
:tipSrc="`../static/${
|
:tipSrc="`../static/${
|
||||||
practiseResult.details.filter(
|
practiseResult.arrows.filter(
|
||||||
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
(arrow) => arrow.x !== -30 && arrow.y !== -30
|
||||||
).length < total
|
).length < total
|
||||||
? '2un'
|
? '2un'
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { onShow } from "@dcloudio/uni-app";
|
|||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import Guide from "@/components/Guide.vue";
|
import Guide from "@/components/Guide.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import TargetPicker from "@/components/TargetPicker.vue";
|
|
||||||
import { getPractiseDataAPI } from "@/apis";
|
import { getPractiseDataAPI } from "@/apis";
|
||||||
import { canEenter } from "@/util";
|
import { canEenter } from "@/util";
|
||||||
|
|
||||||
@@ -13,20 +12,12 @@ import { storeToRefs } from "pinia";
|
|||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user, device, online } = storeToRefs(store);
|
const { user, device, online } = storeToRefs(store);
|
||||||
const data = ref({});
|
const data = ref({});
|
||||||
const showTargetPicker = ref(false);
|
|
||||||
const pendingPractiseType = ref("");
|
|
||||||
|
|
||||||
const goPractise = async (type) => {
|
const goPractise = async (type) => {
|
||||||
if (!canEenter(user.value, device.value, online.value)) return;
|
if (!canEenter(user.value, device.value, online.value)) return;
|
||||||
pendingPractiseType.value = type;
|
await uni.$checkAudio();
|
||||||
showTargetPicker.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleTargetConfirm = (target) => {
|
|
||||||
showTargetPicker.value = false;
|
|
||||||
const type = pendingPractiseType.value;
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/practise-${type}?target=${target}`,
|
url: `/pages/practise-${type}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -97,11 +88,6 @@ onShow(async () => {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<TargetPicker
|
|
||||||
:show="showTargetPicker"
|
|
||||||
:onClose="() => (showTargetPicker = false)"
|
|
||||||
:onConfirm="handleTargetConfirm"
|
|
||||||
/>
|
|
||||||
</Container>
|
</Container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -197,22 +197,22 @@ onShow(async () => {
|
|||||||
<image
|
<image
|
||||||
src="../static/battle2v2.png"
|
src="../static/battle2v2.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click.stop="() => toMatchPage(2, 4)"
|
@click.stop="() => toMatchPage(1, 4)"
|
||||||
/>
|
/>
|
||||||
<image
|
<image
|
||||||
src="../static/battle3v3.png"
|
src="../static/battle3v3.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click.stop="() => toMatchPage(3, 6)"
|
@click.stop="() => toMatchPage(1, 6)"
|
||||||
/>
|
/>
|
||||||
<image
|
<image
|
||||||
src="../static/battle5.png"
|
src="../static/battle5.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click.stop="() => toMatchPage(4, 5)"
|
@click.stop="() => toMatchPage(2, 5)"
|
||||||
/>
|
/>
|
||||||
<image
|
<image
|
||||||
src="../static/battle10.png"
|
src="../static/battle10.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click.stop="() => toMatchPage(5, 10)"
|
@click.stop="() => toMatchPage(2, 10)"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="data-progress">
|
<view class="data-progress">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { onLoad, onShow, onHide } 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 BowTarget from "@/components/BowTarget.vue";
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
|
import PlayersRow from "@/components/PlayersRow.vue";
|
||||||
import BattleFooter from "@/components/BattleFooter.vue";
|
import BattleFooter from "@/components/BattleFooter.vue";
|
||||||
import ScreenHint from "@/components/ScreenHint.vue";
|
import ScreenHint from "@/components/ScreenHint.vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
@@ -11,17 +12,18 @@ import RoundEndTip from "@/components/RoundEndTip.vue";
|
|||||||
import TestDistance from "@/components/TestDistance.vue";
|
import TestDistance from "@/components/TestDistance.vue";
|
||||||
import TeamAvatars from "@/components/TeamAvatars.vue";
|
import TeamAvatars from "@/components/TeamAvatars.vue";
|
||||||
import ShootProgress2 from "@/components/ShootProgress2.vue";
|
import ShootProgress2 from "@/components/ShootProgress2.vue";
|
||||||
import { laserCloseAPI, getBattleAPI } from "@/apis";
|
import { getCurrentGameAPI, laserCloseAPI } from "@/apis";
|
||||||
import { MESSAGETYPESV2 } from "@/constants";
|
import { isGameEnded } from "@/util";
|
||||||
|
import { MESSAGETYPES, roundsName } from "@/constants";
|
||||||
import audioManager from "@/audioManager";
|
import audioManager from "@/audioManager";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { user } = storeToRefs(store);
|
const { user } = storeToRefs(store);
|
||||||
const start = ref(null);
|
const start = ref(false);
|
||||||
const tips = ref("");
|
const tips = ref("");
|
||||||
const battleId = ref("");
|
const battleId = ref("");
|
||||||
const currentRound = ref(0);
|
const currentRound = ref(1);
|
||||||
const goldenRound = ref(0);
|
const goldenRound = ref(0);
|
||||||
const currentRedPoint = ref(0);
|
const currentRedPoint = ref(0);
|
||||||
const currentBluePoint = ref(0);
|
const currentBluePoint = ref(0);
|
||||||
@@ -35,114 +37,252 @@ const redPoints = ref(0);
|
|||||||
const bluePoints = ref(0);
|
const bluePoints = ref(0);
|
||||||
const showRoundTip = ref(false);
|
const showRoundTip = ref(false);
|
||||||
const isFinalShoot = ref(false);
|
const isFinalShoot = ref(false);
|
||||||
|
const isEnded = ref(false);
|
||||||
|
|
||||||
const recoverData = (battleInfo, { force = false, arrowOnly = false } = {}) => {
|
function recoverData(battleInfo) {
|
||||||
try {
|
uni.removeStorageSync("last-awake-time");
|
||||||
battleId.value = battleInfo.matchId;
|
battleId.value = battleInfo.id;
|
||||||
blueTeam.value = battleInfo.teams[1].players || [];
|
redTeam.value = battleInfo.redTeam;
|
||||||
redTeam.value = battleInfo.teams[2].players || [];
|
blueTeam.value = battleInfo.blueTeam;
|
||||||
start.value = battleInfo.status !== 0;
|
|
||||||
if (battleInfo.status === 0) {
|
if (battleInfo.status === 0) {
|
||||||
const readyRemain = (Date.now() - battleInfo.createTime) / 1000;
|
const readyRemain = Date.now() / 1000 - battleInfo.startTime;
|
||||||
console.log(`对局已进行${readyRemain}秒`);
|
console.log(`当前局已进行${readyRemain}秒`);
|
||||||
if (readyRemain > 0 && readyRemain < 15) {
|
if (readyRemain > 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.$emit("update-timer", 15 - readyRemain - 0.2);
|
uni.$emit("update-timer", 15 - readyRemain);
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
return;
|
} else {
|
||||||
|
start.value = true;
|
||||||
|
bluePoints.value = 0;
|
||||||
|
redPoints.value = 0;
|
||||||
|
currentRound.value = battleInfo.currentRound;
|
||||||
|
roundResults.value = [...battleInfo.roundResults];
|
||||||
|
// 算得分
|
||||||
|
battleInfo.roundResults.forEach((round) => {
|
||||||
|
const blueTotal = round.blueArrows.reduce(
|
||||||
|
(last, next) => last + next.ring,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
const redTotal = round.redArrows.reduce(
|
||||||
|
(last, next) => last + next.ring,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
if (blueTotal === redTotal) {
|
||||||
|
bluePoints.value += 1;
|
||||||
|
redPoints.value += 1;
|
||||||
|
} else if (blueTotal > redTotal) {
|
||||||
|
bluePoints.value += 2;
|
||||||
|
} else {
|
||||||
|
redPoints.value += 2;
|
||||||
}
|
}
|
||||||
if (!arrowOnly) {
|
});
|
||||||
currentShooterId.value = battleInfo.current.playerId;
|
if (battleInfo.goldenRoundNumber) {
|
||||||
const redPlayer = battleInfo.teams[2].players.find(
|
currentRound.value += battleInfo.goldenRoundNumber;
|
||||||
(item) => item.id === battleInfo.current.playerId
|
goldenRound.value = battleInfo.goldenRoundNumber;
|
||||||
|
isFinalShoot.value = true;
|
||||||
|
for (let i = 1; i <= battleInfo.goldenRoundNumber; i++) {
|
||||||
|
const redArrows = [];
|
||||||
|
battleInfo.redTeam.forEach((item) => {
|
||||||
|
if (item.shotHistory[roundResults.value.length + 1]) {
|
||||||
|
item.shotHistory[roundResults.value.length + 1]
|
||||||
|
.filter((item) => !!item.playerId)
|
||||||
|
.forEach((item) => redArrows.push(item));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const blueArrows = [];
|
||||||
|
battleInfo.blueTeam.forEach((item) => {
|
||||||
|
if (item.shotHistory[roundResults.value.length + 1]) {
|
||||||
|
item.shotHistory[roundResults.value.length + 1]
|
||||||
|
.filter((item) => !!item.playerId)
|
||||||
|
.forEach((item) => blueArrows.push(item));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
roundResults.value.push({
|
||||||
|
number: roundResults.value.length + 1,
|
||||||
|
blueArrows,
|
||||||
|
redArrows,
|
||||||
|
blueTotal: blueArrows.reduce((last, next) => last + next.ring, 0),
|
||||||
|
redTotal: redArrows.reduce((last, next) => last + next.ring, 0),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const hasCurrentRoundData =
|
||||||
|
battleInfo.redTeam.some(
|
||||||
|
(item) => !!item.shotHistory[battleInfo.currentRound]
|
||||||
|
) ||
|
||||||
|
battleInfo.blueTeam.some(
|
||||||
|
(item) => !!item.shotHistory[battleInfo.currentRound]
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
battleInfo.currentRound > battleInfo.roundResults.length &&
|
||||||
|
hasCurrentRoundData
|
||||||
|
) {
|
||||||
|
const blueArrows = [];
|
||||||
|
const redArrows = [];
|
||||||
|
battleInfo.redTeam.forEach((item) =>
|
||||||
|
item.shotHistory[battleInfo.currentRound]
|
||||||
|
.filter((item) => !!item.playerId)
|
||||||
|
.forEach((item) => redArrows.push(item))
|
||||||
|
);
|
||||||
|
battleInfo.blueTeam.forEach((item) =>
|
||||||
|
item.shotHistory[battleInfo.currentRound]
|
||||||
|
.filter((item) => !!item.playerId)
|
||||||
|
.forEach((item) => blueArrows.push(item))
|
||||||
|
);
|
||||||
|
roundResults.value.push({
|
||||||
|
redArrows,
|
||||||
|
blueArrows,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
[...battleInfo.redTeam, ...battleInfo.blueTeam].some((p) => {
|
||||||
|
if (p.id === user.value.id) {
|
||||||
|
const roundArrows = Object.values(p.shotHistory);
|
||||||
|
if (roundArrows.length) {
|
||||||
|
uni.$emit("update-shot", {
|
||||||
|
currentShot: roundArrows[roundArrows.length - 1].length,
|
||||||
|
totalShot: battleInfo.config.teamSize === 2 ? 3 : 2,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const lastIndex = roundResults.value.length - 1;
|
||||||
|
if (roundResults.value[lastIndex]) {
|
||||||
|
const redArrows = roundResults.value[lastIndex].redArrows;
|
||||||
|
scores.value = [...redArrows]
|
||||||
|
.filter((item) => !!item.playerId)
|
||||||
|
.sort((a, b) => a.shotTimeUnix - b.shotTimeUnix);
|
||||||
|
const blueArrows = roundResults.value[lastIndex].blueArrows;
|
||||||
|
blueScores.value = [...blueArrows]
|
||||||
|
.filter((item) => !!item.playerId)
|
||||||
|
.sort((a, b) => a.shotTimeUnix - b.shotTimeUnix);
|
||||||
|
}
|
||||||
|
if (battleInfo.firePlayerIndex) {
|
||||||
|
currentShooterId.value = battleInfo.firePlayerIndex;
|
||||||
|
const redPlayer = redTeam.value.find(
|
||||||
|
(item) => item.id === currentShooterId.value
|
||||||
);
|
);
|
||||||
let nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
let nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||||
if (force) nextTips += "重回";
|
nextTips += "重回";
|
||||||
if (
|
// if (battleInfo.firePlayerIndex === user.value.id) nextTips += "你";
|
||||||
battleInfo.current.playerId === user.value.id &&
|
|
||||||
redTeam.value.length > 1
|
|
||||||
) {
|
|
||||||
nextTips += "你";
|
|
||||||
}
|
|
||||||
tips.value = nextTips;
|
tips.value = nextTips;
|
||||||
uni.$emit("update-tips", nextTips);
|
uni.$emit("update-tips", nextTips);
|
||||||
if (force) {
|
}
|
||||||
const remain = (Date.now() - battleInfo.current.startTime) / 1000;
|
if (battleInfo.fireTime > 0) {
|
||||||
console.log(`当前轮已进行${remain}秒`);
|
const remain = Date.now() / 1000 - battleInfo.fireTime;
|
||||||
if (remain > 0 && remain < 15) {
|
console.log(`当前箭已过${remain}秒`);
|
||||||
|
if (remain > 0 && remain <= 15) {
|
||||||
|
// 等渲染好再通知
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.$emit("update-remain", 15 - remain - 0.2);
|
uni.$emit("update-ramain", 15 - remain);
|
||||||
}, 200);
|
}, 300);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uni.$emit("update-remain", battleInfo.readyTime);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentRound.value = battleInfo.current.round || 1;
|
|
||||||
const latestRound = battleInfo.rounds[currentRound.value - 1];
|
|
||||||
if (latestRound) {
|
|
||||||
blueScores.value = latestRound.shoots[1];
|
|
||||||
scores.value = latestRound.shoots[2];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
roundResults.value = battleInfo.rounds || [];
|
|
||||||
isFinalShoot.value = battleInfo.current.goldRound;
|
|
||||||
bluePoints.value = battleInfo.teams[1].score;
|
|
||||||
redPoints.value = battleInfo.teams[2].score;
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
async function onReceiveMessage(msg) {
|
|
||||||
if (Array.isArray(msg)) return;
|
|
||||||
if (msg.type === MESSAGETYPESV2.BattleStart) {
|
|
||||||
start.value = true;
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.ToSomeoneShoot) {
|
|
||||||
recoverData(msg);
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.ShootResult) {
|
|
||||||
showRoundTip.value = false;
|
|
||||||
recoverData(msg, { arrowOnly: true });
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.NewRound) {
|
|
||||||
showRoundTip.value = true;
|
|
||||||
isFinalShoot.value = msg.current.goldRound;
|
|
||||||
const latestRound = msg.rounds[currentRound.value - 1];
|
|
||||||
if (latestRound) {
|
|
||||||
if (isFinalShoot.value) {
|
|
||||||
currentBluePoint.value = msg.teams[1].score;
|
|
||||||
currentRedPoint.value = msg.teams[2].score;
|
|
||||||
} else {
|
|
||||||
currentBluePoint.value = latestRound.scores[1].score;
|
|
||||||
currentRedPoint.value = latestRound.scores[2].score;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (msg.type === MESSAGETYPESV2.BattleEnd) {
|
|
||||||
if (msg.status === 4) {
|
|
||||||
showRoundTip.value = true;
|
|
||||||
currentBluePoint.value = 0;
|
|
||||||
currentRedPoint.value = 0;
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack();
|
|
||||||
}, 2000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.redirectTo({
|
|
||||||
url: "/pages/battle-result?battleId=" + msg.matchId,
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onReceiveMessage(messages = []) {
|
||||||
|
messages.forEach((msg) => {
|
||||||
|
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
|
||||||
|
redTeam.value = msg.groupUserStatus.redTeam;
|
||||||
|
blueTeam.value = msg.groupUserStatus.blueTeam;
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.AllReady) {
|
||||||
|
start.value = true;
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.ToSomeoneShoot) {
|
||||||
|
if (currentShooterId.value !== msg.userId) {
|
||||||
|
currentShooterId.value = msg.userId;
|
||||||
|
const redPlayer = redTeam.value.find(
|
||||||
|
(item) => item.id === currentShooterId.value
|
||||||
|
);
|
||||||
|
|
||||||
|
let nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
|
||||||
|
if (msg.userId === user.value.id && redTeam.value.length > 1) {
|
||||||
|
nextTips += "你";
|
||||||
|
}
|
||||||
|
if (nextTips !== tips.value) {
|
||||||
|
tips.value = nextTips;
|
||||||
|
uni.$emit("update-tips", tips.value);
|
||||||
|
} else {
|
||||||
|
uni.$emit("update-ramain", 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
|
if (msg.battleInfo) recoverData(msg.battleInfo);
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||||
|
const result = msg.preRoundResult;
|
||||||
|
scores.value = [];
|
||||||
|
blueScores.value = [];
|
||||||
|
currentShooterId.value = 0;
|
||||||
|
currentBluePoint.value = result.blueScore;
|
||||||
|
currentRedPoint.value = result.redScore;
|
||||||
|
bluePoints.value += result.blueScore;
|
||||||
|
redPoints.value += result.redScore;
|
||||||
|
if (!result.goldenRound) {
|
||||||
|
showRoundTip.value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||||
|
currentShooterId.value = 0;
|
||||||
|
currentBluePoint.value = bluePoints.value;
|
||||||
|
currentRedPoint.value = redPoints.value;
|
||||||
|
if (!isFinalShoot.value) {
|
||||||
|
isFinalShoot.value = true;
|
||||||
|
showRoundTip.value = true;
|
||||||
|
tips.value = "准备开始决金箭";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
if (msg.endStatus.noSaved) {
|
||||||
|
currentBluePoint.value = 0;
|
||||||
|
currentRedPoint.value = 0;
|
||||||
|
showRoundTip.value = true;
|
||||||
|
isFinalShoot.value = false;
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack();
|
||||||
|
}, 3000);
|
||||||
|
} else {
|
||||||
|
isEnded.value = true;
|
||||||
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/battle-result",
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||||
|
uni.$emit("update-header-loading", false);
|
||||||
|
if (msg.battleInfo) recoverData(msg.battleInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.battleId) battleId.value = options.battleId;
|
if (options.battleId) {
|
||||||
// uni.enableAlertBeforeUnload({
|
battleId.value = options.battleId;
|
||||||
// message: "离开比赛可能导致比赛失败,是否继续?",
|
redTeam.value = uni.getStorageSync("red-team");
|
||||||
// success: (res) => {
|
blueTeam.value = uni.getStorageSync("blue-team");
|
||||||
// console.log("已启用离开提示");
|
const battleInfo = uni.getStorageSync("current-battle");
|
||||||
// },
|
if (battleInfo) {
|
||||||
// });
|
await nextTick(() => {
|
||||||
|
recoverData(battleInfo);
|
||||||
|
});
|
||||||
|
setTimeout(getCurrentGameAPI, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uni.enableAlertBeforeUnload({
|
||||||
|
message: "离开比赛可能导致比赛失败,是否继续?",
|
||||||
|
success: (res) => {
|
||||||
|
console.log("已启用离开提示");
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
@@ -161,31 +301,30 @@ onBeforeUnmount(() => {
|
|||||||
const refreshTimer = ref(null);
|
const refreshTimer = ref(null);
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
if (battleId.value) {
|
if (battleId.value) {
|
||||||
const result = await getBattleAPI(battleId.value);
|
if (!isEnded.value && (await isGameEnded(battleId.value))) return;
|
||||||
if (result.status === 2) {
|
getCurrentGameAPI();
|
||||||
uni.showToast({
|
const refreshData = () => {
|
||||||
title: "比赛已结束",
|
const lastAwakeTime = uni.getStorageSync("last-awake-time");
|
||||||
icon: "none",
|
if (lastAwakeTime) {
|
||||||
});
|
getCurrentGameAPI();
|
||||||
uni.navigateBack({
|
|
||||||
delta: 2,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
recoverData(result, { force: true });
|
clearInterval(refreshTimer.value);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
refreshTimer.value = setInterval(refreshData, 2000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
onHide(() => {
|
||||||
|
if (refreshTimer.value) clearInterval(refreshTimer.value);
|
||||||
|
uni.setStorageSync("last-awake-time", Date.now());
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Container :bgType="start ? 3 : 1">
|
<Container :bgType="start ? 3 : 1">
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<BattleHeader
|
<BattleHeader v-if="!start" :redTeam="redTeam" :blueTeam="blueTeam" />
|
||||||
v-if="start === false"
|
<TestDistance v-if="!start" :guide="false" :isBattle="true" />
|
||||||
:redTeam="redTeam"
|
|
||||||
:blueTeam="blueTeam"
|
|
||||||
/>
|
|
||||||
<TestDistance v-if="start === false" :guide="false" :isBattle="true" />
|
|
||||||
<view v-if="start" class="players-row">
|
<view v-if="start" class="players-row">
|
||||||
<TeamAvatars
|
<TeamAvatars
|
||||||
:team="blueTeam"
|
:team="blueTeam"
|
||||||
|
|||||||
@@ -5,42 +5,105 @@ import Container from "@/components/Container.vue";
|
|||||||
import BowTarget from "@/components/BowTarget.vue";
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import { roundsName } from "@/constants";
|
import { roundsName } from "@/constants";
|
||||||
import { getBattleAPI } from "@/apis";
|
import { getGameAPI } from "@/apis";
|
||||||
const selected = ref(0);
|
const selected = ref(0);
|
||||||
const redScores = ref([]);
|
const redScores = ref([]);
|
||||||
const blueScores = ref([]);
|
const blueScores = ref([]);
|
||||||
const tabs = ref([]);
|
const tabs = ref(["所有轮次"]);
|
||||||
const players = ref([]);
|
const players = ref([]);
|
||||||
const data = ref({});
|
const allRoundsScore = ref({});
|
||||||
|
const data = ref({
|
||||||
const loadArrows = (round) => {
|
goldenRounds: [],
|
||||||
round.shoots[1].forEach((arrow) => {
|
});
|
||||||
blueScores.value.push(arrow);
|
|
||||||
});
|
|
||||||
round.shoots[2].forEach((arrow) => {
|
|
||||||
redScores.value.push(arrow);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (!options.battleId) return;
|
if (options.battleId) {
|
||||||
const result = await getBattleAPI(options.battleId || "57943107462893568");
|
const result = await getGameAPI(
|
||||||
|
options.battleId || "BATTLE-1756453741433684760-512"
|
||||||
|
);
|
||||||
data.value = result;
|
data.value = result;
|
||||||
data.value.teams[1].players.forEach((p, index) => {
|
Object.values(result.bluePlayers).forEach((p, index) => {
|
||||||
players.value.push(p);
|
players.value.push(p);
|
||||||
players.value.push(data.value.teams[2].players[index]);
|
if (
|
||||||
|
Object.values(result.redPlayers) &&
|
||||||
|
Object.values(result.redPlayers)[index]
|
||||||
|
) {
|
||||||
|
players.value.push(Object.values(result.redPlayers)[index]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Object.values(data.value.rounds).forEach((round, index) => {
|
if (result.goldenRounds) {
|
||||||
if (round.ifGold) tabs.value.push(`决金箭`);
|
result.goldenRounds.forEach(() => {
|
||||||
else tabs.value.push(`第${roundsName[index + 1]}轮`);
|
tabs.value.push("决金箭");
|
||||||
});
|
});
|
||||||
selected.value = Number(options.selected || 0);
|
}
|
||||||
onClickTab(selected.value);
|
Object.keys(result.roundsData).forEach((key, index) => {
|
||||||
|
if (
|
||||||
|
index <
|
||||||
|
Object.keys(result.roundsData).length - result.goldenRounds.length
|
||||||
|
) {
|
||||||
|
tabs.value.push(`第${roundsName[key]}轮`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
onClickTab(0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const onClickTab = (index) => {
|
const onClickTab = (index) => {
|
||||||
selected.value = index;
|
selected.value = index;
|
||||||
redScores.value = [];
|
redScores.value = [];
|
||||||
blueScores.value = [];
|
blueScores.value = [];
|
||||||
loadArrows(data.value.rounds[index]);
|
const { bluePlayers, redPlayers, roundsData, goldenRounds } = data.value;
|
||||||
|
let maxArrowLength = 0;
|
||||||
|
if (index === 0) {
|
||||||
|
Object.keys(bluePlayers).forEach((p) => {
|
||||||
|
allRoundsScore.value[p] = [];
|
||||||
|
Object.values(roundsData).forEach((round) => {
|
||||||
|
if (!round[p]) return;
|
||||||
|
allRoundsScore.value[p].push(
|
||||||
|
round[p].reduce((last, next) => last + next.ring, 0)
|
||||||
|
);
|
||||||
|
round[p].forEach((arrow) => {
|
||||||
|
blueScores.value.push(arrow);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Object.keys(redPlayers).forEach((p) => {
|
||||||
|
allRoundsScore.value[p] = [];
|
||||||
|
Object.values(roundsData).forEach((round) => {
|
||||||
|
if (!round[p]) return;
|
||||||
|
allRoundsScore.value[p].push(
|
||||||
|
round[p].reduce((last, next) => last + next.ring, 0)
|
||||||
|
);
|
||||||
|
round[p].forEach((arrow) => {
|
||||||
|
redScores.value.push(arrow);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (index <= goldenRounds.length) {
|
||||||
|
const dataIndex =
|
||||||
|
Object.keys(roundsData).length - goldenRounds.length + index;
|
||||||
|
Object.keys(bluePlayers).forEach((p) => {
|
||||||
|
if (!roundsData[dataIndex][p]) return;
|
||||||
|
roundsData[dataIndex][p].forEach((arrow) => {
|
||||||
|
blueScores.value.push(arrow);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Object.keys(redPlayers).forEach((p) => {
|
||||||
|
if (!roundsData[dataIndex][p]) return;
|
||||||
|
roundsData[dataIndex][p].forEach((arrow) => {
|
||||||
|
redScores.value.push(arrow);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Object.keys(bluePlayers).forEach((p) => {
|
||||||
|
roundsData[index - goldenRounds.length][p].forEach((arrow) => {
|
||||||
|
blueScores.value.push(arrow);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Object.keys(redPlayers).forEach((p) => {
|
||||||
|
roundsData[index - goldenRounds.length][p].forEach((arrow) => {
|
||||||
|
redScores.value.push(arrow);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -71,18 +134,45 @@ const onClickTab = (index) => {
|
|||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
:src="player.avatar"
|
:src="player.avatar"
|
||||||
:borderColor="index % 2 === 0 ? '#64BAFF' : '#FF6767'"
|
:borderColor="
|
||||||
|
data.bluePlayers[player.playerId] ? '#64BAFF' : '#FF6767'
|
||||||
|
"
|
||||||
:size="36"
|
:size="36"
|
||||||
/>
|
/>
|
||||||
<view>
|
<view>
|
||||||
<view
|
<view
|
||||||
v-for="(score, index) in data.rounds[selected].shoots[
|
v-if="selected === 0"
|
||||||
index % 2 === 0 ? 1 : 2
|
v-for="(ring, index) in allRoundsScore[player.playerId]"
|
||||||
]"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
class="score-item"
|
class="score-item"
|
||||||
>
|
>
|
||||||
{{ score.ringX ? "X" : score.ring }}
|
{{ ring }}
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-if="
|
||||||
|
selected > 0 &&
|
||||||
|
selected >= data.goldenRounds.length &&
|
||||||
|
selected <= data.goldenRounds.length
|
||||||
|
"
|
||||||
|
v-for="(score, index) in data.roundsData[
|
||||||
|
Object.keys(data.roundsData).length -
|
||||||
|
data.goldenRounds.length +
|
||||||
|
selected
|
||||||
|
][player.playerId]"
|
||||||
|
:key="index"
|
||||||
|
class="score-item"
|
||||||
|
>
|
||||||
|
{{ score.ring }}
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-if="selected > data.goldenRounds.length"
|
||||||
|
v-for="(score, index) in data.roundsData[
|
||||||
|
selected - data.goldenRounds.length
|
||||||
|
][player.playerId]"
|
||||||
|
:key="index"
|
||||||
|
class="score-item"
|
||||||
|
>
|
||||||
|
{{ score.ring }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
BIN
src/static/announce.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
src/static/dashen.png
Normal file
|
After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 21 KiB |
BIN
src/static/nvshen.png
Normal file
|
After Width: | Height: | Size: 691 B |
BIN
src/static/player-1.png
Normal file
|
After Width: | Height: | Size: 594 B |
BIN
src/static/player-10.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/static/player-2.png
Normal file
|
After Width: | Height: | Size: 869 B |
BIN
src/static/player-3.png
Normal file
|
After Width: | Height: | Size: 723 B |
BIN
src/static/player-4.png
Normal file
|
After Width: | Height: | Size: 815 B |
BIN
src/static/player-5.png
Normal file
|
After Width: | Height: | Size: 704 B |
BIN
src/static/player-6.png
Normal file
|
After Width: | Height: | Size: 895 B |
BIN
src/static/player-7.png
Normal file
|
After Width: | Height: | Size: 641 B |
BIN
src/static/player-8.png
Normal file
|
After Width: | Height: | Size: 915 B |
BIN
src/static/player-9.png
Normal file
|
After Width: | Height: | Size: 893 B |
BIN
src/static/race-title-bg.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
src/static/rank-title.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 555 B |
BIN
src/static/tab-medal.png
Normal file
|
After Width: | Height: | Size: 644 B |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 4.9 KiB |
BIN
src/static/tab-user.png
Normal file
|
After Width: | Height: | Size: 614 B |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 656 B |
BIN
src/static/trophy-bg.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/static/xinren.png
Normal file
|
After Width: | Height: | Size: 707 B |
23
src/util.js
@@ -1,3 +1,5 @@
|
|||||||
|
import { getUserGameState, getGameAPI } from "@/apis";
|
||||||
|
|
||||||
export const formatTimestamp = (timestamp) => {
|
export const formatTimestamp = (timestamp) => {
|
||||||
const date = new Date(timestamp * 1000);
|
const date = new Date(timestamp * 1000);
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
@@ -87,6 +89,27 @@ export const wxShare = async (canvasId = "shareCanvas") => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isGameEnded = async (battleId) => {
|
||||||
|
const state = await getUserGameState();
|
||||||
|
if (!state.gaming) {
|
||||||
|
const result = await getGameAPI(battleId);
|
||||||
|
if (result.mode) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/battle-result?battleId=${battleId}`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: "比赛已结束",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !state.gaming;
|
||||||
|
};
|
||||||
|
|
||||||
// 获取元素尺寸和位置信息
|
// 获取元素尺寸和位置信息
|
||||||
export const getElementRect = (classname) => {
|
export const getElementRect = (classname) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ function createWebSocket(token, onMessage) {
|
|||||||
|
|
||||||
switch (envVersion) {
|
switch (envVersion) {
|
||||||
case "develop": // 开发版
|
case "develop": // 开发版
|
||||||
url = "ws://localhost:8000/socket";
|
// url = "ws://192.168.1.242:8000/socket";
|
||||||
// url = "wss://apitest.shelingxingqiu.com/socket";
|
url = "wss://apitest.shelingxingqiu.com/socket";
|
||||||
break;
|
break;
|
||||||
case "trial": // 体验版
|
case "trial": // 体验版
|
||||||
url = "wss://apitest.shelingxingqiu.com/socket";
|
url = "wss://apitest.shelingxingqiu.com/socket";
|
||||||
@@ -45,18 +45,37 @@ function createWebSocket(token, onMessage) {
|
|||||||
|
|
||||||
// 接收消息
|
// 接收消息
|
||||||
uni.onSocketMessage((res) => {
|
uni.onSocketMessage((res) => {
|
||||||
const { data, event } = JSON.parse(res.data);
|
const data = JSON.parse(res.data);
|
||||||
if (event === "pong") return;
|
if (data.event === "pong" || !data.data.updates) return;
|
||||||
if (data.type) {
|
if (onMessage) onMessage(data.data.updates);
|
||||||
console.log("收到消息:", getMessageTypeName(data.type), data.data);
|
const msg = data.data.updates[0];
|
||||||
if (onMessage) onMessage({ ...(data.data || {}), type: data.type });
|
if (!msg) return;
|
||||||
|
console.log("收到消息:", getMessageTypeName(msg.constructor), msg);
|
||||||
|
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
const currentPage = pages[pages.length - 1];
|
||||||
|
if (
|
||||||
|
currentPage.route === "pages/battle-room" ||
|
||||||
|
currentPage.route === "pages/team-battle" ||
|
||||||
|
currentPage.route === "pages/melee-match"
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (onMessage && data.updates) onMessage(data.updates);
|
const { battleInfo } = msg;
|
||||||
const msg = data.updates[0];
|
uni.setStorageSync("current-battle", battleInfo);
|
||||||
if (msg) {
|
// console.log("----battleInfo", battleInfo);
|
||||||
console.log("收到消息:", getMessageTypeName(msg.constructor), msg);
|
if (battleInfo.config.mode === 1) {
|
||||||
if (msg.constructor === MESSAGETYPES.RankUpdate) {
|
uni.navigateTo({
|
||||||
|
url: `/pages/team-battle?battleId=${battleInfo.id}&gameMode=${battleInfo.config.battleMode}`,
|
||||||
|
});
|
||||||
|
} else if (battleInfo.config.mode === 2) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/melee-match?battleId=${battleInfo.id}&gameMode=${battleInfo.config.battleMode}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
uni.$emit("game-over");
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.RankUpdate) {
|
||||||
uni.setStorageSync("latestRank", msg.lvl);
|
uni.setStorageSync("latestRank", msg.lvl);
|
||||||
} else if (msg.constructor === MESSAGETYPES.LvlUpdate) {
|
} else if (msg.constructor === MESSAGETYPES.LvlUpdate) {
|
||||||
uni.setStorageSync("latestLvl", msg.lvl);
|
uni.setStorageSync("latestLvl", msg.lvl);
|
||||||
@@ -65,7 +84,6 @@ function createWebSocket(token, onMessage) {
|
|||||||
} else if (msg.constructor === MESSAGETYPES.DeviceOffline) {
|
} else if (msg.constructor === MESSAGETYPES.DeviceOffline) {
|
||||||
uni.$emit("update-online");
|
uni.$emit("update-online");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 错误处理
|
// 错误处理
|
||||||
|
|||||||