修复BUG
This commit is contained in:
@@ -49,21 +49,11 @@ const props = defineProps({
|
||||
|
||||
const showsimul = ref(false);
|
||||
const latestOne = ref(null);
|
||||
const bluelatestOne = ref(null);
|
||||
const prevScores = ref([]);
|
||||
const prevBlueScores = ref([]);
|
||||
// const startCount = ref(false);
|
||||
const timer = ref(null);
|
||||
|
||||
// watch(
|
||||
// () => props.start,
|
||||
// (newVal) => {
|
||||
// startCount.value = newVal;
|
||||
// },
|
||||
// {
|
||||
// immediate: true,
|
||||
// }
|
||||
// );
|
||||
|
||||
watch(
|
||||
() => props.scores,
|
||||
(newVal) => {
|
||||
@@ -85,10 +75,10 @@ watch(
|
||||
() => props.blueScores,
|
||||
(newVal) => {
|
||||
if (newVal.length - prevBlueScores.value.length === 1) {
|
||||
latestOne.value = newVal[newVal.length - 1];
|
||||
bluelatestOne.value = newVal[newVal.length - 1];
|
||||
if (timer.value) clearTimeout(timer.value);
|
||||
timer.value = setTimeout(() => {
|
||||
latestOne.value = null;
|
||||
bluelatestOne.value = null;
|
||||
}, 1000);
|
||||
}
|
||||
prevBlueScores.value = [...newVal];
|
||||
@@ -176,7 +166,7 @@ onMounted(() => {
|
||||
<view
|
||||
v-if="bow.ring > 0"
|
||||
:class="`hit ${
|
||||
index === blueScores.length - 1 && latestOne ? 'pump-in' : ''
|
||||
index === blueScores.length - 1 && bluelatestOne ? 'pump-in' : ''
|
||||
}`"
|
||||
:style="{
|
||||
left: calcRealX(bow.x),
|
||||
|
||||
@@ -44,30 +44,75 @@ const props = defineProps({
|
||||
const showHint = ref(false);
|
||||
const hintType = ref(0);
|
||||
const capsuleHeight = ref(0);
|
||||
const isLoading = ref(false);
|
||||
|
||||
const showGlobalHint = (type) => {
|
||||
hintType.value = type;
|
||||
showHint.value = true;
|
||||
};
|
||||
|
||||
const hideGlobalHint = () => {
|
||||
showHint.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
|
||||
capsuleHeight.value = menuBtnInfo.top - 9;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
// const pages = getCurrentPages();
|
||||
// const currentPage = pages[pages.length - 1];
|
||||
// uni.setStorageSync("last-route", currentPage.route);
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
uni.$showHint = showGlobalHint;
|
||||
uni.$hideHint = hideGlobalHint;
|
||||
showHint.value = false;
|
||||
});
|
||||
|
||||
const backToGame = debounce(async () => {
|
||||
const result = await getCurrentGameAPI();
|
||||
if (isLoading.value) return; // 防止重复点击
|
||||
|
||||
try {
|
||||
isLoading.value = true;
|
||||
|
||||
// 设置请求超时
|
||||
const timeoutPromise = new Promise((_, reject) => {
|
||||
setTimeout(() => reject(new Error('请求超时')), 10000); // 10秒超时
|
||||
});
|
||||
|
||||
const result = await Promise.race([
|
||||
getCurrentGameAPI(),
|
||||
timeoutPromise
|
||||
]);
|
||||
|
||||
// 处理返回结果
|
||||
if (result && result.gameId) {
|
||||
// 跳转到游戏页面
|
||||
uni.navigateTo({
|
||||
url: `/pages/battle-room?gameId=${result.gameId}`
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '没有进行中的对局',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
showHint.value = false;
|
||||
} catch (error) {
|
||||
console.error('获取当前游戏失败:', error);
|
||||
uni.showToast({
|
||||
title: error.message || '网络请求失败,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack();
|
||||
};
|
||||
@@ -100,7 +145,13 @@ const goBack = () => {
|
||||
<button hover-class="none" @click="() => (showHint = false)">
|
||||
不进入
|
||||
</button>
|
||||
<button hover-class="none" @click="backToGame">进入</button>
|
||||
<button
|
||||
hover-class="none"
|
||||
@click="backToGame"
|
||||
:disabled="isLoading"
|
||||
>
|
||||
{{ isLoading ? '加载中...' : '进入' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="hintType === 2" class="tip-content">
|
||||
@@ -168,4 +219,10 @@ const goBack = () => {
|
||||
background-color: #fed847;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.tip-content > view > button:disabled {
|
||||
background-color: #ccc;
|
||||
color: #666;
|
||||
opacity: 0.6;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -37,7 +37,6 @@ onMounted(() => {
|
||||
pointBook.value = uni.getStorageSync("point-book");
|
||||
}
|
||||
if (
|
||||
currentPage.route === "pages/battle-room" ||
|
||||
currentPage.route === "pages/team-battle" ||
|
||||
currentPage.route === "pages/melee-match"
|
||||
) {
|
||||
|
||||
@@ -29,7 +29,6 @@ watch(
|
||||
if (!sound.value) return;
|
||||
if (currentRoundEnded.value) {
|
||||
currentRound.value += 1;
|
||||
console.log(11111, currentRound.value);
|
||||
// 播放当前轮次语音
|
||||
audioManager.play(
|
||||
`第${["一", "二", "三", "四", "五"][currentRound.value - 1]}轮`
|
||||
@@ -38,10 +37,7 @@ watch(
|
||||
// 延迟播放队伍提示音
|
||||
setTimeout(
|
||||
() => {
|
||||
if (key) {
|
||||
if (!yourTurn.value) audioManager.play(key);
|
||||
else audioManager.play("轮到你了");
|
||||
}
|
||||
if (key && !yourTurn.value) audioManager.play(key);
|
||||
currentRoundEnded.value = false;
|
||||
yourTurn.value = false;
|
||||
},
|
||||
@@ -103,6 +99,7 @@ async function onReceiveMessage(messages = []) {
|
||||
totalShot.value = 0;
|
||||
audioManager.play("决金箭轮");
|
||||
tips.value = "即将开始...";
|
||||
currentRoundEnded.value = false;
|
||||
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
||||
ended.value = true;
|
||||
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
|
||||
Reference in New Issue
Block a user