细节修改

This commit is contained in:
kron
2025-09-03 16:34:54 +08:00
parent bc17a3a584
commit 1f15183fc4
7 changed files with 67 additions and 18 deletions

View File

@@ -13,10 +13,11 @@ const timer = ref(null);
const sound = ref(true);
const currentSound = ref("");
const currentRound = ref(1);
const totalRound = ref(1);
const currentRoundEnded = ref(false);
const ended = ref(false);
const halfTime = ref(false);
const currentShot = ref(0);
const totalShot = ref(0);
watch(
() => tips.value,
@@ -52,6 +53,7 @@ async function onReceiveMessage(messages = []) {
messages.forEach((msg) => {
if (msg.constructor === MESSAGETYPES.ShootResult) {
if (melee.value && msg.userId !== user.value.id) return;
if (msg.userId === user.value.id) currentShot.value++;
if (!halfTime.value && msg.target) {
currentSound.value = msg.target.ring
? `${msg.target.ring}`
@@ -67,6 +69,10 @@ async function onReceiveMessage(messages = []) {
audioManager.play("射击无效");
}
} else if (msg.constructor === MESSAGETYPES.AllReady) {
const { config } = msg.groupUserStatus;
if (config && config.mode === 1) {
totalShot.value = config.teamSize === 2 ? 3 : 2;
}
currentRoundEnded.value = true;
audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
@@ -74,6 +80,7 @@ async function onReceiveMessage(messages = []) {
halfTime.value = false;
audioManager.play("比赛开始");
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
currentShot.value = 0;
if (msg.preRoundResult && msg.preRoundResult.currentRound) {
currentRound.value = msg.preRoundResult.currentRound + 1;
currentRoundEnded.value = true;
@@ -84,6 +91,7 @@ async function onReceiveMessage(messages = []) {
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
audioManager.play("比赛结束");
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
totalShot.value = 0;
audioManager.play("决金箭轮");
tips.value = "即将开始...";
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
@@ -107,14 +115,20 @@ const onUpdateTips = (newVal) => {
tips.value = newVal;
};
const onUpdateTotalShot = (newVal) => {
currentShot.value = newVal.currentShot;
totalShot.value = newVal.totalShot;
};
onMounted(() => {
uni.$on("update-shot", onUpdateTotalShot);
uni.$on("update-tips", onUpdateTips);
uni.$on("socket-inbox", onReceiveMessage);
uni.$on("play-sound", playSound);
});
onBeforeUnmount(() => {
uni.$off("update-tips", onUpdateTips);
uni.$off("update-shot", onUpdateTotalShot);
uni.$off("socket-inbox", onReceiveMessage);
uni.$off("play-sound", playSound);
if (timer.value) clearInterval(timer.value);
@@ -124,7 +138,7 @@ onBeforeUnmount(() => {
<template>
<view class="container">
<text>{{ tips }}</text>
<!-- <text> ({{ currentRound }}/{{ totalRound }}) </text> -->
<text v-if="totalShot > 0"> ({{ currentShot }}/{{ totalShot }}) </text>
<button v-if="!!tips" hover-class="none" @click="updateSound">
<image
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"

View File

@@ -1,5 +1,6 @@
<script setup>
import { ref, watch } from "vue";
import { ref } from "vue";
import { onShow } from "@dcloudio/uni-app";
const props = defineProps({
show: {
type: Boolean,
@@ -14,9 +15,10 @@ const props = defineProps({
default: 10,
},
});
const refreshing = ref(false);
const refreshing = ref(true);
const loading = ref(false);
const noMore = ref(false);
const count = ref(0);
const page = ref(1);
const refresherrefresh = async () => {
if (refreshing.value) return;
@@ -24,6 +26,7 @@ const refresherrefresh = async () => {
refreshing.value = true;
page.value = 1;
const length = await props.onLoading(page.value);
count.value = length;
if (length < props.pageSize) noMore.value = true;
} finally {
refreshing.value = false;
@@ -35,20 +38,21 @@ const scrolltolower = async () => {
loading.value = true;
page.value += 1;
const length = await props.onLoading(page.value);
count.value += length;
if (length < props.pageSize) noMore.value = true;
} finally {
loading.value = false;
}
};
watch(
() => props.show,
async (newVal) => {
if (newVal) await props.onLoading(1);
},
{
immediate: true,
onShow(async () => {
try {
const length = await props.onLoading(page.value);
count.value = length;
if (length < props.pageSize) noMore.value = true;
} finally {
refreshing.value = false;
}
);
});
</script>
<template>
@@ -68,8 +72,10 @@ watch(
}"
>
<slot></slot>
<text class="tips" v-if="loading">加载中...</text>
<text class="tips" v-if="noMore">我是有底线的</text>
<view class="tips">
<text v-if="loading">加载中...</text>
<text v-if="noMore">{{ count === 0 ? "暂无数据" : "没有更多了" }}</text>
</view>
</scroll-view>
</template>
@@ -79,7 +85,10 @@ watch(
height: 100%;
}
.tips {
color: #fff9;
height: 50rpx;
}
.tips > text {
color: #d0d0d0;
display: block;
text-align: center;
font-size: 12px;

View File

@@ -52,6 +52,11 @@ watch(
<template>
<view class="container">
<image
:src="isRed ? '../static/flag-red.png' : '../static/flag-blue.png'"
class="flag"
:style="{ [isRed ? 'left' : 'right']: '10rpx' }"
/>
<view
v-for="(item, index) in team"
:key="index"
@@ -96,6 +101,7 @@ watch(
position: relative;
width: 20vw;
height: 45px;
margin: 0 20rpx;
}
.container > text {
position: absolute;
@@ -124,4 +130,10 @@ watch(
bottom: 0px;
color: #fff;
}
.flag {
position: absolute;
width: 45rpx;
height: 45rpx;
top: -30rpx;
}
</style>

View File

@@ -111,7 +111,7 @@ const comingSoon = () => {
@click="() => toPage('/pages/my-device')"
/>
<text v-if="!user.id">我的弓箭</text>
<text v-if="user.id && !device.deviceId">请绑定设备</text>
<text v-if="user.id && !device.deviceId">连接智能弓箭</text>
<text
v-if="user.id && device.deviceId"
class="truncate"

View File

@@ -126,6 +126,20 @@ function recoverData(battleInfo) {
};
roundResults.value.push(roundData);
}
} else {
[...battleInfo.redTeam, ...battleInfo.blueTeam].some((p) => {
if (p.id === user.value.id) {
const roundArrows = Object.values(p.shotHistory);
if (roundArrows.length) {
uni.$emit("update-shot", {
currentShot: roundArrows[roundArrows.length - 1].length,
totalShot: battleInfo.config.teamSize === 2 ? 3 : 2,
});
}
return true;
}
return false;
});
}
const lastIndex = roundResults.value.length - 1;
if (roundResults.value[lastIndex]) {
@@ -362,7 +376,7 @@ onHide(() => {
.players-row {
display: flex;
align-items: center;
justify-content: space-around;
justify-content: center;
margin-bottom: -7vw;
margin-top: -3vw;
}

BIN
src/static/flag-blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
src/static/flag-red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B