Browse Source

collect page

邹能昇 4 months ago
parent
commit
a83e7cc7fc

+ 56 - 1
nova-tourism/components/collect/index.js

@@ -41,7 +41,14 @@ Component({
         imageUrls: ['https://file-cloud.fmode.cn//tmp/srFPqGFAzeT5958c828d985e451ed4c0b452e39ff57a.jpeg',
             'https://file-cloud.fmode.cn//tmp/P7YTTX6XuEZC607368e1f9745abc429c7c25cbef4c5a.jpeg',
             'https://file-cloud.fmode.cn/EbxZUK5lBI/20241121/jc17lo114657420.jpg'
-        ]
+        ],
+
+        date_start: '',
+        date_end: '',
+        start: '',
+        end: '',
+        istoday: true,
+        daysBetween: 1
     },
     lifetimes: {
         detached: function () {},
@@ -62,6 +69,7 @@ Component({
                 contentHeight
             });
             this.gethomestar()
+            this.getcurrentdate()
         },
     },
 
@@ -131,5 +139,52 @@ Component({
 
             console.log('修改成功', objectId);
         },
+        //转换日期
+        formatDate(date) {
+            date = new Date(date);
+            return `${date.getMonth() + 1}月${date.getDate()}日`;
+        },
+        //获取今日明日日期
+        getcurrentdate() {
+            const today = new Date();
+            const tomorrow = new Date();
+            tomorrow.setDate(today.getDate() + 1);
+
+            this.setData({
+                date_start: this.formatDate(today),
+                date_end: this.formatDate(tomorrow),
+                start: today,
+                end: tomorrow
+            });
+            console.log(this.data.start, this.data.end);
+        },
+        gourl(e) {
+            const url = e.currentTarget.dataset.url;
+            const id = e.currentTarget.dataset.id;
+
+            // 构造要传递的信息
+            const info = {
+                objectId: id,
+                date_start: this.data.date_start,
+                date_end: this.data.date_end,
+                daysBetween: this.data.daysBetween,
+                istoday: this.data.istoday,
+                start: this.data.start,
+                end: this.data.end
+            };
+
+            // 将信息转为查询字符串
+            const queryString = Object.keys(info)
+                .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(info[key])}`)
+                .join('&');
+
+            // 使用查询字符串跳转
+            wx.navigateTo({
+                url: `${url}?${queryString}`,
+            });
+        },
+
+
+
     }
 })

+ 10 - 0
nova-tourism/components/collect/index.less

@@ -154,6 +154,16 @@
                 }
             }
         }
+        .more{
+            width: 100%;
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            .more-tex{
+                font-size: 28rpx;
+                color: #969696;
+            }
+        }
     }
 
 

+ 10 - 1
nova-tourism/components/collect/index.wxml

@@ -53,8 +53,17 @@
                         </view>
                     </block>
                 </view>
-            </view>
 
+                <view class="more">
+                    <view class="more-tex">查看更多 ></view>
+                </view>
+
+                <view class="wangbox">
+                    <view class="wang">妆造旅拍</view>
+                </view>
+
+
+            </view>
         </van-tab>
         <!-- 我的收藏 -->
         <van-tab title="我的收藏">

File diff suppressed because it is too large
+ 0 - 0
nova-tourism/components/collect/index.wxss


+ 75 - 6
nova-tourism/pages/homestay/homestay-detail/index.js

@@ -31,8 +31,13 @@ Page({
         markers: [],
 
         //
-        start:'',
-        end:'',
+        start: '',
+        end: '',
+
+        //
+        show: false,
+        date_start1: '',
+        date_end1:'',
     },
 
     /**
@@ -88,14 +93,14 @@ Page({
             objectId,
             daysBetween,
             istoday,
-            start:Start,
-            end:End,
+            start: Start,
+            end: End,
         })
         console.log('istoday', this.data.istoday);
         this.gethomestay()
         this.getroom()
         this.getpic()
-
+        this.getcurrentdate()
     },
 
     /**
@@ -336,7 +341,7 @@ Page({
                 date_start: this.data.start,
                 date_end: this.data.end,
             };
-            console.log('info',info);
+            console.log('info', info);
 
             // 将信息转为查询字符串
             var queryString = Object.keys(info)
@@ -350,4 +355,68 @@ Page({
 
     },
 
+
+    //获取今日明日日期
+    getcurrentdate() {
+        const today = new Date();
+        const tomorrow = new Date();
+        tomorrow.setDate(today.getDate() + 1);
+
+        this.setData({
+            date_start1: this.formatDate(today),
+            date_end1: this.formatDate(tomorrow),
+        });
+        console.log(this.data.start, this.data.end);
+    },
+    //转换日期
+    formatDate(date) {
+        date = new Date(date);
+        return `${date.getMonth() + 1}月${date.getDate()}日`;
+    },
+    // 计算两个日期之间的天数
+    calculateDaysBetween(startDate, endDate) {
+        const start = new Date(startDate);
+        const end = new Date(endDate);
+        const timeDifference = end - start; // 计算时间差(毫秒)
+        const daysDifference = timeDifference / (1000 * 3600 * 24); // 转换为天数
+        return daysDifference; // 返回天数差
+    },
+    //开日历
+    onDisplay() {
+        this.setData({
+            show: true
+        });
+    },
+    //关日历
+    onClose() {
+        this.setData({
+            show: false
+        });
+    },
+    //选好日期点击完成后
+    onConfirm(event) {
+        const [start, end] = event.detail;
+        const daysBetween = this.calculateDaysBetween(start, end); // 计算天数差
+        this.setData({
+            show: false,
+            start,
+            end,
+            decodedDateStartart: `${this.formatDate(start)} `,
+            decodedDateEnd: `${this.formatDate(end)}`,
+            daysBetween
+        });
+        if (this.data.decodedDateStartart.trim() == this.data.date_start1.trim() && this.data.decodedDateEnd.trim() == this.data.date_end1.trim()) {
+            this.setData({
+                istoday: 'true'
+            })
+            console.log(this.data.istoday);
+        } else {
+            this.setData({
+                istoday: 'false'
+            })
+            console.log(this.data.istoday);
+        }
+        console.log(`入住日期: ${this.data.decodedDateStartart}, 离店日期: ${this.data.decodedDateEnd}, 天数差: ${daysBetween}天`);
+    },
+
 })

+ 2 - 1
nova-tourism/pages/homestay/homestay-detail/index.json

@@ -1,7 +1,8 @@
 {
   "usingComponents": {
     "van-sticky": "@vant/weapp/sticky/index",
-    "van-icon": "@vant/weapp/icon/index"
+    "van-icon": "@vant/weapp/icon/index",
+    "van-calendar": "@vant/weapp/calendar/index"
   },
   "permission": {
     "scope": {

+ 2 - 1
nova-tourism/pages/homestay/homestay-detail/index.wxml

@@ -33,7 +33,7 @@
         </view>
         <view class="roomcard">
             <van-sticky z-index='999' offset-top="{{statusBarHeight+customHeight-5}}">
-                <view class="timebox">
+                <view class="timebox" bindtap="onDisplay">
                     <view class="time">
                         <view class="time-tex" wx:if="{{istoday=='true'}}">今天</view>
                         <view class="time-time">{{decodedDateStart}}</view>
@@ -45,6 +45,7 @@
                     </view>
                     <view class="time_tex2">共{{daysBetween}}晚</view>
                 </view>
+                <van-calendar show="{{ show }}" show-confirm="{{ true }}" confirm-text="完成" confirm-disabled-text='完成' type="range" bind:close="onClose" bind:confirm="onConfirm" color='#46a9a4' position='bottom' />
             </van-sticky>
             <block wx:for="{{roomList}}" wx:key="index">
                 <view class="room-card" wx:if="{{item.remaining>0}}">

Some files were not shown because too many files changed in this diff