接口调试完毕

This commit is contained in:
kron
2025-08-05 11:51:09 +08:00
parent 05f0c14920
commit 414bedf69f
7 changed files with 116 additions and 50 deletions

View File

@@ -374,7 +374,7 @@ export const savePointBookAPI = async (
targetType, targetType,
groups, groups,
arrows, arrows,
group_data = [] data = []
) => { ) => {
return request("POST", "/user/score/sheet/report", { return request("POST", "/user/score/sheet/report", {
bowType, bowType,
@@ -382,15 +382,27 @@ export const savePointBookAPI = async (
targetType, targetType,
groups, groups,
arrows, arrows,
group_data, group_data: data.map((item) =>
item.map((i) => ({
...i,
ring: i.ring === "M" ? -1 : i.ring === "X" ? 0 : Number(i.ring),
}))
),
}); });
}; };
export const getPointBookListAPI = async (page = 1, size = 10) => { export const getPointBookListAPI = async (
return request( page = 1,
"GET", bowType,
`/user/score/sheet/list?pageNum=${page}&pageSize=${size}` distance,
); targetType
) => {
let url = `/user/score/sheet/list?pageNum=${page}&pageSize=10`;
if (bowType) url += `&bowType=${bowType}`;
if (distance) url += `&distance=${distance}`;
if (targetType) url += `&targetType=${targetType}`;
const result = await request("GET", url);
return result.list || [];
}; };
export const getPointBookDetailAPI = async (id) => { export const getPointBookDetailAPI = async (id) => {

View File

@@ -17,7 +17,7 @@ const props = defineProps({
}, },
onChange: { onChange: {
type: Function, type: Function,
default: (arrow) => {}, default: null,
}, },
}); });
@@ -28,7 +28,7 @@ const dragStartPos = ref({ x: 0, y: 0 });
// 点击靶纸创建新的点 // 点击靶纸创建新的点
const onClick = async (e) => { const onClick = async (e) => {
if (arrow.value !== null) return; if (arrow.value !== null || !props.onChange) return;
const newArrow = { const newArrow = {
x: e.detail.x - (rect.value.width * 0.1) / 2, x: e.detail.x - (rect.value.width * 0.1) / 2,
y: e.detail.y - rect.value.top - 10, y: e.detail.y - rect.value.top - 10,
@@ -45,7 +45,8 @@ const onClick = async (e) => {
// 确认添加箭矢 // 确认添加箭矢
const confirmAdd = () => { const confirmAdd = () => {
props.onChange(arrow.value); if (props.onChange)
props.onChange({ ...arrow.value, ring: arrow.value.ring || "M" });
arrow.value = null; arrow.value = null;
}; };

View File

@@ -65,7 +65,10 @@ const onMeterChange = (e) => {
watch( watch(
() => props.value, () => props.value,
(newValue) => { (newValue) => {
if (!newValue) return; if (!newValue) {
selectedIndex.value = -1;
return;
}
if (props.itemIndex === 0 || props.itemIndex === 2) { if (props.itemIndex === 0 || props.itemIndex === 2) {
data.value.forEach((item, index) => { data.value.forEach((item, index) => {
if (item.name === newValue) { if (item.name === newValue) {
@@ -93,7 +96,6 @@ onMounted(() => {
} else if (props.itemIndex === 2) { } else if (props.itemIndex === 2) {
data.value = config.targetOption; data.value = config.targetOption;
} }
// props.onSelect(props.itemIndex, config[props.itemIndex]);
} }
}); });
</script> </script>

View File

@@ -1,29 +1,49 @@
<script setup> <script setup>
import { ref, onMounted } from "vue";
const props = defineProps({ const props = defineProps({
signin: { data: {
type: Function, type: Object,
default: () => {}, default: () => {},
}, },
}); });
const bowOptions = ref({});
const targetOptions = ref({});
onMounted(() => {
const result = uni.getStorageSync("point-book-config");
(result.bowOption || []).forEach((item) => {
bowOptions.value[item.id] = item;
});
(result.targetOption || []).forEach((item) => {
targetOptions.value[item.id] = item;
});
});
</script> </script>
<template> <template>
<view class="container"> <view class="container">
<view> <view>
<view class="labels"> <view class="labels">
<text>反曲弓</text> <text>{{
<text>5 </text> bowOptions[data.bowType] ? bowOptions[data.bowType].name : ""
<text>40 全环靶</text> }}</text>
<text>{{ data.distance }} </text>
<text>{{
targetOptions[data.targetType]
? targetOptions[data.targetType].name
: ""
}}</text>
</view> </view>
<view> <view>
<text>2025-07-10 14:00:00</text> <text>{{ data.createAt }}</text>
</view> </view>
</view> </view>
<view> <view>
<image src="../static/bow-target.png" mode="widthFix" /> <image src="../static/bow-target.png" mode="widthFix" />
<view class="aroow-amount"> <view class="aroow-amount">
<text></text> <text></text>
<text>36</text> <text>{{ data.arrows * data.groups }}</text>
<text></text> <text></text>
</view> </view>
</view> </view>

View File

@@ -2,21 +2,18 @@
import { ref, onMounted, onUnmounted } from "vue"; import { ref, onMounted, onUnmounted } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue"; import Container from "@/components/Container.vue";
import BowTarget from "@/components/BowTarget.vue"; import BowTargetEdit from "@/components/BowTargetEdit.vue";
import ScreenHint2 from "@/components/ScreenHint2.vue"; import ScreenHint2 from "@/components/ScreenHint2.vue";
import { getPointBookDetailAPI } from "@/apis"; import { getPointBookDetailAPI } from "@/apis";
onLoad(async (options) => {
if (options.id) {
const result = await getPointBookDetailAPI(options.id);
console.log(1212, result);
}
});
const selectedIndex = ref(0); const selectedIndex = ref(0);
const showTip = ref(false); const showTip = ref(false);
const showTip2 = ref(false); const showTip2 = ref(false);
const groups = ref([]);
const data = ref({});
const targetSrc = ref("");
const arrows = ref([]);
const openTip = (index) => { const openTip = (index) => {
if (index === 1) showTip.value = true; if (index === 1) showTip.value = true;
@@ -27,6 +24,29 @@ const closeTip = () => {
showTip.value = false; showTip.value = false;
showTip2.value = false; showTip2.value = false;
}; };
const onSelect = (index) => {
selectedIndex.value = index;
data.value = groups.value[index];
arrows.value = groups.value[index].list.filter((item) => item.x && item.y);
};
onLoad(async (options) => {
if (options.id) {
const result = await getPointBookDetailAPI(options.id);
const config = uni.getStorageSync("point-book-config");
config.targetOption.some((item) => {
if (item.id === result.targetType) {
targetSrc.value = item.icon;
}
});
if (result.groups) {
groups.value = result.groups;
data.value = result.groups[0];
arrows.value = result.groups[0].list.filter((item) => item.x && item.y);
}
}
});
</script> </script>
<template> <template>
@@ -34,9 +54,9 @@ const closeTip = () => {
<view class="container"> <view class="container">
<view class="tab-bar"> <view class="tab-bar">
<view <view
v-for="(_, index) in [1, 2, 3, 4, 5]" v-for="(_, index) in groups"
:key="index" :key="index"
@click="selectedIndex = index" @click="onSelect(index)"
> >
<text <text
:style="{ :style="{
@@ -66,23 +86,23 @@ const closeTip = () => {
class="question-mark" class="question-mark"
/> />
</view> </view>
<text>98.99</text> <text>{{ Number((data.stability || 0).toFixed(2)) }}</text>
</view> </view>
<view> <view>
<view>黄心率</view> <view>黄心率</view>
<text>86.3%</text> <text>{{ Number((data.yellowRate * 100).toFixed(2)) }}%</text>
</view> </view>
<view> <view>
<view>10环数</view> <view>10环数</view>
<text>65</text> <text>{{ data.tenRings }}</text>
</view> </view>
<view> <view>
<view>平均环数</view> <view>平均环数</view>
<text>8.99</text> <text>{{ Number((data.averageRing || 0).toFixed(2)) }}</text>
</view> </view>
<view> <view>
<view>总环数</view> <view>总环数</view>
<text>700/999</text> <text>{{ data.userTotalRing }}/{{ data.totalRing }}</text>
</view> </view>
</view> </view>
<view class="title-bar"> <view class="title-bar">
@@ -96,7 +116,7 @@ const closeTip = () => {
/> />
</button> </button>
</view> </view>
<BowTarget /> <BowTargetEdit :src="targetSrc" :arrows="arrows" />
<ScreenHint2 :show="showTip || showTip2" :onClose="closeTip"> <ScreenHint2 :show="showTip || showTip2" :onClose="closeTip">
<view class="tip-content"> <view class="tip-content">
<block v-if="showTip"> <block v-if="showTip">

View File

@@ -46,9 +46,9 @@ const onSubmit = async () => {
amount.value, amount.value,
Object.values(arrowGroups.value) Object.values(arrowGroups.value)
); );
if (res.id) { if (res.record_id) {
uni.redirectTo({ uni.redirectTo({
url: `/pages/point-book-detail?id=${res.id}`, url: `/pages/point-book-detail?id=${res.record_id}`,
}); });
} }
} }

View File

@@ -7,15 +7,20 @@ import PointRecord from "@/components/PointRecord.vue";
import ScrollList from "@/components/ScrollList.vue"; import ScrollList from "@/components/ScrollList.vue";
import { getPointBookListAPI } from "@/apis"; import { getPointBookListAPI } from "@/apis";
const bowType = ref(""); const bowType = ref({});
const distance = ref(0); const distance = ref(0);
const bowtargetType = ref(""); const bowtargetType = ref({});
const showModal = ref(false); const showModal = ref(false);
const selectorIndex = ref(0); const selectorIndex = ref(0);
const list = ref([]); const list = ref([]);
const onListLoading = async (page) => { const onListLoading = async (page) => {
const result = await getPointBookListAPI(page, 1); const result = await getPointBookListAPI(
page,
bowType.value.id,
distance.value,
bowtargetType.value.id
);
if (page === 1) { if (page === 1) {
list.value = result; list.value = result;
} else { } else {
@@ -31,12 +36,14 @@ const openSelector = (index) => {
const onSelectOption = (itemIndex, value) => { const onSelectOption = (itemIndex, value) => {
if (itemIndex === 0) { if (itemIndex === 0) {
bowType.value = value; bowType.value = value.name === bowType.value.name ? {} : value;
} else if (itemIndex === 1) { } else if (itemIndex === 1) {
distance.value = value; distance.value = value === distance.value ? 0 : value;
} else if (itemIndex === 2) { } else if (itemIndex === 2) {
bowtargetType.value = value; bowtargetType.value = value.name === bowtargetType.value.name ? {} : value;
} }
showModal.value = false;
onListLoading(1);
}; };
const toDetailPage = (id) => { const toDetailPage = (id) => {
uni.navigateTo({ uni.navigateTo({
@@ -55,32 +62,32 @@ const toDetailPage = (id) => {
<view class="container"> <view class="container">
<view class="selectors"> <view class="selectors">
<view @click="() => openSelector(0)"> <view @click="() => openSelector(0)">
<text :style="{ color: bowType ? '#000' : '#999' }">{{ <text :style="{ color: bowType.name ? '#000' : '#999' }">{{
bowType || "请选择" bowType.name || "请选择"
}}</text> }}</text>
<image src="../static/arrow-grey.png" mode="widthFix" /> <image src="../static/arrow-grey.png" mode="widthFix" />
</view> </view>
<view @click="() => openSelector(1)"> <view @click="() => openSelector(1)">
<text :style="{ color: bowType ? '#000' : '#999' }">{{ <text :style="{ color: distance ? '#000' : '#999' }">{{
distance ? distance + " 米" : "请选择" distance ? distance + " 米" : "请选择"
}}</text> }}</text>
<image src="../static/arrow-grey.png" mode="widthFix" /> <image src="../static/arrow-grey.png" mode="widthFix" />
</view> </view>
<view @click="() => openSelector(2)"> <view @click="() => openSelector(2)">
<text :style="{ color: bowType ? '#000' : '#999' }">{{ <text :style="{ color: bowtargetType.name ? '#000' : '#999' }">{{
bowtargetType || "请选择" bowtargetType.name || "请选择"
}}</text> }}</text>
<image src="../static/arrow-grey.png" mode="widthFix" /> <image src="../static/arrow-grey.png" mode="widthFix" />
</view> </view>
</view> </view>
<view class="point-records"> <view class="point-records">
<ScrollList :onLoading="onMatchLoading"> <ScrollList :onLoading="onListLoading">
<view <view
v-for="(item, index) in list" v-for="(item, index) in list"
:key="index" :key="index"
@click="() => toDetailPage(item.id)" @click="() => toDetailPage(item.id)"
> >
<PointRecord /> <PointRecord :data="item" />
</view> </view>
</ScrollList> </ScrollList>
</view> </view>
@@ -99,6 +106,7 @@ const toDetailPage = (id) => {
:expand="true" :expand="true"
:noArrow="true" :noArrow="true"
:onSelect="onSelectOption" :onSelect="onSelectOption"
:value="bowType.name"
/> />
<EditOption <EditOption
v-show="selectorIndex === 1" v-show="selectorIndex === 1"
@@ -106,6 +114,7 @@ const toDetailPage = (id) => {
:expand="true" :expand="true"
:noArrow="true" :noArrow="true"
:onSelect="onSelectOption" :onSelect="onSelectOption"
:value="distance + ''"
/> />
<EditOption <EditOption
v-show="selectorIndex === 2" v-show="selectorIndex === 2"
@@ -113,6 +122,7 @@ const toDetailPage = (id) => {
:expand="true" :expand="true"
:noArrow="true" :noArrow="true"
:onSelect="onSelectOption" :onSelect="onSelectOption"
:value="bowtargetType.name"
/> />
</view> </view>
</SModal> </SModal>
@@ -170,5 +180,6 @@ const toDetailPage = (id) => {
} }
.point-records { .point-records {
padding: 15px; padding: 15px;
height: calc(100% - 30px);
} }
</style> </style>