Commit fd021984 authored by 刘玉宏's avatar 刘玉宏
parents 4f691bbe 6313c6be
...@@ -6,21 +6,25 @@ ...@@ -6,21 +6,25 @@
v-for="(item, index) in dataList" v-for="(item, index) in dataList"
:key="index" :key="index"
:class="{ active: selectedItem === index }" :class="{ active: selectedItem === index }"
@tap="selectItem(index)" @tap="selectItem(index, item)"
> >
{{ item }} {{ item }}
</li> </li>
<wd-calendar use-default-slot v-model="value" @confirm="handleConfirm4">
<li>选择日期</li> <li>选择日期</li>
</wd-calendar>
</ul> </ul>
</view> </view>
</template> </template>
<script setup> <script setup>
import { defineProps, onMounted } from 'vue'; import { defineProps, onMounted } from 'vue';
import { getStartDate, getTour } from '@/api/assistingAgriculture/village'; import { getStartDate } from '@/api/assistingAgriculture/village';
const items = reactive(['日期不限', '今天', '明天', '一周内', '一月内', '本周末', '七夕节']);
const selectedItem = ref(null); const selectedItem = ref(null);
const emit = defineEmits(['dataParams']);
const dataList = ref([]); const dataList = ref([]);
const value = ref('');
const formatValue = ref('');
const params = { const params = {
current: 1, current: 1,
size: 10, size: 10,
...@@ -34,15 +38,20 @@ const props = defineProps({ ...@@ -34,15 +38,20 @@ const props = defineProps({
onMounted(async () => { onMounted(async () => {
getStartDateList(); getStartDateList();
}); });
const selectItem = (selectItem) => { const selectItem = (index, item) => {
selectedItem.value = selectItem; selectedItem.value = index;
emit('dataParams', item);
}; };
// 查询景点 // 查询出发日期
const getStartDateList = () => { const getStartDateList = () => {
getStartDate(params).then((res) => { getStartDate(params).then((res) => {
dataList.value = res.data; dataList.value = res.data;
console.log(Object.keys(dataList.value, 232));
}); });
}; };
function handleConfirm4({ value }) {
formatValue.value = new Date(value).toString();
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -111,9 +111,9 @@ ...@@ -111,9 +111,9 @@
</view> </view>
</view> </view>
<Sort v-show="rotate" @sortParams="sortParams" /> <Sort v-show="rotate" @sortParams="sortParams" />
<DepartureDate v-show="rotate2" /> <DepartureDate v-show="rotate2" @dataParams="dataParams" />
<ScenicSpots v-show="rotate3" @placeParams="placeParams" /> <ScenicSpots v-show="rotate3" @placeParams="placeParams" />
<Screen v-show="rotate4" /> <Screen v-show="rotate4" @screenParams="screenParams" />
</view> </view>
<view class="list-card"> <view class="list-card">
<view <view
...@@ -173,6 +173,7 @@ const cardList = ref([]); ...@@ -173,6 +173,7 @@ const cardList = ref([]);
const popularRouterData = ref([]); const popularRouterData = ref([]);
const sortType = ref(null); const sortType = ref(null);
const attractionId = ref(null); const attractionId = ref(null);
const dateType = ref(null);
const locationFiltering = (index) => { const locationFiltering = (index) => {
switch (index) { switch (index) {
case 0: case 0:
...@@ -203,6 +204,7 @@ const locationFiltering = (index) => { ...@@ -203,6 +204,7 @@ const locationFiltering = (index) => {
if (index === 0) { if (index === 0) {
sortType.value = null; sortType.value = null;
attractionId.value = null; attractionId.value = null;
dateType.value = null;
} }
}; };
// 查询热门路线 // 查询热门路线
...@@ -214,15 +216,20 @@ const getPopular = () => { ...@@ -214,15 +216,20 @@ const getPopular = () => {
popularRouterData.value = res.data.records; popularRouterData.value = res.data.records;
}); });
}; };
// 智能排序
const sortParams = (sortMode) => { const sortParams = (sortMode) => {
sortType.value = sortMode; sortType.value = sortMode;
console.log(sortType.value, 211);
getProd(); getProd();
}; };
// 出发日期
const dataParams = (item) => {
console.log(item, 333);
dateType.value = item;
getProd();
};
// 景点
const placeParams = (id) => { const placeParams = (id) => {
console.log(id, 444);
attractionId.value = id; attractionId.value = id;
console.log(attractionId.value, 211);
getProd(); getProd();
}; };
// 查询列表 // 查询列表
...@@ -232,14 +239,13 @@ const getProd = () => { ...@@ -232,14 +239,13 @@ 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 }),
}; };
console.log(params, 222);
getProdList(params).then((res) => { getProdList(params).then((res) => {
res.data.records.forEach((item) => { res.data.records.forEach((item) => {
item.img = import.meta.env.VITE_APP_IMG_URL + item.pic; item.img = import.meta.env.VITE_APP_IMG_URL + item.pic;
}); });
cardList.value = res.data.records; cardList.value = res.data.records;
console.log(res, 222);
}); });
}; };
function toRouteDetails() { function toRouteDetails() {
......
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