BUG修复

This commit is contained in:
kron
2025-07-13 21:06:48 +08:00
parent fa959c73aa
commit d73d52f752
4 changed files with 83 additions and 17 deletions

View File

@@ -106,7 +106,7 @@ onUnmounted(() => {
<view class="container">
<view>
<image src="../static/shooter.png" mode="widthFix" />
<text>{{ start && remain === 0 ? "射箭时间到!" : tips }}</text>
<text>{{ start && remain === 0 ? "时间到!" : tips }}</text>
<button hover-class="none" @click="() => (sound = !sound)">
<image
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"

View File

@@ -77,20 +77,71 @@ onLoad(async (options) => {
if (battleInfo) {
battleId.value = battleInfo.id;
start.value = true;
redTeam.value = battleInfo.redTeam;
blueTeam.value = battleInfo.blueTeam;
currentRound.value = battleInfo.currentRound;
bluePoints.value = battleInfo.blueScore;
redPoints.value = battleInfo.redScore;
totalRounds.value = battleInfo.maxRound;
roundResults.value = battleInfo.roundResults;
currentShooterId.value = battleInfo.firePlayerIndex;
const remain = Date.now() / 1000 - battleInfo.fireTime;
if (remain > 0 && remain < 15) {
// 等渲染好再通知
setTimeout(() => {
uni.$emit("update-ramain", remain);
}, 300);
if (battleInfo.config.mode === 1) {
redTeam.value = battleInfo.redTeam;
blueTeam.value = battleInfo.blueTeam;
currentRound.value = battleInfo.currentRound;
bluePoints.value = battleInfo.blueScore;
redPoints.value = battleInfo.redScore;
totalRounds.value = battleInfo.maxRound;
roundResults.value = battleInfo.roundResults;
currentShooterId.value = battleInfo.firePlayerIndex;
if (
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
) {
roundResults.value.push({
redArrows:
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound],
blueArrows:
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound],
});
} else if (battleInfo.currentRound < 5) {
roundResults.value.push({
redArrows: [],
blueArrows: [],
});
}
if (battleInfo.firePlayerIndex) {
currentShooterId.value = battleInfo.firePlayerIndex;
if (redTeam.value[0].id === currentShooterId.value) {
tips.value = `请红队射箭-第${roundsName[currentRound.value]}`;
} else {
tips.value = `请蓝队射箭-第${roundsName[currentRound.value]}`;
}
}
const remain = Date.now() / 1000 - battleInfo.fireTime;
if (remain > 0 && remain < 15) {
// 等渲染好再通知
setTimeout(() => {
uni.$emit("update-ramain", remain);
}, 300);
}
} else if (battleInfo.config.mode === 2) {
tips.value = "请连续射出6支箭";
players.value = [...battleInfo.blueTeam, ...battleInfo.redTeam];
players.value.forEach((p) => {
playersScores.value[p.id] = p.arrows;
});
if (battleInfo.startTime) {
const remain = Date.now() / 1000 - battleInfo.startTime;
if (remain <= 90) {
setTimeout(() => {
uni.$emit("update-ramain", remain);
}, 300);
} else if (remain > 90 && remain <= 110) {
halfTimeTip.value = true;
countDown.value = 20;
tips.value = "准备下半场";
setTimeout(() => {
uni.$emit("update-ramain", 110 - remain);
}, 300);
} else if (remain > 110) {
setTimeout(() => {
uni.$emit("update-ramain", remain - 110);
}, 300);
}
}
}
}
}

View File

@@ -55,7 +55,7 @@ watch(
onLoad(async (options) => {
if (options.battleId) {
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
// console.log("----battleInfo", battleInfo);
console.log("----battleInfo", battleInfo);
if (battleInfo) {
battleId.value = battleInfo.id;
start.value = true;

View File

@@ -47,7 +47,7 @@ const isFinalShoot = ref(false);
onLoad(async (options) => {
if (options.battleId) {
const battleInfo = uni.getStorageSync(`battle-${options.battleId}`);
console.log("----battleInfo", battleInfo);
// console.log("----battleInfo", battleInfo);
if (battleInfo) {
battleId.value = battleInfo.id;
start.value = true;
@@ -58,6 +58,21 @@ onLoad(async (options) => {
redPoints.value = battleInfo.redScore;
totalRounds.value = battleInfo.maxRound;
roundResults.value = battleInfo.roundResults;
if (
battleInfo.redTeam[0].shotHistory[battleInfo.currentRound] ||
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound]
) {
roundResults.value.push({
redArrows: battleInfo.redTeam[0].shotHistory[battleInfo.currentRound],
blueArrows:
battleInfo.blueTeam[0].shotHistory[battleInfo.currentRound],
});
} else if (battleInfo.currentRound < 5) {
roundResults.value.push({
redArrows: [],
blueArrows: [],
});
}
if (battleInfo.firePlayerIndex) {
currentShooterId.value = battleInfo.firePlayerIndex;
if (redTeam.value[0].id === currentShooterId.value) {