计分本配置接口接入

This commit is contained in:
kron
2025-08-04 16:28:34 +08:00
parent 54a51d2a28
commit 97d23aa731
9 changed files with 181 additions and 129 deletions

View File

@@ -3,6 +3,14 @@ import { ref, onMounted } from "vue";
import { getElementRect, calcRing } from "@/util";
const props = defineProps({
id: {
type: Number,
default: 0,
},
src: {
type: String,
default: "",
},
arrows: {
type: Array,
default: () => [],
@@ -26,6 +34,7 @@ const onClick = async (e) => {
y: e.detail.y - rect.value.top - 10,
};
newArrow.ring = calcRing(
props.id,
newArrow.x,
newArrow.y,
rect.value.width * 0.9,
@@ -72,7 +81,13 @@ const onDrag = async (e) => {
// 更新坐标
arrow.value.x = Math.max(0, Math.min(width, arrow.value.x + deltaX));
arrow.value.y = Math.max(0, Math.min(height, arrow.value.y + deltaY));
arrow.value.ring = calcRing(arrow.value.x, arrow.value.y, width, height);
arrow.value.ring = calcRing(
props.id,
arrow.value.x,
arrow.value.y,
width,
height
);
// 更新拖拽起始位置
dragStartPos.value = { x: clientX, y: clientY };
@@ -96,7 +111,7 @@ onMounted(async () => {
@touchmove="onDrag"
@touchend="endDrag"
>
<image src="../static/bow-target.png" mode="widthFix" />
<image :src="src" mode="widthFix" />
<view
v-for="(arrow, index) in arrows"
:key="index"

View File

@@ -26,59 +26,21 @@ const props = defineProps({
default: "",
},
});
const bowTypes = [
{
name: "反曲弓",
image:
"https://api.shelingxingqiu.com/attachment/2025-07-28/dbnincayxdzicpeidq.png",
},
{
name: "复合弓",
image:
"https://api.shelingxingqiu.com/attachment/2025-07-28/dbnincawegb0dhs0sw.png",
},
{
name: "美洲猎弓",
image:
"https://api.shelingxingqiu.com/attachment/2025-07-28/dbnincaxxeqlufc3nl.png",
},
{
name: "传统弓",
image:
"https://api.shelingxingqiu.com/attachment/2025-07-28/dbnincastq3c3xkzdu.png",
},
{
name: "光弓",
image:
"https://api.shelingxingqiu.com/attachment/2025-07-28/dbnincaur573p7lxh7.png",
},
];
const itemTexts = ["选择弓种", "选择练习距离", "选择靶纸", "选择组/箭数"];
const distances = [5, 8, 10, 18, 25, 30, 50, 60, 70];
const bowtargetTypes = [
"40全环靶",
"80全环靶",
"122全环靶",
"40半环靶",
"60半环靶",
"80半环靶",
"三连靶",
"品字靶",
"复合三连靶",
"复合品字靶",
];
const groupArrows = [3, 6, 12, 18];
const data = ref([]);
const selectedIndex = ref(-1);
const secondSelectIndex = ref(-1);
const onSelectItem = (index) => {
selectedIndex.value = index;
if (props.itemIndex === 0) {
props.onSelect(props.itemIndex, bowTypes[index].name);
props.onSelect(props.itemIndex, data.value[index]);
} else if (props.itemIndex === 1) {
props.onSelect(props.itemIndex, distances[index]);
} else if (props.itemIndex === 2) {
props.onSelect(props.itemIndex, bowtargetTypes[index]);
props.onSelect(props.itemIndex, data.value[index]);
} else if (props.itemIndex === 3 && secondSelectIndex.value !== -1) {
props.onSelect(
props.itemIndex,
@@ -104,8 +66,8 @@ watch(
() => props.value,
(newValue) => {
if (!newValue) return;
if (props.itemIndex === 0) {
bowTypes.forEach((item, index) => {
if (props.itemIndex === 0 || props.itemIndex === 2) {
data.value.forEach((item, index) => {
if (item.name === newValue) {
selectedIndex.value = index;
}
@@ -121,15 +83,19 @@ watch(
}
});
}
if (props.itemIndex === 2) {
bowtargetTypes.forEach((item, index) => {
if (item === newValue) {
selectedIndex.value = index;
}
});
}
}
);
onMounted(() => {
const config = uni.getStorageSync("point-book-config");
if (config) {
if (props.itemIndex === 0) {
data.value = config.bowOption;
} else if (props.itemIndex === 2) {
data.value = config.targetOption;
}
// props.onSelect(props.itemIndex, config[props.itemIndex]);
}
});
</script>
<template>
@@ -171,14 +137,14 @@ watch(
</view>
<view v-if="itemIndex === 0" class="bow-items">
<view
v-for="(item, index) in bowTypes"
v-for="(item, index) in data"
:key="index"
:style="{
borderColor: selectedIndex === index ? '#fed847' : '#eeeeee',
}"
@click="onSelectItem(index)"
>
<image :src="item.image" mode="widthFix" />
<image :src="item.icon" mode="widthFix" />
<text>{{ item.name }}</text>
</view>
</view>
@@ -211,15 +177,15 @@ watch(
</view>
<view v-if="itemIndex === 2" class="bowtarget-items">
<view
v-for="(item, index) in bowtargetTypes"
v-for="(item, index) in data"
:key="index"
:style="{
borderColor: selectedIndex === index ? '#fed847' : '#eeeeee',
}"
@click="onSelectItem(index)"
>
<text>{{ item.substring(0, item.length - 3) }}</text>
<text>{{ item.substring(item.length - 3) }}</text>
<text>{{ item.name.substring(0, item.name.length - 3) }}</text>
<text>{{ item.name.substring(item.name.length - 3) }}</text>
</view>
</view>
<view v-if="itemIndex === 3">
@@ -236,7 +202,8 @@ watch(
<text></text>
</view>
</view>
<view :style="{ marginTop: '5px', marginBottom: '10px' }"
<view
:style="{ marginTop: '5px', marginBottom: '10px', color: '#999999' }"
>选择每组的箭数</view
>
<view class="amount-items">

View File

@@ -97,17 +97,17 @@ onUnmounted(() => {
class="loading"
/>
<view v-if="pointBook" class="point-book-info">
<text>{{ pointBook.bowType }}</text>
<text>{{ pointBook.bowType.name }}</text>
<text>{{ pointBook.distance }} </text>
<text
>{{
pointBook.bowtargetType.substring(
pointBook.bowtargetType.name.substring(
0,
pointBook.bowtargetType.length - 3
pointBook.bowtargetType.name.length - 3
)
}}
{{
pointBook.bowtargetType.substring(pointBook.bowtargetType.length - 3)
pointBook.bowtargetType.name.substring(pointBook.bowtargetType.name.length - 3)
}}</text
>
</view>