...
This commit is contained in:
22
src/apis.js
22
src/apis.js
@@ -368,9 +368,31 @@ export const getPointBookConfigAPI = async () => {
|
||||
return request("GET", "/user/score/sheet/option");
|
||||
};
|
||||
|
||||
export const savePointBookAPI = async (
|
||||
bowType,
|
||||
distance,
|
||||
targetType,
|
||||
groups,
|
||||
arrows,
|
||||
group_data = []
|
||||
) => {
|
||||
return request("POST", "/user/score/sheet/report", {
|
||||
bowType,
|
||||
distance,
|
||||
targetType,
|
||||
groups,
|
||||
arrows,
|
||||
group_data,
|
||||
});
|
||||
};
|
||||
|
||||
export const getPointBookListAPI = async (page = 1, size = 10) => {
|
||||
return request(
|
||||
"GET",
|
||||
`/user/score/sheet/list?pageNum=${page}&pageSize=${size}`
|
||||
);
|
||||
};
|
||||
|
||||
export const getPointBookDetailAPI = async (id) => {
|
||||
return request("GET", `/user/score/sheet/detail?id=${id}`);
|
||||
};
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import BowTarget from "@/components/BowTarget.vue";
|
||||
import ScreenHint2 from "@/components/ScreenHint2.vue";
|
||||
|
||||
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 showTip = ref(false);
|
||||
const showTip2 = ref(false);
|
||||
|
||||
@@ -4,6 +4,7 @@ import Container from "@/components/Container.vue";
|
||||
import ScreenHint2 from "@/components/ScreenHint2.vue";
|
||||
import SButton from "@/components/SButton.vue";
|
||||
import BowTargetEdit from "@/components/BowTargetEdit.vue";
|
||||
import { savePointBookAPI } from "@/apis";
|
||||
|
||||
const clickable = ref(false);
|
||||
const showTip = ref(false);
|
||||
@@ -27,22 +28,29 @@ const ringTypes = ref([
|
||||
{ ring: "1", color: "#d8d8d8" },
|
||||
]);
|
||||
|
||||
const onEdit = (arrows) => {
|
||||
arrowGroups.value[currentGroup.value][currentArrow.value] = { ring };
|
||||
};
|
||||
|
||||
const onBack = () => {
|
||||
uni.navigateBack();
|
||||
};
|
||||
const onSubmit = () => {
|
||||
const onSubmit = async () => {
|
||||
if (currentGroup.value < groups.value) {
|
||||
currentGroup.value++;
|
||||
currentArrow.value = 0;
|
||||
clickable.value = false;
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: `/pages/point-book-detail`,
|
||||
});
|
||||
const pointBook = uni.getStorageSync("point-book");
|
||||
const res = await savePointBookAPI(
|
||||
pointBook.bowType.id,
|
||||
pointBook.distance,
|
||||
pointBook.bowtargetType.id,
|
||||
groups.value,
|
||||
amount.value,
|
||||
Object.values(arrowGroups.value)
|
||||
);
|
||||
if (res.id) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/point-book-detail?id=${res.id}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
const onClickRing = (ring) => {
|
||||
@@ -59,6 +67,9 @@ const deleteArrow = () => {
|
||||
};
|
||||
const onEditDone = (arrow) => {
|
||||
arrowGroups.value[currentGroup.value][currentArrow.value] = arrow;
|
||||
clickable.value = arrowGroups.value[currentGroup.value].every(
|
||||
(item) => !!item.ring
|
||||
);
|
||||
if (currentArrow.value < amount.value - 1) currentArrow.value++;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,12 +4,25 @@ import Container from "@/components/Container.vue";
|
||||
import SModal from "@/components/SModal.vue";
|
||||
import EditOption from "@/components/EditOption.vue";
|
||||
import PointRecord from "@/components/PointRecord.vue";
|
||||
import ScrollList from "@/components/ScrollList.vue";
|
||||
import { getPointBookListAPI } from "@/apis";
|
||||
|
||||
const bowType = ref("");
|
||||
const distance = ref(0);
|
||||
const bowtargetType = ref("");
|
||||
const showModal = ref(false);
|
||||
const selectorIndex = ref(0);
|
||||
const list = ref([]);
|
||||
|
||||
const onListLoading = async (page) => {
|
||||
const result = await getPointBookListAPI(page, 1);
|
||||
if (page === 1) {
|
||||
list.value = result;
|
||||
} else {
|
||||
list.value = list.value.concat(result);
|
||||
}
|
||||
return result.length;
|
||||
};
|
||||
|
||||
const openSelector = (index) => {
|
||||
selectorIndex.value = index;
|
||||
@@ -25,9 +38,9 @@ const onSelectOption = (itemIndex, value) => {
|
||||
bowtargetType.value = value;
|
||||
}
|
||||
};
|
||||
const toDetailPage = (record) => {
|
||||
const toDetailPage = (id) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/point-book-detail?id=${record.id}`,
|
||||
url: `/pages/point-book-detail?id=${id}`,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
@@ -61,9 +74,15 @@ const toDetailPage = (record) => {
|
||||
</view>
|
||||
</view>
|
||||
<view class="point-records">
|
||||
<view v-for="i in 4" :key="i" @click="toDetailPage">
|
||||
<PointRecord />
|
||||
</view>
|
||||
<ScrollList :onLoading="onMatchLoading">
|
||||
<view
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
@click="() => toDetailPage(item.id)"
|
||||
>
|
||||
<PointRecord />
|
||||
</view>
|
||||
</ScrollList>
|
||||
</view>
|
||||
<SModal
|
||||
:show="showModal"
|
||||
|
||||
Reference in New Issue
Block a user