修复BUG

This commit is contained in:
kron
2025-09-18 09:28:14 +08:00
parent b952ea9fd0
commit 72ab9c3757
8 changed files with 96 additions and 34 deletions

View File

@@ -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 = () => {

View File

@@ -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;

View File

@@ -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"
/>

View File

@@ -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;