修改升级接收方式

This commit is contained in:
kron
2025-07-22 09:36:38 +08:00
parent cbf83952d7
commit d3029865cf
8 changed files with 36 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted, onUnmounted } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import Avatar from "@/components/Avatar.vue";
import UserUpgrade from "@/components/UserUpgrade.vue";
@@ -16,37 +16,21 @@ const data = ref({});
const totalPoints = ref(0);
const rank = ref(0);
const showUpgrade = ref(false);
// onLoad(async (options) => {
// battleId.value = options.battleId;
// const result = await getGameAPI(
// // options.battleId || "BATTLE-1750867490990424058-718"
// options.battleId || "BATTLE-1752563964391008873-624"
// );
// data.value = result;
// if (result.mode === 1 && result.redPlayers[user.value.id]) {
// totalPoints.value = result.redPlayers[user.value.id].totalScore;
// ifWin.value = result.winner === 0;
// }
// if (result.mode === 1 && result.bluePlayers[user.value.id]) {
// totalPoints.value = result.bluePlayers[user.value.id].totalScore;
// ifWin.value = result.winner === 1;
// }
// if (result.mode === 2) {
// const mine = result.players.find((p) => p.playerId === user.value.id);
// if (mine) totalPoints.value = mine.totalScore;
// }
// });
const timer = ref(null);
const latestLvl = ref(0);
function exit() {
uni.navigateBack();
}
const checkBowData = () => {
uni.navigateTo({
url: `/pages/match-detail?id=${data.value.id}`,
});
};
onMounted(async () => {
const battleInfo = uni.getStorageSync("last-battle");
console.log("----battleInfo", battleInfo);
if (battleInfo.lvl > user.value.lvl) {
showUpgrade.value = true;
}
data.value = battleInfo;
const mine = battleInfo.playerStats.find((p) => p.id === user.value.id);
rank.value =
@@ -55,13 +39,16 @@ onMounted(async () => {
totalPoints.value = mine.totalScore;
ifWin.value = battleInfo.mode === 1 && mine.team === battleInfo.winner;
}
timer.value = setTimeout(() => {
const lastLvl = uni.getStorageSync("lastest-lvl");
if (parseInt(lastLvl) > user.value.lvl) {
latestLvl.value = parseInt(lastLvl);
}
}, 1000);
});
onUnmounted(() => {
if (timer.value) clearTimeout(timer.value);
});
const checkBowData = () => {
uni.navigateTo({
url: `/pages/match-detail?id=${data.value.id}`,
});
};
</script>
<template>
@@ -181,7 +168,7 @@ const checkBowData = () => {
<UserUpgrade
:show="showUpgrade"
:onClose="() => (showUpgrade = false)"
:lvl="data.lvl"
:lvl="latestLvl"
/>
</view>
</template>