Files
shoot-miniprograms/src/pages/calibration.vue

117 lines
2.6 KiB
Vue
Raw Normal View History

2025-10-29 15:17:22 +08:00
<script setup>
2025-10-29 18:07:42 +08:00
import { ref, onMounted, onBeforeUnmount } from "vue";
2025-10-29 15:17:22 +08:00
import Container from "@/components/Container.vue";
import SButton from "@/components/SButton.vue";
import { laserAimAPI, laserCloseAPI } from "@/apis";
2025-10-29 18:07:42 +08:00
import { MESSAGETYPES } from "@/constants";
import audioManager from "@/audioManager";
2025-10-29 15:17:22 +08:00
const guides = [
{
2025-10-31 10:22:02 +08:00
title: "箭头面向墙面,直至语音提示激光坐标已校准",
2025-10-30 10:11:15 +08:00
src: "https://static.shelingxingqiu.com/attachment/2025-10-30/ddv9p5fk5wscg7hrfo.png",
2025-10-29 15:17:22 +08:00
},
{
title: "摆出拉弓姿势",
2025-10-30 10:11:15 +08:00
src: "https://static.shelingxingqiu.com/attachment/2025-10-30/ddv9p5fk5b7ljrhx3o.png",
2025-10-29 15:17:22 +08:00
},
{
title: "调整瞄准器",
src: "https://static.shelingxingqiu.com/attachment/2025-10-29/dduexjgrcxf9wjaiv4.png",
},
];
2025-10-29 18:07:42 +08:00
const done = ref(false);
2025-10-29 15:17:22 +08:00
const onComplete = async () => {
await laserCloseAPI();
uni.navigateBack();
};
2025-10-29 18:07:42 +08:00
function onReceiveMessage(messages = []) {
messages.forEach((msg) => {
if (msg.constructor === MESSAGETYPES.Calibration) {
done.value = true;
uni.setStorageSync("calibration", true);
audioManager.play("激光已校准");
}
});
}
2025-10-29 15:17:22 +08:00
onMounted(async () => {
2025-10-29 18:07:42 +08:00
uni.$on("socket-inbox", onReceiveMessage);
2025-10-29 15:17:22 +08:00
await laserAimAPI();
});
2025-10-29 18:07:42 +08:00
onBeforeUnmount(async () => {
uni.$off("socket-inbox", onReceiveMessage);
await laserCloseAPI();
});
2025-10-29 15:17:22 +08:00
</script>
<template>
<Container title="校准智能弓">
<view class="container">
<view v-for="(guide, index) in guides" :key="guide.title" class="guide">
<view>
<text>{{ index + 1 }}</text>
<text>{{ guide.title }}</text>
</view>
<image :src="guide.src" mode="widthFix" />
</view>
<text>请完成以上步骤校准智能弓</text>
2025-10-29 18:07:42 +08:00
<SButton
:onClick="onComplete"
width="60vw"
:rounded="40"
:disabled="!done"
>
2025-10-29 15:17:22 +08:00
我已校准
</SButton>
</view>
</Container>
</template>
<style scoped>
.container {
display: flex;
flex-direction: column;
align-items: center;
}
.guide {
display: flex;
flex-direction: column;
align-items: center;
font-size: 26rpx;
color: #ffffff;
margin-bottom: 15rpx;
}
.guide > view {
width: 100%;
margin: 25rpx 0;
display: flex;
align-items: center;
}
.guide > view > text:first-child {
font-size: 24rpx;
background: #e89024;
border-radius: 50%;
width: 32rpx;
height: 32rpx;
line-height: 32rpx;
display: block;
text-align: center;
margin-right: 15rpx;
}
.guide > image {
width: 630rpx;
height: 250rpx;
}
.container > text {
font-size: 20rpx;
color: #fff9;
margin: 30rpx;
}
</style>