升级逻辑完善
This commit is contained in:
@@ -3,13 +3,13 @@ import { ref, onMounted } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import Avatar from "@/components/Avatar.vue";
|
||||
import UserUpgrade from "@/components/UserUpgrade.vue";
|
||||
import { getGameAPI, getHomeData } from "@/apis";
|
||||
import { getGameAPI } from "@/apis";
|
||||
import { topThreeColors, getBattleResultTips } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const { updateUser, getLvlName } = store;
|
||||
const { getLvlName } = store;
|
||||
|
||||
const ifWin = ref(false);
|
||||
const data = ref({});
|
||||
@@ -44,6 +44,9 @@ function exit() {
|
||||
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 =
|
||||
@@ -52,8 +55,6 @@ onMounted(async () => {
|
||||
totalPoints.value = mine.totalScore;
|
||||
ifWin.value = battleInfo.mode === 1 && mine.team === battleInfo.winner;
|
||||
}
|
||||
const result = await getHomeData();
|
||||
if (result.user) updateUser(result.user);
|
||||
});
|
||||
|
||||
const checkBowData = () => {
|
||||
|
||||
@@ -453,7 +453,7 @@ async function onReceiveMessage(messages = []) {
|
||||
tips.value = "准备下半场";
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||
uni.setStorageSync("last-battle", msg.endStatus);
|
||||
uni.setStorageSync("last-battle", { ...msg.endStatus, lvl: msg.lvl });
|
||||
if (msg.endStatus.nosaved) {
|
||||
uni.showToast({
|
||||
title: "游戏结束",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import AppFooter from "@/components/AppFooter.vue";
|
||||
import AppBackground from "@/components/AppBackground.vue";
|
||||
@@ -52,37 +53,36 @@ const toRankListPage = () => {
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const deviceInfo = uni.getDeviceInfo();
|
||||
isIos.value = deviceInfo.osName === "ios";
|
||||
const config = await getAppConfig();
|
||||
updateConfig(config);
|
||||
console.log("全局配置:", config);
|
||||
const result = await getHomeData();
|
||||
updateRank(result);
|
||||
console.log("首页数据:", result);
|
||||
if (result.user) {
|
||||
updateUser(result.user);
|
||||
if (result.user.trio <= 0) {
|
||||
showGuide.value = true;
|
||||
setTimeout(() => {
|
||||
showGuide.value = false;
|
||||
}, 3000);
|
||||
}
|
||||
const devices = await getMyDevicesAPI();
|
||||
if (devices.bindings && devices.bindings.length) {
|
||||
updateDevice(
|
||||
devices.bindings[0].deviceId,
|
||||
devices.bindings[0].deviceName
|
||||
);
|
||||
}
|
||||
onShow(async () => {
|
||||
const result = await getHomeData();
|
||||
updateRank(result);
|
||||
console.log("首页数据:", result);
|
||||
if (result.user) {
|
||||
updateUser(result.user);
|
||||
if (result.user.trio <= 0) {
|
||||
showGuide.value = true;
|
||||
setTimeout(() => {
|
||||
showGuide.value = false;
|
||||
}, 3000);
|
||||
}
|
||||
const devices = await getMyDevicesAPI();
|
||||
if (devices.bindings && devices.bindings.length) {
|
||||
updateDevice(
|
||||
devices.bindings[0].deviceId,
|
||||
devices.bindings[0].deviceName
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取配置失败:", error);
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
const deviceInfo = uni.getDeviceInfo();
|
||||
isIos.value = deviceInfo.osName === "ios";
|
||||
const config = await getAppConfig();
|
||||
updateConfig(config);
|
||||
console.log("全局配置:", config);
|
||||
});
|
||||
|
||||
const comingSoon = () => {
|
||||
uni.showToast({
|
||||
title: "敬请期待",
|
||||
|
||||
@@ -10,7 +10,7 @@ import Avatar from "@/components/Avatar.vue";
|
||||
import BowPower from "@/components/BowPower.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import BubbleTip from "@/components/BubbleTip.vue";
|
||||
import { createPractiseAPI, getHomeData } from "@/apis";
|
||||
import { createPractiseAPI } from "@/apis";
|
||||
import { generateCanvasImage } from "@/util";
|
||||
import { MESSAGETYPES, roundsName } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
|
||||
@@ -10,7 +10,7 @@ import Avatar from "@/components/Avatar.vue";
|
||||
import BowPower from "@/components/BowPower.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import BubbleTip from "@/components/BubbleTip.vue";
|
||||
import { createPractiseAPI, getHomeData } from "@/apis";
|
||||
import { createPractiseAPI } from "@/apis";
|
||||
import { generateCanvasImage } from "@/util";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
|
||||
Reference in New Issue
Block a user