比赛结果数据源修改
This commit is contained in:
@@ -10,47 +10,61 @@ const store = useStore();
|
|||||||
const { user } = storeToRefs(store);
|
const { user } = storeToRefs(store);
|
||||||
const { updateUser, getLvlName } = store;
|
const { updateUser, getLvlName } = store;
|
||||||
|
|
||||||
const battleId = ref("");
|
|
||||||
const ifWin = ref(false);
|
const ifWin = ref(false);
|
||||||
const data = ref({});
|
const data = ref({});
|
||||||
const totalPoints = ref(0);
|
const totalPoints = ref(0);
|
||||||
|
|
||||||
onLoad(async (options) => {
|
// onLoad(async (options) => {
|
||||||
battleId.value = options.battleId;
|
// battleId.value = options.battleId;
|
||||||
const result = await getGameAPI(
|
// const result = await getGameAPI(
|
||||||
// options.battleId || "BATTLE-1750867490990424058-718"
|
// // options.battleId || "BATTLE-1750867490990424058-718"
|
||||||
options.battleId || "BATTLE-1752563964391008873-624"
|
// options.battleId || "BATTLE-1752563964391008873-624"
|
||||||
);
|
// );
|
||||||
data.value = result;
|
// data.value = result;
|
||||||
if (result.mode === 1 && result.redPlayers[user.value.id]) {
|
// if (result.mode === 1 && result.redPlayers[user.value.id]) {
|
||||||
totalPoints.value = result.redPlayers[user.value.id].totalScore;
|
// totalPoints.value = result.redPlayers[user.value.id].totalScore;
|
||||||
ifWin.value = result.winner === 0;
|
// ifWin.value = result.winner === 0;
|
||||||
}
|
// }
|
||||||
if (result.mode === 1 && result.bluePlayers[user.value.id]) {
|
// if (result.mode === 1 && result.bluePlayers[user.value.id]) {
|
||||||
totalPoints.value = result.bluePlayers[user.value.id].totalScore;
|
// totalPoints.value = result.bluePlayers[user.value.id].totalScore;
|
||||||
ifWin.value = result.winner === 1;
|
// ifWin.value = result.winner === 1;
|
||||||
}
|
// }
|
||||||
if (result.mode === 2) {
|
// if (result.mode === 2) {
|
||||||
const mine = result.players.find((p) => p.playerId === user.value.id);
|
// const mine = result.players.find((p) => p.playerId === user.value.id);
|
||||||
if (mine) totalPoints.value = mine.totalScore;
|
// if (mine) totalPoints.value = mine.totalScore;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
function exit() {
|
function exit() {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const result = await getHomeData();
|
const battleInfo = uni.getStorageSync("last-battle");
|
||||||
if (result.user) updateUser(result.user);
|
console.log("----battleInfo", battleInfo);
|
||||||
|
data.value = battleInfo;
|
||||||
|
if (battleInfo.mode === 1) {
|
||||||
|
battleInfo.playerStats.forEach((p) => {
|
||||||
|
if (p.id === user.value.id) {
|
||||||
|
totalPoints.value = p.totalScore;
|
||||||
|
if (p.team === battleInfo.winner) ifWin.value = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (battleInfo.mode === 2) {
|
||||||
|
const mine = battleInfo.playerStats.find((p) => p.id === user.value.id);
|
||||||
|
if (mine) totalPoints.value = mine.totalScore;
|
||||||
|
}
|
||||||
|
// const result = await getHomeData();
|
||||||
|
// if (result.user) updateUser(result.user);
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkBowData = () => {
|
const checkBowData = () => {
|
||||||
if (data.value.mode === 1) {
|
if (data.value.mode === 1) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/team-bow-data?battleId=${battleId.value}`,
|
url: `/pages/team-bow-data?battleId=${data.value.id}`,
|
||||||
});
|
});
|
||||||
} else if (data.value.mode === 2) {
|
} else if (data.value.mode === 2) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/melee-bow-data?battleId=${battleId.value}`,
|
url: `/pages/melee-bow-data?battleId=${data.value.id}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -84,14 +98,14 @@ const checkBowData = () => {
|
|||||||
<view
|
<view
|
||||||
class="players"
|
class="players"
|
||||||
:style="{
|
:style="{
|
||||||
height: `${Math.max(data.players.length > 5 ? '330' : '300')}px`,
|
height: `${Math.max(data.playerStats.length > 5 ? '330' : '300')}px`,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
v-for="(player, index) in data.players"
|
v-for="(player, index) in data.playerStats"
|
||||||
:key="index"
|
:key="index"
|
||||||
:style="{
|
:style="{
|
||||||
border: player.playerId === user.id ? '1px solid #B04630' : 'none',
|
border: player.id === user.id ? '1px solid #B04630' : 'none',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<image
|
<image
|
||||||
@@ -150,10 +164,10 @@ const checkBowData = () => {
|
|||||||
<view class="battle-e">
|
<view class="battle-e">
|
||||||
<image src="../static/row-yellow-bg.png" mode="widthFix" />
|
<image src="../static/row-yellow-bg.png" mode="widthFix" />
|
||||||
<Avatar v-if="data.mode === 1" :src="user.avatar" :size="40" />
|
<Avatar v-if="data.mode === 1" :src="user.avatar" :size="40" />
|
||||||
<text v-if="data.gameMode === 1"
|
<text v-if="data.battleMode === 1"
|
||||||
>经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}</text
|
>经验 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}</text
|
||||||
>
|
>
|
||||||
<text v-if="data.gameMode === 2"
|
<text v-if="data.battleMode === 2"
|
||||||
>积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}</text
|
>积分 {{ totalPoints > 0 ? "+" + totalPoints : totalPoints }}</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ watch(
|
|||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.battleId) {
|
if (options.battleId) {
|
||||||
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
const battleInfo = uni.getStorageSync("current-battle");
|
||||||
// console.log("----battleInfo", battleInfo);
|
console.log("----battleInfo", battleInfo);
|
||||||
if (battleInfo) {
|
if (battleInfo) {
|
||||||
battleId.value = battleInfo.id;
|
battleId.value = battleInfo.id;
|
||||||
start.value = true;
|
start.value = true;
|
||||||
@@ -406,7 +406,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
tips.value = "准备下半场";
|
tips.value = "准备下半场";
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
uni.setStorageSync("battle", msg.endStatus);
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/battle-result?battleId=${msg.id}`,
|
url: `/pages/battle-result?battleId=${msg.id}`,
|
||||||
});
|
});
|
||||||
@@ -541,10 +541,10 @@ onUnmounted(() => {
|
|||||||
:total="total"
|
:total="total"
|
||||||
:currentRound="currentRound"
|
:currentRound="currentRound"
|
||||||
:battleId="battleId"
|
:battleId="battleId"
|
||||||
:melee="room.battleType === 2"
|
:melee="players.length > 0"
|
||||||
/>
|
/>
|
||||||
<PlayersRow
|
<PlayersRow
|
||||||
v-if="room.battleType === 1"
|
v-if="blueTeam.length && redTeam.length"
|
||||||
:blueTeam="blueTeam"
|
:blueTeam="blueTeam"
|
||||||
:redTeam="redTeam"
|
:redTeam="redTeam"
|
||||||
:currentShooterId="currentShooterId"
|
:currentShooterId="currentShooterId"
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ const comingSoon = () => {
|
|||||||
<view class="feature-grid">
|
<view class="feature-grid">
|
||||||
<view class="bow-card">
|
<view class="bow-card">
|
||||||
<image
|
<image
|
||||||
src="https://api.shelingxingqiu.com/attachment/2025-07-15/dbci3g2g77tbxnujdl.webp"
|
src="https://api.shelingxingqiu.com/attachment/2025-07-15/dbciq9qhkpd3pqxawo.webp"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click="() => toPage('/pages/my-device')"
|
@click="() => toPage('/pages/my-device')"
|
||||||
/>
|
/>
|
||||||
@@ -343,12 +343,13 @@ const comingSoon = () => {
|
|||||||
|
|
||||||
.player-avatar,
|
.player-avatar,
|
||||||
.more-players {
|
.more-players {
|
||||||
width: 80rpx;
|
width: 82rpx;
|
||||||
height: 80rpx;
|
height: 82rpx;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-right: -10px;
|
margin-right: -10px;
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.player-avatar > image:first-child,
|
.player-avatar > image:first-child,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const { user } = storeToRefs(store);
|
|||||||
const gameType = ref(0);
|
const gameType = ref(0);
|
||||||
const teamSize = ref(0);
|
const teamSize = ref(0);
|
||||||
const start = ref(false);
|
const start = ref(false);
|
||||||
const countDown = ref(90);
|
const startCount = ref(false);
|
||||||
const battleId = ref("");
|
const battleId = ref("");
|
||||||
const currentRound = ref(1);
|
const currentRound = ref(1);
|
||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
@@ -35,6 +35,7 @@ const playersSorted = ref([]);
|
|||||||
const playersScores = ref({});
|
const playersScores = ref({});
|
||||||
const halfTimeTip = ref(false);
|
const halfTimeTip = ref(false);
|
||||||
const onComplete = ref(null);
|
const onComplete = ref(null);
|
||||||
|
const total = ref(90);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [players.value, playersScores.value],
|
() => [players.value, playersScores.value],
|
||||||
@@ -53,7 +54,7 @@ watch(
|
|||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.battleId) {
|
if (options.battleId) {
|
||||||
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
const battleInfo = uni.getStorageSync("current-battle");
|
||||||
console.log("----battleInfo", battleInfo);
|
console.log("----battleInfo", battleInfo);
|
||||||
if (battleInfo) {
|
if (battleInfo) {
|
||||||
battleId.value = battleInfo.id;
|
battleId.value = battleInfo.id;
|
||||||
@@ -71,7 +72,7 @@ onLoad(async (options) => {
|
|||||||
}, 300);
|
}, 300);
|
||||||
} else if (remain > 90 && remain <= 110) {
|
} else if (remain > 90 && remain <= 110) {
|
||||||
halfTimeTip.value = true;
|
halfTimeTip.value = true;
|
||||||
countDown.value = 20;
|
total.value = 20;
|
||||||
tips.value = "准备下半场";
|
tips.value = "准备下半场";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.$emit("update-ramain", 110 - remain);
|
uni.$emit("update-ramain", 110 - remain);
|
||||||
@@ -129,11 +130,12 @@ async function onReceiveMessage(messages = []) {
|
|||||||
if (msg.id !== battleId.value) return;
|
if (msg.id !== battleId.value) return;
|
||||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||||
start.value = true;
|
start.value = true;
|
||||||
|
startCount.value = true;
|
||||||
seq.value += 1;
|
seq.value += 1;
|
||||||
timerSeq.value = 0;
|
timerSeq.value = 0;
|
||||||
tips.value = "请连续射出6支箭";
|
tips.value = "请连续射出6支箭";
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
countDown.value = 90;
|
total.value = 90;
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
if (msg.userId === user.value.id) {
|
if (msg.userId === user.value.id) {
|
||||||
@@ -143,11 +145,13 @@ async function onReceiveMessage(messages = []) {
|
|||||||
playersScores.value[msg.userId].push(msg.target);
|
playersScores.value[msg.userId].push(msg.target);
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||||
|
startCount.value = false;
|
||||||
halfTimeTip.value = true;
|
halfTimeTip.value = true;
|
||||||
countDown.value = 20;
|
total.value = 20;
|
||||||
tips.value = "准备下半场";
|
tips.value = "准备下半场";
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/battle-result?battleId=${msg.id}`,
|
url: `/pages/battle-result?battleId=${msg.id}`,
|
||||||
});
|
});
|
||||||
@@ -192,9 +196,9 @@ onUnmounted(() => {
|
|||||||
<ShootProgress
|
<ShootProgress
|
||||||
v-if="start"
|
v-if="start"
|
||||||
:seq="seq"
|
:seq="seq"
|
||||||
:start="start"
|
:start="start && startCount"
|
||||||
:tips="tips"
|
:tips="tips"
|
||||||
:total="countDown"
|
:total="total"
|
||||||
:melee="true"
|
:melee="true"
|
||||||
/>
|
/>
|
||||||
<view v-if="start" class="user-row">
|
<view v-if="start" class="user-row">
|
||||||
@@ -207,6 +211,7 @@ onUnmounted(() => {
|
|||||||
:currentRound="scores.length"
|
:currentRound="scores.length"
|
||||||
:totalRound="start ? 12 : 0"
|
:totalRound="start ? 12 : 0"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
|
:stop="halfTimeTip && !startCount"
|
||||||
/>
|
/>
|
||||||
<view :style="{ paddingBottom: '20px' }">
|
<view :style="{ paddingBottom: '20px' }">
|
||||||
<PlayerScore
|
<PlayerScore
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const isFinalShoot = ref(false);
|
|||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
if (options.battleId) {
|
if (options.battleId) {
|
||||||
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
|
const battleInfo = uni.getStorageSync("current-battle");
|
||||||
// console.log("----battleInfo", battleInfo);
|
// console.log("----battleInfo", battleInfo);
|
||||||
if (battleInfo) {
|
if (battleInfo) {
|
||||||
battleId.value = battleInfo.id;
|
battleId.value = battleInfo.id;
|
||||||
@@ -203,6 +203,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/battle-result?battleId=${msg.id}`,
|
url: `/pages/battle-result?battleId=${msg.id}`,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function createWebSocket(token, onMessage) {
|
|||||||
if (!msg) return;
|
if (!msg) return;
|
||||||
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||||
const { battleInfo } = msg;
|
const { battleInfo } = msg;
|
||||||
uni.setStorageSync(`battle-${battleInfo.id}`, battleInfo);
|
uni.setStorageSync("current-battle", battleInfo);
|
||||||
// 约战
|
// 约战
|
||||||
if (battleInfo.config.battleMode === 1) {
|
if (battleInfo.config.battleMode === 1) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
|
|||||||
Reference in New Issue
Block a user