Commit 493cd4a5 authored by 张娇(东信)'s avatar 张娇(东信)

乡村旅居筛选优化

parent 23189d75
...@@ -10,16 +10,17 @@ ...@@ -10,16 +10,17 @@
> >
{{ item.startDate }} {{ item.startDate }}
</li> </li>
<wd-calendar use-default-slot v-model="value" @confirm="handleConfirm4"> <wd-calendar use-default-slot v-model="value" @confirm="handleConfirm">
<li>选择日期</li> <li @tap="selectItem(index, item)">选择日期</li>
</wd-calendar> </wd-calendar>
</ul> </ul>
</view> </view>
</template> </template>
<script setup> <script setup>
import { defineProps, onMounted } from 'vue'; import { defineProps, onMounted, ref } from 'vue';
import { getStartDate } from '@/api/assistingAgriculture/village'; import { getStartDate } from '@/api/assistingAgriculture/village';
const selectedItem = ref(null); const selectedItem = ref(null);
const emit = defineEmits(['dataParams']); const emit = defineEmits(['dataParams']);
const dataList = ref([]); const dataList = ref([]);
...@@ -35,21 +36,33 @@ const props = defineProps({ ...@@ -35,21 +36,33 @@ const props = defineProps({
default: '100%', default: '100%',
}, },
}); });
onMounted(async () => { onMounted(async () => {
getStartDateList(); getStartDateList();
}); });
const selectItem = (index, item) => { const selectItem = (index, item) => {
console.log(item, 323);
const datePart = timestampToDateBasic(value.value);
selectedItem.value = index; selectedItem.value = index;
emit('dataParams', item); emit('dataParams', item, datePart);
console.log(datePart, 'datePart');
}; };
// 查询出发日期
const getStartDateList = () => { const getStartDateList = () => {
getStartDate(params).then((res) => { getStartDate(params).then((res) => {
dataList.value = res.data; dataList.value = res.data;
}); });
}; };
function handleConfirm4({ value }) { function handleConfirm({ value }) {
formatValue.value = new Date(value).toString(); const datePart = timestampToDateBasic(value);
console.log(datePart, 'datePart---111');
selectItem(undefined, undefined);
}
function timestampToDateBasic(timestamp) {
const date = new Date(timestamp);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
return `${year}/${month}/${day}`;
} }
</script> </script>
......
...@@ -180,6 +180,7 @@ const sortType = ref(null); ...@@ -180,6 +180,7 @@ const sortType = ref(null);
const attractionId = ref(null); const attractionId = ref(null);
const startCity = ref(null); const startCity = ref(null);
const dateType = ref(null); const dateType = ref(null);
const allocateDate = ref(null);
const serviceCommitment = ref(null); const serviceCommitment = ref(null);
const labelId = ref(null); const labelId = ref(null);
const locationFiltering = (index) => { const locationFiltering = (index) => {
...@@ -233,10 +234,16 @@ const sortParams = (sortMode) => { ...@@ -233,10 +234,16 @@ const sortParams = (sortMode) => {
getProd(); getProd();
}; };
// 出发日期 // 出发日期
const dataParams = (item) => { const dataParams = (item, datePart) => {
console.log(item, item.key, 22322323); if (item !== undefined) {
dateType.value = item.key; dateType.value = item.key;
getProd(); getProd();
} else if (item === undefined) {
console.log(item, 3333333);
dateType.value = 8;
allocateDate.value = datePart;
getProd();
}
}; };
// 景点 // 景点
const placeParams = (id) => { const placeParams = (id) => {
...@@ -262,10 +269,11 @@ const getProd = () => { ...@@ -262,10 +269,11 @@ const getProd = () => {
size: 10, size: 10,
...(sortType.value !== null && { sortType: sortType.value.sortMode }), ...(sortType.value !== null && { sortType: sortType.value.sortMode }),
...(attractionId.value !== null && { attractionId: attractionId.value.id }), ...(attractionId.value !== null && { attractionId: attractionId.value.id }),
...(dateType.value !== null && { dateType: dateType.value.key }), ...(dateType.value !== null && { dateType: dateType.value }),
...(startCity.value !== null && { startCity: startCity.value }), ...(startCity.value !== null && { startCity: startCity.value }),
...(serviceCommitment.value !== null && { serviceCommitment: serviceCommitment.value }), ...(serviceCommitment.value !== null && { serviceCommitment: serviceCommitment.value }),
...(labelId.value !== null && { labelId: labelId.value }), ...(labelId.value !== null && { labelId: labelId.value }),
...(dateType.value === 8 && { allocateDate: allocateDate.value }),
}; };
getProdList(params).then((res) => { getProdList(params).then((res) => {
res.data.records.forEach((item) => { res.data.records.forEach((item) => {
...@@ -274,6 +282,7 @@ const getProd = () => { ...@@ -274,6 +282,7 @@ const getProd = () => {
cardList.value = res.data.records; cardList.value = res.data.records;
}); });
}; };
function toRouteDetails(item) { function toRouteDetails(item) {
console.log(item, 22222); console.log(item, 22222);
// TODO: 跳转到线路详情 // TODO: 跳转到线路详情
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment