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

乡村旅居筛选优化

parent 23189d75
......@@ -10,16 +10,17 @@
>
{{ item.startDate }}
</li>
<wd-calendar use-default-slot v-model="value" @confirm="handleConfirm4">
<li>选择日期</li>
<wd-calendar use-default-slot v-model="value" @confirm="handleConfirm">
<li @tap="selectItem(index, item)">选择日期</li>
</wd-calendar>
</ul>
</view>
</template>
<script setup>
import { defineProps, onMounted } from 'vue';
import { defineProps, onMounted, ref } from 'vue';
import { getStartDate } from '@/api/assistingAgriculture/village';
const selectedItem = ref(null);
const emit = defineEmits(['dataParams']);
const dataList = ref([]);
......@@ -35,21 +36,33 @@ const props = defineProps({
default: '100%',
},
});
onMounted(async () => {
getStartDateList();
});
const selectItem = (index, item) => {
console.log(item, 323);
const datePart = timestampToDateBasic(value.value);
selectedItem.value = index;
emit('dataParams', item);
emit('dataParams', item, datePart);
console.log(datePart, 'datePart');
};
// 查询出发日期
const getStartDateList = () => {
getStartDate(params).then((res) => {
dataList.value = res.data;
});
};
function handleConfirm4({ value }) {
formatValue.value = new Date(value).toString();
function handleConfirm({ value }) {
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>
......
......@@ -180,6 +180,7 @@ const sortType = ref(null);
const attractionId = ref(null);
const startCity = ref(null);
const dateType = ref(null);
const allocateDate = ref(null);
const serviceCommitment = ref(null);
const labelId = ref(null);
const locationFiltering = (index) => {
......@@ -233,10 +234,16 @@ const sortParams = (sortMode) => {
getProd();
};
// 出发日期
const dataParams = (item) => {
console.log(item, item.key, 22322323);
const dataParams = (item, datePart) => {
if (item !== undefined) {
dateType.value = item.key;
getProd();
} else if (item === undefined) {
console.log(item, 3333333);
dateType.value = 8;
allocateDate.value = datePart;
getProd();
}
};
// 景点
const placeParams = (id) => {
......@@ -262,10 +269,11 @@ const getProd = () => {
size: 10,
...(sortType.value !== null && { sortType: sortType.value.sortMode }),
...(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 }),
...(serviceCommitment.value !== null && { serviceCommitment: serviceCommitment.value }),
...(labelId.value !== null && { labelId: labelId.value }),
...(dateType.value === 8 && { allocateDate: allocateDate.value }),
};
getProdList(params).then((res) => {
res.data.records.forEach((item) => {
......@@ -274,6 +282,7 @@ const getProd = () => {
cardList.value = res.data.records;
});
};
function toRouteDetails(item) {
console.log(item, 22222);
// 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