细节优化
This commit is contained in:
@@ -53,6 +53,7 @@ const props = defineProps({
|
|||||||
:total="arrows.length"
|
:total="arrows.length"
|
||||||
:scores="arrows.map((a) => a.ring)"
|
:scores="arrows.map((a) => a.ring)"
|
||||||
/>
|
/>
|
||||||
|
<text>长按保存本次靶纸</text>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -69,6 +70,11 @@ const props = defineProps({
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
.container > text:last-child {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #fff9;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -79,6 +85,7 @@ const props = defineProps({
|
|||||||
.header > view:first-child {
|
.header > view:first-child {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
.header > view:first-child > view:last-child {
|
.header > view:first-child > view:last-child {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ defineProps({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container" :style="{ opacity: power > 0 ? 1 : 0 }">
|
||||||
<image src="../static/b-power.png" mode="widthFix" />
|
<image src="../static/b-power.png" mode="widthFix" />
|
||||||
<view>电量{{ power }}%</view>
|
<view>电量{{ power }}%</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -43,14 +43,16 @@ const props = defineProps({
|
|||||||
const showRoundTips = ref(false);
|
const showRoundTips = ref(false);
|
||||||
const showLatestArrow = ref(false);
|
const showLatestArrow = ref(false);
|
||||||
const prevLength = ref(0);
|
const prevLength = ref(0);
|
||||||
|
const timer = ref(null);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.scores,
|
() => props.scores,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal.length - prevLength.value === 1) {
|
if (newVal.length - prevLength.value === 1) {
|
||||||
|
if (timer.value) clearTimeout(timer.value);
|
||||||
showRoundTips.value = true;
|
showRoundTips.value = true;
|
||||||
showLatestArrow.value = true;
|
showLatestArrow.value = true;
|
||||||
setTimeout(() => {
|
timer.value = setTimeout(() => {
|
||||||
showRoundTips.value = false;
|
showRoundTips.value = false;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
@@ -80,7 +82,7 @@ function calcRealY(num) {
|
|||||||
"/" +
|
"/" +
|
||||||
totalRound
|
totalRound
|
||||||
}}</text>
|
}}</text>
|
||||||
<BowPower v-if="power > 0" :power="power" />
|
<BowPower :power="power" />
|
||||||
</view>
|
</view>
|
||||||
<view class="target">
|
<view class="target">
|
||||||
<view
|
<view
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ const rowCount = new Array(6).fill(0);
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
width: 20%;
|
||||||
}
|
}
|
||||||
.container > view:nth-child(3) {
|
.container > view:nth-child(3) {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -50,5 +50,6 @@ const props = defineProps({
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
color: #000;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ const handleLogin = () => {
|
|||||||
type="nickname"
|
type="nickname"
|
||||||
class="nickname-input"
|
class="nickname-input"
|
||||||
placeholder="请输入昵称"
|
placeholder="请输入昵称"
|
||||||
|
placeholder-style="color: #ccc"
|
||||||
@change="onNicknameChange"
|
@change="onNicknameChange"
|
||||||
@blur="onNicknameBlur"
|
@blur="onNicknameBlur"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ async function onReceiveMessage(content) {
|
|||||||
messages.forEach((msg) => {
|
messages.forEach((msg) => {
|
||||||
if (
|
if (
|
||||||
msg.roomNumber === roomNumber.value ||
|
msg.roomNumber === roomNumber.value ||
|
||||||
(battleId.value && msg.id === battleId.value) ||
|
|
||||||
msg.constructor === MESSAGETYPES.WaitForAllReady
|
msg.constructor === MESSAGETYPES.WaitForAllReady
|
||||||
) {
|
) {
|
||||||
console.log("收到消息:", msg);
|
console.log("收到消息:", msg);
|
||||||
@@ -187,9 +186,9 @@ onMounted(() => {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
uni.$off("socket-inbox", onReceiveMessage);
|
uni.$off("socket-inbox", onReceiveMessage);
|
||||||
if (owner.value) {
|
if (owner.value) {
|
||||||
destroyRoomAPI(room.value.id);
|
destroyRoomAPI(roomNumber.value);
|
||||||
} else {
|
} else {
|
||||||
exitRoomAPI(room.value.id);
|
exitRoomAPI(roomNumber.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ const nextStep = async () => {
|
|||||||
scores.value = [];
|
scores.value = [];
|
||||||
await createPractise(total);
|
await createPractise(total);
|
||||||
step.value = 4;
|
step.value = 4;
|
||||||
|
setTimeout(() => {
|
||||||
|
start.value = true;
|
||||||
|
}, 500);
|
||||||
} else if (step.value === 5) {
|
} else if (step.value === 5) {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1,
|
delta: 1,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { storeToRefs } from "pinia";
|
|||||||
const store = useStore();
|
const store = useStore();
|
||||||
const { updateConfig, updateUser, updateDevice } = store;
|
const { updateConfig, updateUser, updateDevice } = store;
|
||||||
// 使用storeToRefs,用于UI里显示,保持响应性
|
// 使用storeToRefs,用于UI里显示,保持响应性
|
||||||
const { user } = storeToRefs(store);
|
const { user, device } = storeToRefs(store);
|
||||||
const showModal = ref(false);
|
const showModal = ref(false);
|
||||||
|
|
||||||
const toPage = (path) => {
|
const toPage = (path) => {
|
||||||
@@ -68,7 +68,9 @@ onMounted(async () => {
|
|||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@click="() => toPage('/pages/my-device')"
|
@click="() => toPage('/pages/my-device')"
|
||||||
/>
|
/>
|
||||||
<text>我的弓箭</text>
|
<text>{{
|
||||||
|
user.id && !device.deviceId ? "请绑定设备" : "我的弓箭"
|
||||||
|
}}</text>
|
||||||
<image
|
<image
|
||||||
src="../static/a2@2x.png"
|
src="../static/a2@2x.png"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
@@ -151,7 +153,7 @@ onMounted(async () => {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<AppFooter />
|
<AppFooter :signin="() => (showModal = true)" />
|
||||||
<SModal :show="showModal" :onClose="() => (showModal = false)">
|
<SModal :show="showModal" :onClose="() => (showModal = false)">
|
||||||
<Signin :onClose="() => (showModal = false)" />
|
<Signin :onClose="() => (showModal = false)" />
|
||||||
</SModal>
|
</SModal>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const totalRounds = ref(0);
|
|||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
const scores = ref([]);
|
const scores = ref([]);
|
||||||
const tips = ref("即将开始...");
|
const tips = ref("即将开始...");
|
||||||
|
const seq = ref(0);
|
||||||
const timerSeq = ref(0);
|
const timerSeq = ref(0);
|
||||||
const players = ref([]);
|
const players = ref([]);
|
||||||
const playersScores = ref({});
|
const playersScores = ref({});
|
||||||
@@ -83,13 +84,14 @@ async function onReceiveMessage(content) {
|
|||||||
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
if (msg.constructor === MESSAGETYPES.MeleeAllReady) {
|
||||||
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
totalRounds.value = msg.groupUserStatus.config.maxRounds;
|
||||||
start.value = true;
|
start.value = true;
|
||||||
|
seq.value += 1;
|
||||||
timerSeq.value = 0;
|
timerSeq.value = 0;
|
||||||
tips.value = "请在90秒内射完12支箭";
|
tips.value = "请在90秒内射完12支箭";
|
||||||
scores.value = [];
|
scores.value = [];
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
if (msg.constructor === MESSAGETYPES.ShootResult) {
|
||||||
if (msg.userId === user.value.id) {
|
if (msg.userId === user.value.id) {
|
||||||
scores.value = [msg.target];
|
scores.value.push(msg.target);
|
||||||
power.value = msg.target.battery;
|
power.value = msg.target.battery;
|
||||||
}
|
}
|
||||||
playersScores.value[msg.userId].push(msg.target);
|
playersScores.value[msg.userId].push(msg.target);
|
||||||
@@ -125,7 +127,7 @@ onUnmounted(() => {
|
|||||||
<BowPower :power="45" />
|
<BowPower :power="45" />
|
||||||
</view>
|
</view>
|
||||||
</Guide>
|
</Guide>
|
||||||
<ShootProgress v-if="start" :start="start" :tips="tips" />
|
<ShootProgress v-if="start" :seq="seq" :start="start" :tips="tips" />
|
||||||
<BowTarget
|
<BowTarget
|
||||||
:avatar="user.avatarUrl"
|
:avatar="user.avatarUrl"
|
||||||
:power="power"
|
:power="power"
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ onUnmounted(() => {
|
|||||||
<view>
|
<view>
|
||||||
<ShootProgress
|
<ShootProgress
|
||||||
:tips="`${
|
:tips="`${
|
||||||
scores.length === 12
|
!start || scores.length === 12
|
||||||
? ''
|
? ''
|
||||||
: `请开始射箭第${roundsName[Math.ceil((scores.length + 1) / 4)]}轮`
|
: `请开始射箭第${roundsName[Math.ceil((scores.length + 1) / 4)]}轮`
|
||||||
}`"
|
}`"
|
||||||
@@ -76,6 +76,13 @@ onUnmounted(() => {
|
|||||||
:avatar="user.avatarUrl"
|
:avatar="user.avatarUrl"
|
||||||
:power="power"
|
:power="power"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
|
:tips="
|
||||||
|
!start && scores.length > 0
|
||||||
|
? `本次射程${scores[scores.length - 1].dst / 100}米,${
|
||||||
|
scores[scores.length - 1].dst / 100 >= 5 ? '已' : '未'
|
||||||
|
}达到距离要求`
|
||||||
|
: ''
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<ScorePanel2 v-if="start" :scores="scores.map((s) => s.ring)" />
|
<ScorePanel2 v-if="start" :scores="scores.map((s) => s.ring)" />
|
||||||
<ScoreResult
|
<ScoreResult
|
||||||
|
|||||||
@@ -22,13 +22,15 @@ const power = ref(0);
|
|||||||
const onReady = async () => {
|
const onReady = async () => {
|
||||||
await createPractiseAPI(total);
|
await createPractiseAPI(total);
|
||||||
start.value = true;
|
start.value = true;
|
||||||
|
scores.value = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onReceiveMessage(content) {
|
async function onReceiveMessage(content) {
|
||||||
const messages = JSON.parse(content).data.updates || [];
|
const messages = JSON.parse(content).data.updates || [];
|
||||||
messages.forEach((msg) => {
|
messages.forEach((msg) => {
|
||||||
if (start.value && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||||
scores.value.push(msg.target);
|
scores.value.push(msg.target);
|
||||||
|
power.value = msg.target.battery;
|
||||||
if (scores.value.length === total) {
|
if (scores.value.length === total) {
|
||||||
showScore.value = true;
|
showScore.value = true;
|
||||||
}
|
}
|
||||||
@@ -59,13 +61,24 @@ onUnmounted(() => {
|
|||||||
<template>
|
<template>
|
||||||
<Container :bgType="1" title="个人单组练习">
|
<Container :bgType="1" title="个人单组练习">
|
||||||
<view>
|
<view>
|
||||||
<ShootProgress :tips="`请连续射箭${total}支`" :total="120" />
|
<ShootProgress
|
||||||
|
:start="start"
|
||||||
|
:tips="`请连续射箭${total}支`"
|
||||||
|
:total="120"
|
||||||
|
/>
|
||||||
<BowTarget
|
<BowTarget
|
||||||
:totalRound="total"
|
:totalRound="total"
|
||||||
:currentRound="scores.length + 1"
|
:currentRound="scores.length + 1"
|
||||||
:avatar="user.avatarUrl"
|
:avatar="user.avatarUrl"
|
||||||
:power="power"
|
:power="power"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
|
:tips="
|
||||||
|
!start && scores.length > 0
|
||||||
|
? `本次射程${scores[scores.length - 1].dst / 100}米,${
|
||||||
|
scores[scores.length - 1].dst / 100 >= 5 ? '已' : '未'
|
||||||
|
}达到距离要求`
|
||||||
|
: ''
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<ScorePanel
|
<ScorePanel
|
||||||
v-if="start"
|
v-if="start"
|
||||||
|
|||||||
Reference in New Issue
Block a user