hookehuyr

首页房间选项卡不显示已满状态,日历默认值不传,页面的相关调整

1 <!-- 1 <!--
2 * @Date: 2023-12-13 13:42:23 2 * @Date: 2023-12-13 13:42:23
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-26 16:14:35 4 + * @LastEditTime: 2023-12-27 16:01:27
5 * @FilePath: /meihuaApp/src/components/roomCard.vue 5 * @FilePath: /meihuaApp/src/components/roomCard.vue
6 * @Description: 房间详情组件 6 * @Description: 房间详情组件
7 --> 7 -->
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
20 </nut-col> 20 </nut-col>
21 </nut-row> 21 </nut-row>
22 </view> 22 </view>
23 - <view v-if="!num" class="room-status"> 23 + <view v-if="!num && props.type !== 'index'" class="room-status">
24 <view class="room-status-wrapper"> 24 <view class="room-status-wrapper">
25 <image mode="aspectFill" src="https://cdn.ipadbiz.cn/meihua/icon_checked@2x.png" /> 25 <image mode="aspectFill" src="https://cdn.ipadbiz.cn/meihua/icon_checked@2x.png" />
26 </view> 26 </view>
...@@ -84,6 +84,10 @@ const props = defineProps({ ...@@ -84,6 +84,10 @@ const props = defineProps({
84 endDate: '', 84 endDate: '',
85 }, 85 },
86 }, 86 },
87 + type: {
88 + type: String,
89 + default: '',
90 + }
87 }); 91 });
88 92
89 const startDate = ref(''); 93 const startDate = ref('');
...@@ -111,9 +115,15 @@ const handleTap = () => { ...@@ -111,9 +115,15 @@ const handleTap = () => {
111 if (!endDate.value) { 115 if (!endDate.value) {
112 endDate.value = dates.tomorrow; 116 endDate.value = dates.tomorrow;
113 } 117 }
118 + if (props.type === 'index') { // 首页进入的
119 + Taro.navigateTo({
120 + url: `../detail/index?id=${id.value}&room_type=${room_type.value}&start_date=&end_date=`,
121 + });
122 + } else {
114 Taro.navigateTo({ 123 Taro.navigateTo({
115 url: `../detail/index?id=${id.value}&room_type=${room_type.value}&start_date=${startDate.value}&end_date=${endDate.value}`, 124 url: `../detail/index?id=${id.value}&room_type=${room_type.value}&start_date=${startDate.value}&end_date=${endDate.value}`,
116 }); 125 });
126 + }
117 } 127 }
118 128
119 const id = ref(''); // 房间id 129 const id = ref(''); // 房间id
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-26 18:08:01 4 + * @LastEditTime: 2023-12-27 15:37:50
5 * @FilePath: /meihuaApp/src/pages/book/index.vue 5 * @FilePath: /meihuaApp/src/pages/book/index.vue
6 * @Description: 订房页面 6 * @Description: 订房页面
7 --> 7 -->
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
9 <view class="book-page"> 9 <view class="book-page">
10 <view id="book-content" class="book-content"> 10 <view id="book-content" class="book-content">
11 <view id="book-cal" class="book-cal"> 11 <view id="book-cal" class="book-cal">
12 - <calendar-select @on-dates-change="onDatesChange" @on-dates-close="onDatesClose"></calendar-select> 12 + <calendar-select :start-date="start_date" :end-date="end_date" @on-dates-change="onDatesChange" @on-dates-close="onDatesClose"></calendar-select>
13 </view> 13 </view>
14 <view class="book-type"> 14 <view class="book-type">
15 <!-- <nut-tabs v-model="value" @click="onTabClick" title-scroll title-gutter="10" name="tabName" background="#FFF" color="#4C2E08" animated-time="0"> 15 <!-- <nut-tabs v-model="value" @click="onTabClick" title-scroll title-gutter="10" name="tabName" background="#FFF" color="#4C2E08" animated-time="0">
...@@ -37,6 +37,46 @@ import navBar from '@/components/navBar.vue' ...@@ -37,6 +37,46 @@ import navBar from '@/components/navBar.vue'
37 import calendarSelect from '@/components/calendarSelect.vue' 37 import calendarSelect from '@/components/calendarSelect.vue'
38 import roomCard from '@/components/roomCard.vue' 38 import roomCard from '@/components/roomCard.vue'
39 39
40 +/**
41 + * 获取今天和明天日期
42 + */
43 +const getTodayAndTomorrow = () => {
44 + var today = new Date(); // 获取当前日期
45 +
46 + var todayYear = today.getFullYear();
47 + var todayMonth = today.getMonth() + 1; // 月份从0开始,所以要加1
48 + var todayDay = today.getDate();
49 +
50 + var tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000); // 获取明天日期
51 +
52 + var tomorrowYear = tomorrow.getFullYear();
53 + var tomorrowMonth = tomorrow.getMonth() + 1; // 月份从0开始,所以要加1
54 + var tomorrowDay = tomorrow.getDate();
55 +
56 + // 跨年处理
57 + if (tomorrowYear > todayYear) {
58 + tomorrowMonth = '01';
59 + tomorrowDay = '01';
60 + }
61 +
62 + // 跨月处理
63 + if (tomorrowMonth > 12) {
64 + tomorrowMonth = '01';
65 + tomorrowYear = todayYear + 1;
66 + }
67 +
68 + // 格式化为两位数
69 + todayMonth = todayMonth < 10 ? '0' + todayMonth : todayMonth;
70 + todayDay = todayDay < 10 ? '0' + todayDay : todayDay;
71 + tomorrowMonth = tomorrowMonth < 10 ? '0' + tomorrowMonth : tomorrowMonth;
72 + tomorrowDay = tomorrowDay < 10 ? '0' + tomorrowDay : tomorrowDay;
73 +
74 + return {
75 + today: todayYear + '-' + todayMonth + '-' + todayDay,
76 + tomorrow: tomorrowYear + '-' + tomorrowMonth + '-' + tomorrowDay
77 + };
78 +}
79 +
40 // const value = ref('0'); 80 // const value = ref('0');
41 81
42 // const tabList = ref([{ 82 // const tabList = ref([{
...@@ -56,6 +96,15 @@ import roomCard from '@/components/roomCard.vue' ...@@ -56,6 +96,15 @@ import roomCard from '@/components/roomCard.vue'
56 // key: '4', 96 // key: '4',
57 // }]); 97 // }]);
58 98
99 +// 调用方法获取今天和明天的日期
100 +const dates = getTodayAndTomorrow();
101 +
102 +const start_date = ref('');
103 +const end_date = ref('');
104 +
105 +start_date.value = dates.today;
106 +end_date.value = dates.tomorrow;
107 +
59 onMounted(() => { 108 onMounted(() => {
60 }); 109 });
61 110
...@@ -140,14 +189,15 @@ export default { ...@@ -140,14 +189,15 @@ export default {
140 startDate, 189 startDate,
141 endDate 190 endDate
142 } 191 }
143 - },
144 - onDatesClose () {
145 // 重置列表 192 // 重置列表
146 this.flag = true; 193 this.flag = true;
147 this.page = 1; 194 this.page = 1;
148 this.bookList = []; 195 this.bookList = [];
149 this.getList(); 196 this.getList();
150 }, 197 },
198 + onDatesClose () {
199 +
200 + },
151 onScrollToLower () { 201 onScrollToLower () {
152 if(!this.flag){ 202 if(!this.flag){
153 return 203 return
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-12-27 14:21:07 4 + * @LastEditTime: 2023-12-27 16:23:40
5 * @FilePath: /meihuaApp/src/pages/detail/index.vue 5 * @FilePath: /meihuaApp/src/pages/detail/index.vue
6 * @Description: 房间详情页面 6 * @Description: 房间详情页面
7 --> 7 -->
...@@ -17,14 +17,15 @@ ...@@ -17,14 +17,15 @@
17 <view class="detail-info-content">{{ state.roomInfo.room_num }}室 宜住{{ state.roomInfo.capacity }}人</view> 17 <view class="detail-info-content">{{ state.roomInfo.room_num }}室 宜住{{ state.roomInfo.capacity }}人</view>
18 </view> 18 </view>
19 <!-- 日历选择器 --> 19 <!-- 日历选择器 -->
20 - <view v-if="showBook" class="book-cal"> 20 + <view class="book-cal">
21 - <calendar-select @on-dates-change="onDatesChange" :start-date="start_date" :end-date="end_date"></calendar-select> 21 + <calendar-select @on-dates-change="onDatesChange" :start-date="start_date" :end-date="end_date" @on-dates-close="onDatesClose"></calendar-select>
22 </view> 22 </view>
23 - <view v-else class="no-calendar-border"></view> 23 + <!-- <view v-else class="no-calendar-border"></view> -->
24 <!-- END --> 24 <!-- END -->
25 <view v-if="state.roomInfo.description" class="detail-introduce-title">房间介绍</view> 25 <view v-if="state.roomInfo.description" class="detail-introduce-title">房间介绍</view>
26 <view class="detail-introduce-html"> 26 <view class="detail-introduce-html">
27 <view id="taro_html" v-html="state.roomInfo.description" class="taro_html"></view> 27 <view id="taro_html" v-html="state.roomInfo.description" class="taro_html"></view>
28 + <view style="height: 6rem;"></view>
28 </view> 29 </view>
29 <view class="book-bar"> 30 <view class="book-bar">
30 <nut-row> 31 <nut-row>
...@@ -35,7 +36,7 @@ ...@@ -35,7 +36,7 @@
35 </view> 36 </view>
36 </nut-col> 37 </nut-col>
37 <nut-col :span="6"> 38 <nut-col :span="6">
38 - <view v-if="showBook" class="book-btn" @tap="goToConfirm">预定</view> 39 + <view class="book-btn" @tap="goToConfirm">预定</view>
39 </nut-col> 40 </nut-col>
40 </nut-row> 41 </nut-row>
41 </view> 42 </view>
...@@ -134,15 +135,27 @@ const onDatesChange = async ({ startDate, endDate, betweenDate, startDateWeek, e ...@@ -134,15 +135,27 @@ const onDatesChange = async ({ startDate, endDate, betweenDate, startDateWeek, e
134 state.roomInfo = data; 135 state.roomInfo = data;
135 // 轮播图 136 // 轮播图
136 if (state.roomInfo.banner.length) { 137 if (state.roomInfo.banner.length) {
138 + state.imgData = [];
137 state.roomInfo.banner.forEach(item => { 139 state.roomInfo.banner.forEach(item => {
138 state.imgData.push({ 140 state.imgData.push({
139 src: item 141 src: item
140 }) 142 })
141 }); 143 });
142 } 144 }
145 + if (!state.roomInfo.num) {
146 + Taro.showToast({
147 + title: '该时段房间已售罄,请重新选择日期',
148 + icon: 'none',
149 + duration: 3000,
150 + });
151 + }
143 } 152 }
144 } 153 }
145 154
155 +const onDatesClose = async () => {
156 +
157 +}
158 +
146 const state = reactive({ 159 const state = reactive({
147 showPreview: false, 160 showPreview: false,
148 imgData: [], 161 imgData: [],
...@@ -164,6 +177,7 @@ onMounted(async () => { ...@@ -164,6 +177,7 @@ onMounted(async () => {
164 state.roomInfo = roomData.data; 177 state.roomInfo = roomData.data;
165 // 轮播图 178 // 轮播图
166 if (state.roomInfo.banner.length) { 179 if (state.roomInfo.banner.length) {
180 + state.imgData = [];
167 state.roomInfo.banner.forEach(item => { 181 state.roomInfo.banner.forEach(item => {
168 state.imgData.push({ 182 state.imgData.push({
169 src: item 183 src: item
...@@ -175,12 +189,28 @@ onMounted(async () => { ...@@ -175,12 +189,28 @@ onMounted(async () => {
175 189
176 // 预定房间 190 // 预定房间
177 const goToConfirm = async () => { 191 const goToConfirm = async () => {
192 + let params = getCurrentPageParam();
193 + if (!start_date.value || !end_date.value) {
194 + Taro.showToast({
195 + title: '请先选择入住时间段',
196 + icon: 'none',
197 + duration: 3000,
198 + });
199 + return false;
200 + }
201 + if (!showBook.value) {
202 + Taro.showToast({
203 + title: '该时段房间已售罄,请重新选择日期',
204 + icon: 'none',
205 + duration: 3000,
206 + });
207 + return false;
208 + }
178 // 获取用户信息 209 // 获取用户信息
179 const myInfoData = await showMyInfoAPI(); 210 const myInfoData = await showMyInfoAPI();
180 if (myInfoData.code) { 211 if (myInfoData.code) {
181 state.phone = myInfoData.data.wxapp_user_phone; 212 state.phone = myInfoData.data.wxapp_user_phone;
182 } 213 }
183 - let params = getCurrentPageParam();
184 if (state.phone) { 214 if (state.phone) {
185 Taro.navigateTo({ 215 Taro.navigateTo({
186 url: `/pages/confirm/index?id=${params.id}&start_date=${start_date.value}&end_date=${end_date.value}&between_date=${between_date.value}&start_date_week=${start_date_week.value}&end_date_week=${end_date_week.value}&room_type=${params.room_type}`, 216 url: `/pages/confirm/index?id=${params.id}&start_date=${start_date.value}&end_date=${end_date.value}&between_date=${between_date.value}&start_date_week=${start_date_week.value}&end_date_week=${end_date_week.value}&room_type=${params.room_type}`,
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 </view> 16 </view>
17 <view class="index-title">热门推荐</view> 17 <view class="index-title">热门推荐</view>
18 <view class="index-list"> 18 <view class="index-list">
19 - <room-card v-for="(item, index) in room_list" :key="index" :data="item" /> 19 + <room-card v-for="(item, index) in room_list" :key="index" :data="item" type="index" />
20 </view> 20 </view>
21 </scroll-view> 21 </scroll-view>
22 <view style="height: 6rem;"></view> 22 <view style="height: 6rem;"></view>
......