完成单组练习接口调试
This commit is contained in:
@@ -3,38 +3,17 @@ import Guide from "@/components/Guide.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import Container from "@/components/Container.vue";
|
||||
import { getMyDeviceAPI } from "@/apis";
|
||||
|
||||
// 扫描二维码方法
|
||||
const handleScan = () => {
|
||||
console.log('开始扫码');
|
||||
// 调用扫码API
|
||||
uni.scanCode({
|
||||
// 只支持扫码二维码
|
||||
onlyFromCamera: true,
|
||||
scanType: ['qrCode'],
|
||||
success: (res) => {
|
||||
// res.result 为二维码内容
|
||||
console.log('扫码结果:', res.result);
|
||||
uni.showToast({
|
||||
title: '扫码成功',
|
||||
icon: 'success'
|
||||
});
|
||||
// 这里可以处理扫码后的业务逻辑
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('扫码失败:', err);
|
||||
uni.showToast({
|
||||
title: '扫码失败',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
const getMyDevice = async () => {
|
||||
const result = await getMyDeviceAPI();
|
||||
console.log("我的设备:", result);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container bgType="1" title="弓箭调试">
|
||||
<Guide>
|
||||
<!-- <Guide>
|
||||
<view class="guide-tips">
|
||||
<text>请预先射几箭测试</text>
|
||||
<text>确保射击距离有5米</text>
|
||||
@@ -44,10 +23,10 @@ const handleScan = () => {
|
||||
avatar="../static/avatar.png"
|
||||
:power="45"
|
||||
tips="本次射程5.2米,已达距离要求"
|
||||
/>
|
||||
/> -->
|
||||
<view>
|
||||
<SButton>准备好了直接开始</SButton>
|
||||
<SButton :onClick="handleScan">扫码</SButton>
|
||||
<!-- <SButton>准备好了直接开始</SButton> -->
|
||||
<SButton :onClick="getMyDevice">获取我的设备</SButton>
|
||||
</view>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
@@ -1,36 +1,66 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
import AppBackground from "@/components/AppBackground.vue";
|
||||
import Header from "@/components/Header.vue";
|
||||
import ShootProgress from "@/components/ShootProgress.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
import ScorePanel2 from "@/components/ScorePanel2.vue";
|
||||
import ScoreResult from "@/components/ScoreResult.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import { createPractiseAPI } from "@/apis";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import websocket from "@/websocket";
|
||||
const start = ref(false);
|
||||
const showScore = ref(false);
|
||||
const scores = ref([]);
|
||||
|
||||
setTimeout(() => {
|
||||
showScore.value = true;
|
||||
}, 2000);
|
||||
const onReady = async () => {
|
||||
const result = await createPractiseAPI(12);
|
||||
console.log("result", result);
|
||||
start.value = true;
|
||||
const token = uni.getStorageSync("token");
|
||||
|
||||
websocket.createWebSocket(token, (result) => {
|
||||
const messages = JSON.parse(result).data.updates || [];
|
||||
messages.forEach((msg) => {
|
||||
if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
|
||||
scores.value.push(msg.target);
|
||||
console.log("msg:", msg.target);
|
||||
if (scores.value.length === 12) {
|
||||
showScore.value = true;
|
||||
websocket.closeWebSocket();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
onUnmounted(() => {
|
||||
websocket.closeWebSocket();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="container">
|
||||
<AppBackground type="1" />
|
||||
<AppBackground :type="1" />
|
||||
<Header title="个人单组练习" />
|
||||
<ShootProgress tips="请开始射箭第一轮" total="120" />
|
||||
<ShootProgress tips="请开始射箭第一轮" :start="start" :total="120" />
|
||||
<BowTarget
|
||||
totalRound="10"
|
||||
currentRound="4"
|
||||
:totalRound="12"
|
||||
:currentRound="scores.length + 1"
|
||||
avatar="../static/avatar.png"
|
||||
power="45"
|
||||
:power="45"
|
||||
:scores="scores"
|
||||
/>
|
||||
<ScorePanel2 :scores="[1, 2, 3, 4, 5, 6]" />
|
||||
<ScorePanel2 v-if="start" :scores="scores.map((s) => s.ring)" />
|
||||
<ScoreResult
|
||||
:total="12"
|
||||
:rowCount="6"
|
||||
:show="showScore"
|
||||
:onClose="() => (showScore = false)"
|
||||
:scores="scores.map((s) => s.ring)"
|
||||
/>
|
||||
<SButton v-if="!start" :onClick="onReady">准备好了,直接开始</SButton>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ const toRankIntroPage = () => {
|
||||
:onClick="toOrderPage"
|
||||
/>
|
||||
<UserItem title="新手试炼场" :onClick="toFristTryPage">
|
||||
<text v-if="user.trio" :style="{ color: '#259249' }">已完成</text>
|
||||
<text v-if="user.trio > 1" :style="{ color: '#259249' }">已完成</text>
|
||||
<text v-else :style="{ color: '#CC311F' }">未完成</text>
|
||||
</UserItem>
|
||||
<UserItem title="会员" :onClick="toBeVipPage"> 已赠送6个月会员 </UserItem>
|
||||
|
||||
Reference in New Issue
Block a user