diff --git a/src/components/BowTarget.vue b/src/components/BowTarget.vue
index e470f6b..96a12f6 100644
--- a/src/components/BowTarget.vue
+++ b/src/components/BowTarget.vue
@@ -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(() => {
{
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 = () => {
-
+
@@ -168,4 +219,10 @@ const goBack = () => {
background-color: #fed847;
color: #000;
}
+
+.tip-content > view > button:disabled {
+ background-color: #ccc;
+ color: #666;
+ opacity: 0.6;
+}
diff --git a/src/components/Header.vue b/src/components/Header.vue
index c8f64f7..6f66956 100644
--- a/src/components/Header.vue
+++ b/src/components/Header.vue
@@ -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"
) {
diff --git a/src/components/HeaderProgress.vue b/src/components/HeaderProgress.vue
index a49b18a..577fc34 100644
--- a/src/components/HeaderProgress.vue
+++ b/src/components/HeaderProgress.vue
@@ -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) {
diff --git a/src/pages/battle-result.vue b/src/pages/battle-result.vue
index 101641f..4248687 100644
--- a/src/pages/battle-result.vue
+++ b/src/pages/battle-result.vue
@@ -44,6 +44,7 @@ onLoad(async (options) => {
data.value.myTeam = result.bluePlayers[myId].team;
ifWin.value = result.winner === 1;
}
+ audioManager.play(ifWin.value ? "胜利" : "失败");
}
if (result.mode === 2) {
data.value.playerStats = result.players.map((p) => ({
@@ -53,6 +54,9 @@ onLoad(async (options) => {
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;
+ if (rank.value > result.players.length * 0.3) {
+ audioManager.play("胜利");
+ }
}
} else {
const battleInfo = uni.getStorageSync("last-battle");
@@ -77,10 +81,16 @@ onLoad(async (options) => {
if (mine) {
data.value.myTeam = mine.team;
totalPoints.value = mine.totalScore;
- ifWin.value = battleInfo.mode === 1 && mine.team === battleInfo.winner;
+ if (battleInfo.mode === 1) {
+ ifWin.value = mine.team === battleInfo.winner;
+ audioManager.play(ifWin.value ? "胜利" : "失败");
+ } else {
+ if (rank.value > battleInfo.playerStats.length * 0.3) {
+ audioManager.play("胜利");
+ }
+ }
}
}
- audioManager.play(ifWin.value ? "胜利" : "失败");
});
const checkBowData = () => {
diff --git a/src/pages/index.vue b/src/pages/index.vue
index a6f2288..4b7817d 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -58,18 +58,25 @@ const toRankListPage = () => {
};
onShow(async () => {
- const rankList = await getRankListAPI();
- console.log("排行数据", rankList);
- updateRank(rankList);
const token = uni.getStorageSync(
`${uni.getAccountInfoSync().miniProgram.envVersion}_token`
);
+
+ const promises = [getRankListAPI()];
if (token) {
- const result = await getHomeData();
- console.log("首页数据:", result);
- if (result.user) {
- updateUser(result.user);
- if (result.user.trio <= 0) {
+ promises.push(getHomeData());
+ }
+
+ const [rankList, homeData] = await Promise.all(promises);
+
+ console.log("排行数据", rankList);
+ updateRank(rankList);
+
+ if (homeData) {
+ console.log("首页数据:", homeData);
+ if (homeData.user) {
+ updateUser(homeData.user);
+ if (homeData.user.trio <= 0) {
showGuide.value = true;
setTimeout(() => {
showGuide.value = false;
diff --git a/src/pages/match-detail.vue b/src/pages/match-detail.vue
index 436717b..639391e 100644
--- a/src/pages/match-detail.vue
+++ b/src/pages/match-detail.vue
@@ -168,7 +168,7 @@ const checkBowData = () => {
borderColor: '#FF6767',
transform: `translateX(-${index * 15}px)`,
}"
- :src="src"
+ :src="src || '../static/user-icon.png'"
:key="index"
mode="widthFix"
/>
@@ -210,7 +210,7 @@ const checkBowData = () => {
borderColor: '#64BAFF',
transform: `translateX(-${index * 15}px)`,
}"
- :src="src"
+ :src="src || '../static/user-icon.png'"
:key="index"
mode="widthFix"
/>
diff --git a/src/pages/team-battle.vue b/src/pages/team-battle.vue
index 9bc19fc..9425218 100644
--- a/src/pages/team-battle.vue
+++ b/src/pages/team-battle.vue
@@ -16,6 +16,7 @@ import ShootProgress2 from "@/components/ShootProgress2.vue";
import { getCurrentGameAPI } from "@/apis";
import { isGameEnded } from "@/util";
import { MESSAGETYPES, roundsName } from "@/constants";
+import audioManager from "@/audioManager";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
@@ -182,6 +183,7 @@ async function onReceiveMessage(messages = []) {
const redPlayer = redTeam.value.find(
(item) => item.id === currentShooterId.value
);
+ if (msg.userId === user.value.id) audioManager.play("轮到你了");
const nextTips = redPlayer ? "请红队射箭" : "请蓝队射箭";
if (nextTips !== tips.value) {
tips.value = nextTips;