细节修改
This commit is contained in:
@@ -13,10 +13,11 @@ const timer = ref(null);
|
|||||||
const sound = ref(true);
|
const sound = ref(true);
|
||||||
const currentSound = ref("");
|
const currentSound = ref("");
|
||||||
const currentRound = ref(1);
|
const currentRound = ref(1);
|
||||||
const totalRound = ref(1);
|
|
||||||
const currentRoundEnded = ref(false);
|
const currentRoundEnded = ref(false);
|
||||||
const ended = ref(false);
|
const ended = ref(false);
|
||||||
const halfTime = ref(false);
|
const halfTime = ref(false);
|
||||||
|
const currentShot = ref(0);
|
||||||
|
const totalShot = ref(0);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => tips.value,
|
() => tips.value,
|
||||||
@@ -52,6 +53,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
messages.forEach((msg) => {
|
messages.forEach((msg) => {
|
||||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
if (melee.value && msg.userId !== user.value.id) return;
|
if (melee.value && msg.userId !== user.value.id) return;
|
||||||
|
if (msg.userId === user.value.id) currentShot.value++;
|
||||||
if (!halfTime.value && msg.target) {
|
if (!halfTime.value && msg.target) {
|
||||||
currentSound.value = msg.target.ring
|
currentSound.value = msg.target.ring
|
||||||
? `${msg.target.ring}环`
|
? `${msg.target.ring}环`
|
||||||
@@ -67,6 +69,10 @@ async function onReceiveMessage(messages = []) {
|
|||||||
audioManager.play("射击无效");
|
audioManager.play("射击无效");
|
||||||
}
|
}
|
||||||
} else if (msg.constructor === MESSAGETYPES.AllReady) {
|
} 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;
|
currentRoundEnded.value = true;
|
||||||
audioManager.play("比赛开始");
|
audioManager.play("比赛开始");
|
||||||
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
} else if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||||
@@ -74,6 +80,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
halfTime.value = false;
|
halfTime.value = false;
|
||||||
audioManager.play("比赛开始");
|
audioManager.play("比赛开始");
|
||||||
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
|
||||||
|
currentShot.value = 0;
|
||||||
if (msg.preRoundResult && msg.preRoundResult.currentRound) {
|
if (msg.preRoundResult && msg.preRoundResult.currentRound) {
|
||||||
currentRound.value = msg.preRoundResult.currentRound + 1;
|
currentRound.value = msg.preRoundResult.currentRound + 1;
|
||||||
currentRoundEnded.value = true;
|
currentRoundEnded.value = true;
|
||||||
@@ -84,6 +91,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
|
||||||
audioManager.play("比赛结束");
|
audioManager.play("比赛结束");
|
||||||
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
|
||||||
|
totalShot.value = 0;
|
||||||
audioManager.play("决金箭轮");
|
audioManager.play("决金箭轮");
|
||||||
tips.value = "即将开始...";
|
tips.value = "即将开始...";
|
||||||
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
||||||
@@ -107,14 +115,20 @@ const onUpdateTips = (newVal) => {
|
|||||||
tips.value = newVal;
|
tips.value = newVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onUpdateTotalShot = (newVal) => {
|
||||||
|
currentShot.value = newVal.currentShot;
|
||||||
|
totalShot.value = newVal.totalShot;
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
uni.$on("update-shot", onUpdateTotalShot);
|
||||||
uni.$on("update-tips", onUpdateTips);
|
uni.$on("update-tips", onUpdateTips);
|
||||||
uni.$on("socket-inbox", onReceiveMessage);
|
uni.$on("socket-inbox", onReceiveMessage);
|
||||||
uni.$on("play-sound", playSound);
|
uni.$on("play-sound", playSound);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
uni.$off("update-tips", onUpdateTips);
|
uni.$off("update-shot", onUpdateTotalShot);
|
||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
uni.$off("play-sound", playSound);
|
uni.$off("play-sound", playSound);
|
||||||
if (timer.value) clearInterval(timer.value);
|
if (timer.value) clearInterval(timer.value);
|
||||||
@@ -124,7 +138,7 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<text>{{ tips }}</text>
|
<text>{{ tips }}</text>
|
||||||
<!-- <text> ({{ currentRound }}/{{ totalRound }}) </text> -->
|
<text v-if="totalShot > 0"> ({{ currentShot }}/{{ totalShot }}) </text>
|
||||||
<button v-if="!!tips" hover-class="none" @click="updateSound">
|
<button v-if="!!tips" hover-class="none" @click="updateSound">
|
||||||
<image
|
<image
|
||||||
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"
|
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from "vue";
|
import { ref } from "vue";
|
||||||
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -14,9 +15,10 @@ const props = defineProps({
|
|||||||
default: 10,
|
default: 10,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const refreshing = ref(false);
|
const refreshing = ref(true);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const noMore = ref(false);
|
const noMore = ref(false);
|
||||||
|
const count = ref(0);
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
const refresherrefresh = async () => {
|
const refresherrefresh = async () => {
|
||||||
if (refreshing.value) return;
|
if (refreshing.value) return;
|
||||||
@@ -24,6 +26,7 @@ const refresherrefresh = async () => {
|
|||||||
refreshing.value = true;
|
refreshing.value = true;
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
const length = await props.onLoading(page.value);
|
const length = await props.onLoading(page.value);
|
||||||
|
count.value = length;
|
||||||
if (length < props.pageSize) noMore.value = true;
|
if (length < props.pageSize) noMore.value = true;
|
||||||
} finally {
|
} finally {
|
||||||
refreshing.value = false;
|
refreshing.value = false;
|
||||||
@@ -35,20 +38,21 @@ const scrolltolower = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
page.value += 1;
|
page.value += 1;
|
||||||
const length = await props.onLoading(page.value);
|
const length = await props.onLoading(page.value);
|
||||||
|
count.value += length;
|
||||||
if (length < props.pageSize) noMore.value = true;
|
if (length < props.pageSize) noMore.value = true;
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
watch(
|
onShow(async () => {
|
||||||
() => props.show,
|
try {
|
||||||
async (newVal) => {
|
const length = await props.onLoading(page.value);
|
||||||
if (newVal) await props.onLoading(1);
|
count.value = length;
|
||||||
},
|
if (length < props.pageSize) noMore.value = true;
|
||||||
{
|
} finally {
|
||||||
immediate: true,
|
refreshing.value = false;
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -68,8 +72,10 @@ watch(
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<text class="tips" v-if="loading">加载中...</text>
|
<view class="tips">
|
||||||
<text class="tips" v-if="noMore">我是有底线的</text>
|
<text v-if="loading">加载中...</text>
|
||||||
|
<text v-if="noMore">{{ count === 0 ? "暂无数据" : "没有更多了" }}</text>
|
||||||
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -79,7 +85,10 @@ watch(
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.tips {
|
.tips {
|
||||||
color: #fff9;
|
height: 50rpx;
|
||||||
|
}
|
||||||
|
.tips > text {
|
||||||
|
color: #d0d0d0;
|
||||||
display: block;
|
display: block;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ watch(
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
|
<image
|
||||||
|
:src="isRed ? '../static/flag-red.png' : '../static/flag-blue.png'"
|
||||||
|
class="flag"
|
||||||
|
:style="{ [isRed ? 'left' : 'right']: '10rpx' }"
|
||||||
|
/>
|
||||||
<view
|
<view
|
||||||
v-for="(item, index) in team"
|
v-for="(item, index) in team"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -96,6 +101,7 @@ watch(
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 20vw;
|
width: 20vw;
|
||||||
height: 45px;
|
height: 45px;
|
||||||
|
margin: 0 20rpx;
|
||||||
}
|
}
|
||||||
.container > text {
|
.container > text {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -124,4 +130,10 @@ watch(
|
|||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
.flag {
|
||||||
|
position: absolute;
|
||||||
|
width: 45rpx;
|
||||||
|
height: 45rpx;
|
||||||
|
top: -30rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ const comingSoon = () => {
|
|||||||
@click="() => toPage('/pages/my-device')"
|
@click="() => toPage('/pages/my-device')"
|
||||||
/>
|
/>
|
||||||
<text v-if="!user.id">我的弓箭</text>
|
<text v-if="!user.id">我的弓箭</text>
|
||||||
<text v-if="user.id && !device.deviceId">请绑定设备</text>
|
<text v-if="user.id && !device.deviceId">连接智能弓箭</text>
|
||||||
<text
|
<text
|
||||||
v-if="user.id && device.deviceId"
|
v-if="user.id && device.deviceId"
|
||||||
class="truncate"
|
class="truncate"
|
||||||
|
|||||||
@@ -126,6 +126,20 @@ function recoverData(battleInfo) {
|
|||||||
};
|
};
|
||||||
roundResults.value.push(roundData);
|
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;
|
const lastIndex = roundResults.value.length - 1;
|
||||||
if (roundResults.value[lastIndex]) {
|
if (roundResults.value[lastIndex]) {
|
||||||
@@ -362,7 +376,7 @@ onHide(() => {
|
|||||||
.players-row {
|
.players-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-around;
|
justify-content: center;
|
||||||
margin-bottom: -7vw;
|
margin-bottom: -7vw;
|
||||||
margin-top: -3vw;
|
margin-top: -3vw;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/static/flag-blue.png
Normal file
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
BIN
src/static/flag-red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 540 B |
Reference in New Issue
Block a user