feat: 实现了日历的选择组件与快速预定的接口请求联动
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
<CreateServiceOrder v-else-if="item.toolCall.componentName === CompName.createWorkOrderCard"/>
|
<CreateServiceOrder v-else-if="item.toolCall.componentName === CompName.createWorkOrderCard"/>
|
||||||
</template>
|
</template>
|
||||||
<template #footer >
|
<template #footer >
|
||||||
<text> 这个是底部 </text>
|
<!-- <text> 这个是底部 </text> -->
|
||||||
</template>
|
</template>
|
||||||
</ChatCardAI>
|
</ChatCardAI>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<!-- :style="backgroundStyle" -->
|
<!-- :style="backgroundStyle" -->
|
||||||
<view class="top-item1-left">
|
<view class="top-item1-left">
|
||||||
<image :src="initPageImages.welcomeImageUrl"></image>
|
<image :src="initPageImages.welcomeImageUrl"></image>
|
||||||
<text>{{ currentDate }} 多云 -3~6℃ ff </text>
|
<text>{{ currentDate }} 多云 -3~6℃ cc </text>
|
||||||
</view>
|
</view>
|
||||||
<view class="top-item1-right">
|
<view class="top-item1-right">
|
||||||
<image :src="initPageImages.logoImageUrl"></image>
|
<image :src="initPageImages.logoImageUrl"></image>
|
||||||
|
|||||||
119
pages/module/booking/QuickBookingCalender.vue
Normal file
119
pages/module/booking/QuickBookingCalender.vue
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<template>
|
||||||
|
<view class="date-picker">
|
||||||
|
<view class="date-list">
|
||||||
|
<view
|
||||||
|
v-for="(item, index) in dates"
|
||||||
|
:key="index"
|
||||||
|
class="date-item"
|
||||||
|
:class="{ active: index === activeIndex }"
|
||||||
|
@click="selectDate(index)"
|
||||||
|
>
|
||||||
|
<text class="label">{{ item.label }}</text>
|
||||||
|
<text class="date">{{ item.date }}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 日历按钮 -->
|
||||||
|
<view class="calendar-btn btn-bom" @click="openCalendar">
|
||||||
|
<image src="/static/booking_calendar.png" mode="widthFix" class="calendar-img" />
|
||||||
|
<text class="calendar-text">日历</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
const emit = defineEmits(['update:date']); // 声明事件
|
||||||
|
|
||||||
|
const activeIndex = ref(2); // 默认今天
|
||||||
|
const dates = ref([]);
|
||||||
|
|
||||||
|
// 初始化日期(前天、昨天、今天、明天、后天)
|
||||||
|
const initDates = () => {
|
||||||
|
const today = new Date();
|
||||||
|
const labels = ['前天', '昨天', '今天', '明天', '后天'];
|
||||||
|
for (let i = -2; i <= 2; i++) {
|
||||||
|
const d = new Date(today);
|
||||||
|
d.setDate(today.getDate() + i);
|
||||||
|
const month = d.getMonth() + 1;
|
||||||
|
const day = d.getDate();
|
||||||
|
dates.value.push({
|
||||||
|
label: labels[i + 2],
|
||||||
|
date: `${month}/${day}`,
|
||||||
|
fullDate: `${d.getFullYear()}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectDate = (index) => {
|
||||||
|
activeIndex.value = index;
|
||||||
|
emit('update:date', dates.value[index]); // 传回父组件
|
||||||
|
};
|
||||||
|
|
||||||
|
const openCalendar = () => {
|
||||||
|
uni.showToast({ title: '打开日历', icon: 'none' });
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initDates();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.date-picker {
|
||||||
|
background: rgba(140, 236, 255, 0.24);
|
||||||
|
padding: 8rpx 0;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-list {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-item,
|
||||||
|
.calendar-btn {
|
||||||
|
flex: 1; /* 等宽 */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 12rpx 0;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
.date {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-item.active {
|
||||||
|
background-color: #00A6FF;
|
||||||
|
}
|
||||||
|
.date-item.active .label,
|
||||||
|
.date-item.active .date {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日历按钮 */
|
||||||
|
.calendar-btn {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 0 16rpx 16rpx 0;
|
||||||
|
margin: -8rpx 0;
|
||||||
|
box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1); /* 阴影 */
|
||||||
|
}
|
||||||
|
.calendar-img {
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
}
|
||||||
|
.calendar-text {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #666;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="calendar"></view>
|
<QuickBookingCalender class="calendar" @update:date="onDateSelected" />
|
||||||
|
<view v-for="item in commodityGroupDTOList" :key="commodityGroupKey(item.title)">
|
||||||
<view v-for="item in commodityGroupDTOList" :key="item.title">
|
|
||||||
|
|
||||||
<QuickBookingContentList :commodityDTO="item" />
|
<QuickBookingContentList :commodityDTO="item" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -11,25 +9,50 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import QuickBookingCalender from './QuickBookingCalender.vue'
|
||||||
import QuickBookingContentList from './QuickBookingContentList.vue'
|
import QuickBookingContentList from './QuickBookingContentList.vue'
|
||||||
import { ref, nextTick } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { quickBookingComponent } from '@/request/api/MainPageDataApi'
|
import { quickBookingComponent } from '@/request/api/MainPageDataApi'
|
||||||
import { SCROLL_TO_BOTTOM } from '@/constant/constant'
|
import { SCROLL_TO_BOTTOM } from '@/constant/constant'
|
||||||
|
|
||||||
|
const selectedDate = ref({});
|
||||||
|
|
||||||
const commodityGroupDTOList = ref([])
|
const commodityGroupDTOList = ref([])
|
||||||
|
const formattedDate = ref('')
|
||||||
|
|
||||||
const loadQuickBookingComponent = async () => {
|
const loadQuickBookingComponent = async () => {
|
||||||
const res = await quickBookingComponent('2025-07-29')
|
formattedDate.value = formatDate(selectedDate.value.fullDate || new Date());
|
||||||
|
const res = await quickBookingComponent(formattedDate.value)
|
||||||
if(res.code === 0 && res.data) {
|
if(res.code === 0 && res.data) {
|
||||||
commodityGroupDTOList.value.push(...res.data.commodityGroupDTOList)
|
commodityGroupDTOList.value = res.data.commodityGroupDTOList
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
uni.$emit(SCROLL_TO_BOTTOM, true)
|
setTimeout(() => {
|
||||||
|
uni.$emit(SCROLL_TO_BOTTOM, true)
|
||||||
|
}, 300)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onDateSelected = (date) => {
|
||||||
|
console.log('Selected date:', date);
|
||||||
|
selectedDate.value = date;
|
||||||
|
loadQuickBookingComponent();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化日期为 yyyy-MM-dd
|
||||||
|
const formatDate = (date) => {
|
||||||
|
const d = new Date(date);
|
||||||
|
const year = d.getFullYear();
|
||||||
|
const month = String(d.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(d.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const commodityGroupKey = (title) => {
|
||||||
|
return `${title}${formattedDate.value}`
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log('=============')
|
console.log('=============')
|
||||||
loadQuickBookingComponent()
|
loadQuickBookingComponent()
|
||||||
@@ -47,7 +70,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 58px;
|
height: 58px;
|
||||||
margin: 12px 0 6px;
|
margin: 12px 0 6px;
|
||||||
background-color: rgba(140,236,255,0.24);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
const loadDiscoveryCradComponent = async () => {
|
const loadDiscoveryCradComponent = async () => {
|
||||||
const res = await discoveryCradComponent()
|
const res = await discoveryCradComponent()
|
||||||
if(res.code === 0 && res.data) {
|
if(res.code === 0 && res.data) {
|
||||||
themeDTOList.value.push(...res.data.themeDTOList)
|
themeDTOList.value = res.data.themeDTOList
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
uni.$emit(SCROLL_TO_BOTTOM, true)
|
uni.$emit(SCROLL_TO_BOTTOM, true)
|
||||||
|
|||||||
BIN
static/booking_calendar.png
Normal file
BIN
static/booking_calendar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 791 B |
Reference in New Issue
Block a user