新手试炼流程优化
This commit is contained in:
@@ -63,9 +63,7 @@ export const unbindDeviceAPI = (deviceId) => {
|
|||||||
|
|
||||||
export const getMyDevicesAPI = () => {
|
export const getMyDevicesAPI = () => {
|
||||||
// "/user/device/getBinding?deviceId=9ZF9oVXs"
|
// "/user/device/getBinding?deviceId=9ZF9oVXs"
|
||||||
return request("GET", "/user/device/getBindings", {
|
return request("GET", "/user/device/getBindings");
|
||||||
deviceId,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createPractiseAPI = (arrows) => {
|
export const createPractiseAPI = (arrows) => {
|
||||||
|
|||||||
@@ -12,14 +12,26 @@ const props = defineProps({
|
|||||||
type: Function,
|
type: Function,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view
|
<view
|
||||||
class="sbtn"
|
class="sbtn"
|
||||||
:style="{ width: width, borderRadius: rounded + 'px' }"
|
:style="{
|
||||||
@click="onClick"
|
width: width,
|
||||||
|
borderRadius: rounded + 'px',
|
||||||
|
backgroundColor: disabled ? '#757575' : '#fed847',
|
||||||
|
}"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
if (!disabled) onClick();
|
||||||
|
}
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</view>
|
</view>
|
||||||
@@ -31,7 +43,6 @@ const props = defineProps({
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background-color: #fed847;
|
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onUnmounted } from "vue";
|
import { ref, onMounted, onUnmounted } from "vue";
|
||||||
import Guide from "@/components/Guide.vue";
|
import Guide from "@/components/Guide.vue";
|
||||||
import SButton from "@/components/SButton.vue";
|
import SButton from "@/components/SButton.vue";
|
||||||
import Swiper from "@/components/Swiper.vue";
|
import Swiper from "@/components/Swiper.vue";
|
||||||
@@ -30,11 +30,14 @@ const stepButtonTexts = [
|
|||||||
const start = ref(false);
|
const start = ref(false);
|
||||||
const practiseResult = ref({});
|
const practiseResult = ref({});
|
||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
|
const btnDisabled = ref(false);
|
||||||
|
|
||||||
const onReady = async () => {
|
const createPractise = async (arrows) => {
|
||||||
const result = await createPractiseAPI(total);
|
const result = await createPractiseAPI(arrows);
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
start.value = true;
|
|
||||||
websocket.createWebSocket(token, (content) => {
|
websocket.createWebSocket(token, (content) => {
|
||||||
const messages = JSON.parse(content).data.updates || [];
|
const messages = JSON.parse(content).data.updates || [];
|
||||||
messages.forEach((msg) => {
|
messages.forEach((msg) => {
|
||||||
@@ -43,6 +46,9 @@ const onReady = async () => {
|
|||||||
if (scores.value.length === total) {
|
if (scores.value.length === total) {
|
||||||
showScore.value = true;
|
showScore.value = true;
|
||||||
}
|
}
|
||||||
|
if (step.value === 2 && msg.target.dst > 5) {
|
||||||
|
btnDisabled.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
|
||||||
practiseResult.value = {
|
practiseResult.value = {
|
||||||
@@ -52,22 +58,25 @@ const onReady = async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
websocket.closeWebSocket();
|
websocket.closeWebSocket();
|
||||||
});
|
});
|
||||||
|
|
||||||
const nextStep = () => {
|
const nextStep = async () => {
|
||||||
if (step.value === 0) {
|
if (step.value === 0) {
|
||||||
step.value = 1;
|
step.value = 1;
|
||||||
} else if (step.value === 1) {
|
} else if (step.value === 1) {
|
||||||
|
await createPractise(1);
|
||||||
|
btnDisabled.value = true;
|
||||||
step.value = 2;
|
step.value = 2;
|
||||||
} else if (step.value === 2) {
|
} else if (step.value === 2) {
|
||||||
step.value = 3;
|
step.value = 3;
|
||||||
} else if (step.value === 3) {
|
} else if (step.value === 3) {
|
||||||
|
scores.value = [];
|
||||||
|
await createPractise(total);
|
||||||
step.value = 4;
|
step.value = 4;
|
||||||
onReady();
|
|
||||||
} else if (step.value === 5) {
|
} else if (step.value === 5) {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1,
|
delta: 1,
|
||||||
@@ -159,7 +168,13 @@ const onClose = () => {
|
|||||||
:power="power"
|
:power="power"
|
||||||
:debug="step === 2"
|
:debug="step === 2"
|
||||||
v-if="step === 2 || step === 4"
|
v-if="step === 2 || step === 4"
|
||||||
:tips="step === 4 ? '' : '本次射程5.2米,已达到距离要求'"
|
:tips="
|
||||||
|
step === 2 && scores.length > 0
|
||||||
|
? `本次射程${scores[scores.length - 1].dst}米,${
|
||||||
|
scores[scores.length - 1].dst >= 5 ? '已' : '未'
|
||||||
|
}达到距离要求`
|
||||||
|
: ''
|
||||||
|
"
|
||||||
:scores="scores"
|
:scores="scores"
|
||||||
/>
|
/>
|
||||||
<ScorePanel
|
<ScorePanel
|
||||||
@@ -176,7 +191,7 @@ const onClose = () => {
|
|||||||
:onClose="onClose"
|
:onClose="onClose"
|
||||||
:result="practiseResult"
|
:result="practiseResult"
|
||||||
/>
|
/>
|
||||||
<SButton v-if="step !== 4" :onClick="nextStep">{{
|
<SButton v-if="step !== 4" :onClick="nextStep" :disabled="btnDisabled">{{
|
||||||
stepButtonTexts[step]
|
stepButtonTexts[step]
|
||||||
}}</SButton>
|
}}</SButton>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
Reference in New Issue
Block a user