修改升级接收方式
This commit is contained in:
@@ -49,6 +49,7 @@ onMounted(() => {
|
|||||||
<image src="../static/update-text-bg.png" />
|
<image src="../static/update-text-bg.png" />
|
||||||
<text>恭喜你升级到</text>
|
<text>恭喜你升级到</text>
|
||||||
<text>射灵{{ lvl }}级</text>
|
<text>射灵{{ lvl }}级</text>
|
||||||
|
<text>!</text>
|
||||||
</view>
|
</view>
|
||||||
<button @click="onClose" hover-class="none">关闭</button>
|
<button @click="onClose" hover-class="none">关闭</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -102,7 +103,7 @@ onMounted(() => {
|
|||||||
left: calc(50% - 40vw);
|
left: calc(50% - 40vw);
|
||||||
height: 60px;
|
height: 60px;
|
||||||
}
|
}
|
||||||
.text-content > text:last-child {
|
.text-content > text:nth-child(3) {
|
||||||
color: #fed847;
|
color: #fed847;
|
||||||
}
|
}
|
||||||
.content > button:last-child {
|
.content > button:last-child {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export const MESSAGETYPES = {
|
|||||||
BackToGame: 1899960424,
|
BackToGame: 1899960424,
|
||||||
FinalShootResult: 3813452544,
|
FinalShootResult: 3813452544,
|
||||||
PaySuccess: 3793388244,
|
PaySuccess: 3793388244,
|
||||||
|
RankUpdate: 1121669910,
|
||||||
|
LvlUpdate: 3958625354,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted, onUnmounted } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import UserUpgrade from "@/components/UserUpgrade.vue";
|
import UserUpgrade from "@/components/UserUpgrade.vue";
|
||||||
@@ -16,37 +16,21 @@ const data = ref({});
|
|||||||
const totalPoints = ref(0);
|
const totalPoints = ref(0);
|
||||||
const rank = ref(0);
|
const rank = ref(0);
|
||||||
const showUpgrade = ref(false);
|
const showUpgrade = ref(false);
|
||||||
|
const timer = ref(null);
|
||||||
// onLoad(async (options) => {
|
const latestLvl = ref(0);
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
function exit() {
|
function exit() {
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkBowData = () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/match-detail?id=${data.value.id}`,
|
||||||
|
});
|
||||||
|
};
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const battleInfo = uni.getStorageSync("last-battle");
|
const battleInfo = uni.getStorageSync("last-battle");
|
||||||
console.log("----battleInfo", battleInfo);
|
console.log("----battleInfo", battleInfo);
|
||||||
if (battleInfo.lvl > user.value.lvl) {
|
|
||||||
showUpgrade.value = true;
|
|
||||||
}
|
|
||||||
data.value = battleInfo;
|
data.value = battleInfo;
|
||||||
const mine = battleInfo.playerStats.find((p) => p.id === user.value.id);
|
const mine = battleInfo.playerStats.find((p) => p.id === user.value.id);
|
||||||
rank.value =
|
rank.value =
|
||||||
@@ -55,13 +39,16 @@ onMounted(async () => {
|
|||||||
totalPoints.value = mine.totalScore;
|
totalPoints.value = mine.totalScore;
|
||||||
ifWin.value = battleInfo.mode === 1 && mine.team === battleInfo.winner;
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -181,7 +168,7 @@ const checkBowData = () => {
|
|||||||
<UserUpgrade
|
<UserUpgrade
|
||||||
:show="showUpgrade"
|
:show="showUpgrade"
|
||||||
:onClose="() => (showUpgrade = false)"
|
:onClose="() => (showUpgrade = false)"
|
||||||
:lvl="data.lvl"
|
:lvl="latestLvl"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
tips.value = "准备下半场";
|
tips.value = "准备下半场";
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
uni.setStorageSync("last-battle", { ...msg.endStatus, lvl: msg.lvl });
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
if (msg.endStatus.nosaved) {
|
if (msg.endStatus.nosaved) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "游戏结束",
|
title: "游戏结束",
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ const toRankListPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
if (user.value.id) {
|
const token = uni.getStorageSync("token");
|
||||||
|
if (token) {
|
||||||
const result = await getHomeData();
|
const result = await getHomeData();
|
||||||
updateRank(result);
|
updateRank(result);
|
||||||
console.log("首页数据:", result);
|
console.log("首页数据:", result);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, onUnmounted } from "vue";
|
import { ref, watch, onMounted, onUnmounted } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import BowTarget from "@/components/BowTarget.vue";
|
import BowTarget from "@/components/BowTarget.vue";
|
||||||
import ShootProgress from "@/components/ShootProgress.vue";
|
import ShootProgress from "@/components/ShootProgress.vue";
|
||||||
@@ -155,7 +155,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
tips.value = "准备下半场";
|
tips.value = "准备下半场";
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
uni.setStorageSync("last-battle", { ...msg.endStatus, lvl: msg.lvl });
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
if (msg.endStatus.noSaved) {
|
if (msg.endStatus.noSaved) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "游戏结束",
|
title: "游戏结束",
|
||||||
@@ -177,6 +177,7 @@ const onBack = () => {
|
|||||||
uni.$showHint(3);
|
uni.$showHint(3);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
onShow(() => {});
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
uni.setKeepScreenOn({
|
uni.setKeepScreenOn({
|
||||||
keepScreenOn: true,
|
keepScreenOn: true,
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
uni.setStorageSync("last-battle", { ...msg.endStatus, lvl: msg.lvl });
|
uni.setStorageSync("last-battle", msg.endStatus);
|
||||||
if (msg.endStatus.noSaved) {
|
if (msg.endStatus.noSaved) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "游戏结束",
|
title: "游戏结束",
|
||||||
|
|||||||
@@ -48,11 +48,13 @@ function createWebSocket(token, onMessage) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
if (msg.constructor === MESSAGETYPES.MatchOver) {
|
|
||||||
uni.$emit("game-over");
|
uni.$emit("game-over");
|
||||||
}
|
} else if (msg.constructor === MESSAGETYPES.RankUpdate) {
|
||||||
if (msg.constructor === MESSAGETYPES.PaySuccess) {
|
console.log("RankUpdate", msg);
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.LvlUpdate) {
|
||||||
|
uni.setStorageSync("latest-lvl", msg.lvl);
|
||||||
|
} else if (msg.constructor === MESSAGETYPES.PaySuccess) {
|
||||||
console.log(1111111, msg);
|
console.log(1111111, msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user