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

186 lines
4.6 KiB
Vue
Raw Normal View History

2025-07-29 10:46:37 +08:00
<script setup>
import { ref, onMounted, onUnmounted } from "vue";
import Container from "@/components/Container.vue";
2025-07-30 09:55:15 +08:00
import SModal from "@/components/SModal.vue";
import EditOption from "@/components/EditOption.vue";
import PointRecord from "@/components/PointRecord.vue";
2025-08-04 17:54:59 +08:00
import ScrollList from "@/components/ScrollList.vue";
import { getPointBookListAPI } from "@/apis";
2025-07-30 09:55:15 +08:00
2025-08-05 11:51:09 +08:00
const bowType = ref({});
2025-07-30 09:55:15 +08:00
const distance = ref(0);
2025-08-05 11:51:09 +08:00
const bowtargetType = ref({});
2025-07-30 09:55:15 +08:00
const showModal = ref(false);
const selectorIndex = ref(0);
2025-08-04 17:54:59 +08:00
const list = ref([]);
const onListLoading = async (page) => {
2025-08-05 11:51:09 +08:00
const result = await getPointBookListAPI(
page,
bowType.value.id,
distance.value,
bowtargetType.value.id
);
2025-08-04 17:54:59 +08:00
if (page === 1) {
list.value = result;
} else {
list.value = list.value.concat(result);
}
return result.length;
};
2025-07-30 09:55:15 +08:00
const openSelector = (index) => {
selectorIndex.value = index;
showModal.value = true;
};
const onSelectOption = (itemIndex, value) => {
if (itemIndex === 0) {
2025-08-05 11:51:09 +08:00
bowType.value = value.name === bowType.value.name ? {} : value;
2025-07-30 09:55:15 +08:00
} else if (itemIndex === 1) {
2025-08-05 11:51:09 +08:00
distance.value = value === distance.value ? 0 : value;
2025-07-30 09:55:15 +08:00
} else if (itemIndex === 2) {
2025-08-05 11:51:09 +08:00
bowtargetType.value = value.name === bowtargetType.value.name ? {} : value;
2025-07-30 09:55:15 +08:00
}
2025-08-05 11:51:09 +08:00
showModal.value = false;
onListLoading(1);
2025-07-30 09:55:15 +08:00
};
2025-08-04 17:54:59 +08:00
const toDetailPage = (id) => {
2025-07-30 09:55:15 +08:00
uni.navigateTo({
2025-08-04 17:54:59 +08:00
url: `/pages/point-book-detail?id=${id}`,
2025-07-30 09:55:15 +08:00
});
};
2025-07-29 10:46:37 +08:00
</script>
<template>
<Container
:bgType="2"
bgColor="#F5F5F5"
:whiteBackArrow="false"
title="计分记录"
>
2025-07-30 09:55:15 +08:00
<view class="container">
<view class="selectors">
<view @click="() => openSelector(0)">
2025-08-05 11:51:09 +08:00
<text :style="{ color: bowType.name ? '#000' : '#999' }">{{
bowType.name || "请选择"
2025-07-30 09:55:15 +08:00
}}</text>
<image src="../static/arrow-grey.png" mode="widthFix" />
</view>
<view @click="() => openSelector(1)">
2025-08-05 11:51:09 +08:00
<text :style="{ color: distance ? '#000' : '#999' }">{{
2025-07-30 09:55:15 +08:00
distance ? distance + " 米" : "请选择"
}}</text>
<image src="../static/arrow-grey.png" mode="widthFix" />
</view>
<view @click="() => openSelector(2)">
2025-08-05 11:51:09 +08:00
<text :style="{ color: bowtargetType.name ? '#000' : '#999' }">{{
bowtargetType.name || "请选择"
2025-07-30 09:55:15 +08:00
}}</text>
<image src="../static/arrow-grey.png" mode="widthFix" />
</view>
</view>
<view class="point-records">
2025-08-05 11:51:09 +08:00
<ScrollList :onLoading="onListLoading">
2025-08-04 17:54:59 +08:00
<view
v-for="(item, index) in list"
:key="index"
@click="() => toDetailPage(item.id)"
>
2025-08-05 11:51:09 +08:00
<PointRecord :data="item" />
2025-08-04 17:54:59 +08:00
</view>
</ScrollList>
2025-07-30 09:55:15 +08:00
</view>
<SModal
:show="showModal"
:noBg="true"
:onClose="() => (showModal = false)"
>
<view class="selector">
<button hover-class="none" @click="() => (showModal = false)">
<image src="../static/close-grey.png" mode="widthFix" />
</button>
<EditOption
v-show="selectorIndex === 0"
:itemIndex="0"
:expand="true"
:noArrow="true"
:onSelect="onSelectOption"
2025-08-05 11:51:09 +08:00
:value="bowType.name"
2025-07-30 09:55:15 +08:00
/>
<EditOption
v-show="selectorIndex === 1"
:itemIndex="1"
:expand="true"
:noArrow="true"
:onSelect="onSelectOption"
2025-08-05 11:51:09 +08:00
:value="distance + ''"
2025-07-30 09:55:15 +08:00
/>
<EditOption
v-show="selectorIndex === 2"
:itemIndex="2"
:expand="true"
:noArrow="true"
:onSelect="onSelectOption"
2025-08-05 11:51:09 +08:00
:value="bowtargetType.name"
2025-07-30 09:55:15 +08:00
/>
</view>
</SModal>
</view>
2025-07-29 10:46:37 +08:00
</Container>
</template>
2025-07-30 09:55:15 +08:00
<style scoped>
.container {
width: 100%;
height: 100%;
}
.selectors {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 15px;
}
.selectors > view {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #fff;
height: 55px;
border-radius: 12px;
color: #333;
font-size: 13px;
width: 26vw;
}
.selectors > view:last-child {
width: 34vw;
}
.selectors > view > text {
width: calc(100% - 11vw);
text-align: center;
margin-left: 3vw;
}
.selectors > view > image {
width: 5vw;
margin-right: 3vw;
}
.selector {
padding: 10px;
background-color: #fff;
border-radius: 10px;
position: relative;
}
.selector > button {
position: absolute;
top: 0;
right: 0;
}
.selector > button > image {
width: 40px;
}
.point-records {
padding: 15px;
2025-08-05 11:51:09 +08:00
height: calc(100% - 30px);
2025-07-30 09:55:15 +08:00
}
</style>