Files
shoot-miniprograms/src/pages/point-book-create.vue

190 lines
4.5 KiB
Vue
Raw Normal View History

2025-07-29 10:46:37 +08:00
<script setup>
2025-08-25 13:47:32 +08:00
import { ref, onMounted } from "vue";
2025-09-24 21:05:06 +08:00
import { onShow } from "@dcloudio/uni-app";
2025-07-29 10:46:37 +08:00
import Container from "@/components/Container.vue";
import EditOption from "@/components/EditOption.vue";
import SButton from "@/components/SButton.vue";
2025-08-13 17:11:30 +08:00
import { getPointBookDataAPI } from "@/apis";
2025-07-29 10:46:37 +08:00
2025-08-07 09:21:30 +08:00
const expandIndex = ref(0);
2025-08-04 16:28:34 +08:00
const bowType = ref({});
2025-07-29 10:46:37 +08:00
const distance = ref(0);
const bowtargetType = ref("");
const amountGroup = ref("");
2025-08-06 18:36:30 +08:00
const days = ref(0);
const arrows = ref(0);
2025-07-29 10:46:37 +08:00
const onExpandChange = (index, expand) => {
2025-08-04 16:28:34 +08:00
if (expandIndex.value !== -1) {
expandIndex.value = -1;
setTimeout(() => {
expandIndex.value = !expand ? -1 : index;
}, 100);
} else {
expandIndex.value = !expand ? -1 : index;
}
2025-07-29 10:46:37 +08:00
};
const toListPage = () => {
uni.navigateTo({
url: "/pages/point-book-list",
});
};
const onSelect = (itemIndex, value) => {
if (itemIndex === 0) bowType.value = value;
else if (itemIndex === 1) distance.value = value;
else if (itemIndex === 2) bowtargetType.value = value;
else if (itemIndex === 3) amountGroup.value = value;
2025-08-07 09:21:30 +08:00
};
const toEditPage = () => {
2025-07-29 10:46:37 +08:00
if (
bowType.value &&
distance.value &&
bowtargetType.value &&
amountGroup.value
) {
2025-07-30 14:20:38 +08:00
uni.setStorageSync("point-book", {
bowType: bowType.value,
distance: distance.value,
bowtargetType: bowtargetType.value,
amountGroup: amountGroup.value,
});
2025-08-07 09:21:30 +08:00
uni.navigateTo({
url: "/pages/point-book-edit",
});
} else {
uni.showToast({
title: "请完善信息",
icon: "none",
});
2025-07-29 10:46:37 +08:00
}
};
2025-09-27 10:09:02 +08:00
// onShow(async () => {
// const result = await getPointBookDataAPI();
// if (result) {
// days.value = result.total_day || 0;
// arrows.value = result.total_arrow || 0;
// }
// });
2025-08-04 16:28:34 +08:00
onMounted(async () => {
2025-07-30 17:38:48 +08:00
const pointBook = uni.getStorageSync("point-book");
if (pointBook) {
bowType.value = pointBook.bowType;
distance.value = pointBook.distance;
bowtargetType.value = pointBook.bowtargetType;
2025-08-09 12:19:39 +08:00
expandIndex.value = 3;
2025-07-30 17:38:48 +08:00
}
});
2025-07-29 10:46:37 +08:00
</script>
<template>
<Container
:bgType="2"
bgColor="#F5F5F5"
:whiteBackArrow="false"
2025-09-27 10:09:02 +08:00
title="选择参数"
2025-07-29 10:46:37 +08:00
>
<view class="container">
2025-09-27 10:09:02 +08:00
<!-- <view class="header">
2025-08-06 18:36:30 +08:00
<image
src="https://static.shelingxingqiu.com/attachment/2025-08-06/dbv8w5ak76hozbfpy2.png"
mode="widthFix"
/>
<view>
<view>
<text>{{ days }}</text>
<text></text>
</view>
<text>训练天数</text>
</view>
<view>
<view>
<text>{{ arrows }}</text>
<text></text>
</view>
<text>训练箭数</text>
</view>
2025-09-27 10:09:02 +08:00
</view> -->
2025-07-30 09:55:15 +08:00
<view>
<EditOption
:itemIndex="0"
:expand="expandIndex === 0"
:onExpand="onExpandChange"
:onSelect="onSelect"
2025-08-04 16:28:34 +08:00
:value="bowType.name"
2025-07-30 09:55:15 +08:00
/>
<EditOption
:itemIndex="1"
:expand="expandIndex === 1"
:onExpand="onExpandChange"
:onSelect="onSelect"
2025-07-30 17:38:48 +08:00
:value="distance + ''"
2025-07-30 09:55:15 +08:00
/>
<EditOption
:itemIndex="2"
:expand="expandIndex === 2"
:onExpand="onExpandChange"
:onSelect="onSelect"
2025-08-04 16:28:34 +08:00
:value="bowtargetType.name"
2025-07-30 09:55:15 +08:00
/>
<EditOption
:itemIndex="3"
:expand="expandIndex === 3"
:onExpand="onExpandChange"
:onSelect="onSelect"
/>
</view>
2025-07-29 10:46:37 +08:00
</view>
<view :style="{ marginBottom: '20px' }">
2025-09-27 10:09:02 +08:00
<SButton :rounded="50" :onClick="toEditPage">下一步</SButton>
2025-07-29 10:46:37 +08:00
<view class="see-more" @click="toListPage">
<text>历史计分记录</text>
<image src="../static/enter-arrow-blue.png" mode="widthFix" />
</view>
</view>
</Container>
</template>
<style scoped>
.container {
width: calc(100% - 20px);
2025-08-11 09:13:43 +08:00
padding: 0 10px;
2025-07-29 10:46:37 +08:00
display: flex;
flex-direction: column;
align-items: center;
}
2025-08-06 18:36:30 +08:00
.container > view:nth-child(2) {
margin: 0 10px;
}
.header {
width: 100%;
height: 27vw;
position: relative;
display: flex;
align-items: center;
color: #ffffffc7;
font-size: 14px;
2025-08-07 11:04:12 +08:00
margin-top: 10px;
2025-08-06 18:36:30 +08:00
}
.header > image {
position: absolute;
2025-07-29 10:46:37 +08:00
width: 100%;
border: 2px solid #fff;
box-sizing: border-box;
border-radius: 10px;
}
2025-08-06 18:36:30 +08:00
.header > view {
position: relative;
}
.header > view:nth-child(2) {
margin-left: 7vw;
margin-right: 7vw;
}
.header > view > view > text:first-child {
font-size: 27px;
font-weight: 500;
margin-right: 5px;
2025-08-09 12:19:39 +08:00
color: #fff4c9;
2025-07-30 09:55:15 +08:00
}
2025-07-29 10:46:37 +08:00
</style>