添加升级显示
This commit is contained in:
@@ -4,6 +4,7 @@ import IconButton from "@/components/IconButton.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import ScreenHint from "@/components/ScreenHint.vue";
|
||||
import BowData from "@/components/BowData.vue";
|
||||
import UserUpgrade from "@/components/UserUpgrade.vue";
|
||||
import { wxShare } from "@/util";
|
||||
import { directionAdjusts } from "@/constants";
|
||||
const props = defineProps({
|
||||
@@ -31,6 +32,7 @@ const props = defineProps({
|
||||
const showPanel = ref(true);
|
||||
const showComment = ref(false);
|
||||
const showBowData = ref(false);
|
||||
const showUpgrade = ref(false);
|
||||
const finished = ref(false);
|
||||
const totalRing = ref(0);
|
||||
const closePanel = () => {
|
||||
@@ -40,6 +42,9 @@ const closePanel = () => {
|
||||
}, 300);
|
||||
};
|
||||
onMounted(() => {
|
||||
if (props.result.lvl) {
|
||||
showUpgrade.value = true;
|
||||
}
|
||||
if (props.result.arrows) {
|
||||
totalRing.value = props.result.arrows.reduce(
|
||||
(last, next) => last + next.ring,
|
||||
@@ -55,7 +60,7 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-if="result.arrows" class="container">
|
||||
<view class="container">
|
||||
<view :class="['container-header', showPanel ? 'scale-in' : 'scale-out']">
|
||||
<image :src="tipSrc" mode="widthFix" />
|
||||
<image src="../static/finish-frame.png" mode="widthFix" />
|
||||
@@ -144,6 +149,11 @@ onMounted(() => {
|
||||
:show="showBowData"
|
||||
:onClose="() => (showBowData = false)"
|
||||
/>
|
||||
<UserUpgrade
|
||||
:show="showUpgrade"
|
||||
:onClose="() => (showUpgrade = false)"
|
||||
:lvl="result.lvl"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -227,6 +227,9 @@ onUnmounted(() => {
|
||||
font-size: 18px;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
.container > view:first-child > button:last-child {
|
||||
overflow: visible;
|
||||
}
|
||||
.container > view:first-child > button:last-child > image {
|
||||
width: 40px;
|
||||
transform: translateX(10px) translateY(-10px);
|
||||
|
||||
80
src/components/UserUpgrade.vue
Normal file
80
src/components/UserUpgrade.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<script setup>
|
||||
import { onMounted } from "vue";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const { updateUser } = store;
|
||||
const props = defineProps({
|
||||
lvl: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
onClose: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
onMounted(() => {
|
||||
updateUser({ ...user.value, lvl: props.lvl });
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="content" :style="{ display: show ? 'flex' : 'none' }">
|
||||
<image src="../static/user-upgrade.png" mode="widthFix" />
|
||||
<image class="" src="../static/shining-bg.png" mode="widthFix" />
|
||||
<view>
|
||||
<text>恭喜你升级到</text>
|
||||
<text>射灵{{ lvl }}级</text>
|
||||
</view>
|
||||
<button @click="onClose" hover-class="none">关闭</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.content {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: #232323;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 10;
|
||||
color: red;
|
||||
}
|
||||
.content > image:first-child {
|
||||
width: 50vw;
|
||||
position: absolute;
|
||||
top: calc(50% - 30vw);
|
||||
}
|
||||
.content > image:nth-child(2) {
|
||||
width: 80vw;
|
||||
}
|
||||
.content > view:nth-child(3) {
|
||||
color: #fff;
|
||||
display: flex;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-top: -6vw;
|
||||
}
|
||||
.content > view:nth-child(3) > text:last-child {
|
||||
color: #fed847;
|
||||
}
|
||||
.content > button:last-child {
|
||||
color: #fff9;
|
||||
font-size: 20px;
|
||||
border: 1px solid #fff;
|
||||
padding: 10px;
|
||||
width: 50vw;
|
||||
border-radius: 20px;
|
||||
margin-top: 10vw;
|
||||
}
|
||||
</style>
|
||||
@@ -2,6 +2,7 @@
|
||||
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 { topThreeColors, getBattleResultTips } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
@@ -14,6 +15,7 @@ const ifWin = ref(false);
|
||||
const data = ref({});
|
||||
const totalPoints = ref(0);
|
||||
const rank = ref(0);
|
||||
const showUpgrade = ref(false);
|
||||
|
||||
// onLoad(async (options) => {
|
||||
// battleId.value = options.battleId;
|
||||
@@ -181,6 +183,11 @@ const checkBowData = () => {
|
||||
<view @click="checkBowData">查看靶纸</view>
|
||||
<view @click="exit">退出</view>
|
||||
</view>
|
||||
<UserUpgrade
|
||||
:show="showUpgrade"
|
||||
:onClose="() => (showUpgrade = false)"
|
||||
:lvl="data.lvl"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ watch(
|
||||
onLoad(async (options) => {
|
||||
if (options.battleId) {
|
||||
const battleInfo = uni.getStorageSync("current-battle");
|
||||
console.log("----battleInfo", battleInfo);
|
||||
// console.log("----battleInfo", battleInfo);
|
||||
if (battleInfo) {
|
||||
battleId.value = battleInfo.id;
|
||||
battleType.value = battleInfo.config.mode;
|
||||
@@ -245,6 +245,7 @@ async function onReceiveMessage(messages = []) {
|
||||
// 这里会掉多次;
|
||||
timerSeq.value += 1;
|
||||
battleId.value = msg.id;
|
||||
startCount.value = true;
|
||||
step.value = 2;
|
||||
if (battleType.value === 1) {
|
||||
redTeam.value = msg.groupUserStatus.redTeam;
|
||||
@@ -335,7 +336,6 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
start.value = true;
|
||||
startCount.value = true;
|
||||
step.value = 3;
|
||||
seq.value += 1;
|
||||
timerSeq.value = 0;
|
||||
@@ -424,7 +424,7 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||
playersScores.value = {};
|
||||
uni.$emit("update-ramain", 0);
|
||||
[
|
||||
...msg.groupUserStatus.redTeam,
|
||||
...msg.groupUserStatus.blueTeam,
|
||||
|
||||
@@ -117,6 +117,7 @@ async function onReceiveMessage(messages = []) {
|
||||
// 这里会掉多次;
|
||||
timerSeq.value += 1;
|
||||
battleId.value = msg.id;
|
||||
startCount.value = true;
|
||||
players.value = [
|
||||
...msg.groupUserStatus.redTeam,
|
||||
...msg.groupUserStatus.blueTeam,
|
||||
@@ -130,7 +131,6 @@ async function onReceiveMessage(messages = []) {
|
||||
if (msg.id !== battleId.value) return;
|
||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||
start.value = true;
|
||||
startCount.value = true;
|
||||
seq.value += 1;
|
||||
timerSeq.value = 0;
|
||||
tips.value = "请连续射出6支箭";
|
||||
@@ -144,7 +144,7 @@ async function onReceiveMessage(messages = []) {
|
||||
playersScores.value[msg.userId].push(msg.target);
|
||||
}
|
||||
if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
|
||||
playersScores.value = {};
|
||||
uni.$emit("update-ramain", 0);
|
||||
[...msg.groupUserStatus.redTeam, ...msg.groupUserStatus.blueTeam].forEach(
|
||||
(player) => {
|
||||
playersScores.value[player.id] = player.arrows;
|
||||
@@ -155,7 +155,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: "游戏结束",
|
||||
|
||||
@@ -63,6 +63,7 @@ async function onReceiveMessage(messages = []) {
|
||||
practiseResult.value = {
|
||||
...msg.practice,
|
||||
arrows: JSON.parse(msg.practice.arrows),
|
||||
lvl: msg.lvl,
|
||||
};
|
||||
generateCanvasImage(
|
||||
"shareCanvas",
|
||||
|
||||
@@ -225,7 +225,7 @@ async function onReceiveMessage(messages = []) {
|
||||
}
|
||||
}
|
||||
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: "游戏结束",
|
||||
|
||||
Reference in New Issue
Block a user