邹能昇 hai 1 día
pai
achega
8621950ffa

+ 66 - 4
nova-tourism/components/homestay/index.js

@@ -1,3 +1,5 @@
+let Parse = getApp().Parse;
+const company = getApp().globalData.company
 Component({
     /**
      * 组件的属性列表
@@ -16,8 +18,15 @@ Component({
         
         date_start: '',
         date_end: '',
+        date_start1: '',
+        date_end1: '',
+        istoday:true,
         daysBetween:1,
         show: false,
+        //店铺数据
+        storeList:[],
+        //价格
+        price:211
     },
     lifetimes: {
         detached: function () {},
@@ -38,6 +47,7 @@ Component({
                 contentHeight
             });
             this.getcurrentdate();
+            this.gethomestar()
         },
     },
     /**
@@ -53,6 +63,8 @@ Component({
             this.setData({
                 date_start: this.formatDate(today),
                 date_end: this.formatDate(tomorrow),
+                date_start1: this.formatDate(today),
+                date_end1: this.formatDate(tomorrow),
             });
             console.log(this.data.date_start, this.data.date_end);
         },
@@ -91,13 +103,63 @@ Component({
                 date_end: `${this.formatDate(end)}`,
                 daysBetween
             });
+            if(this.data.date_start.trim()==this.data.date_start1.trim()&&this.data.date_end.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);
+            }
+            this.gethomestar()
             console.log(`入住日期: ${this.data.date_start}, 离店日期: ${this.data.date_end}, 天数差: ${daysBetween}天`);
         },
-        gourl(e){
-            const url = e.currentTarget.dataset.url
+        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,
+            };
+        
+            // 将信息转为查询字符串
+            const queryString = Object.keys(info)
+                .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(info[key])}`)
+                .join('&');
+        
+            // 使用查询字符串跳转
             wx.navigateTo({
-              url: `${url}`,
-            })
+                url: `${url}?${queryString}`,
+            });
+        },
+        //获取店铺消息
+        async gethomestar() {
+            let ShopStore = new Parse.Query('ShopStore');
+            ShopStore.equalTo('company', company);
+            ShopStore.equalTo('type', "stay");
+            ShopStore.notEqualTo('isDeleted', "true");
+            
+            let store = await ShopStore.find();
+            let storeList = store.map(item => {
+                let storeItem = item.toJSON();
+                // 为每一项添加价格属性
+                storeItem.price = storeItem.perCapita*this.data.daysBetween; 
+                return storeItem;
+            });
+            
+            this.setData({
+                storeList
+            });
+            
+            console.log(this.data.storeList);
         }
     }
 });

+ 8 - 1
nova-tourism/components/homestay/index.less

@@ -48,6 +48,13 @@
                 align-items: center;
                 font-size: 32rpx;
                 border-top: solid #e5e5e5 2rpx;
+                .today{
+                    font-size: 28rpx;
+                    color: gray;
+                    margin-left: 10rpx;
+                    display: flex;
+                    justify-content: flex-end;
+                }
                 .start{
                     display: flex;
                     justify-content: flex-end;
@@ -86,6 +93,7 @@
             background-image: url('https://file-cloud.fmode.cn/EbxZUK5lBI/20241121/01atf5032703958.png?imageView2/1/w/200/h/200');
             margin-top: 20rpx;
             margin-bottom: 20rpx;
+            break-inside: avoid;
             .pic-2{
                 width: 100%;
                 height: 56rpx;
@@ -117,7 +125,6 @@
                 padding-top: 10rpx;
                 padding-left: 20rpx;
                 padding-right: 20rpx;
-                background-color: #f7f7f7;
                 .title{
                     width: 100%;
                     height: 50rpx;

+ 10 - 8
nova-tourism/components/homestay/index.wxml

@@ -11,14 +11,16 @@
             </view>
             <view class="datebox" bindtap="onDisplay">
                 <view class="start">{{date_start}}</view>
+                <view class="today" wx:if="{{istoday}}">今天</view>
                 <view class="day">共{{daysBetween}}晚</view>
                 <view class="end">{{date_end}}</view>
+                <view class="today" wx:if="{{istoday}}">明天</view>
             </view>
             <van-calendar show="{{ show }}" show-confirm="{{ true }}" confirm-text="完成" confirm-disabled-text='完成' type="range" bind:close="onClose" bind:confirm="onConfirm" color='#ff0000' position='top' />
         </view>
     </view>
     <view class="Legendary-Information">
-        <block wx:for="{{6}}">
+        <block wx:for="{{storeList}}">
             <view class="picbox" wx:if="{{index==1}}">
                 <view class="pic-2"></view>
                 <block wx:for="{{3}}">
@@ -30,22 +32,22 @@
 
             </view>
             <view class="cardbox">
-                <image class="pic" mode="aspectFit" src="https://file-cloud.fmode.cn/EbxZUK5lBI/20241121/jc17lo114657420.jpg" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl"></image>
+                <image class="pic" src="{{item.image[0]}}" data-id="{{item.objectId}}" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl"></image>
                 <view class="textobx">
-                    <view class="title" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
-                        <view class="til">剑仙居</view>
+                    <view class="title" data-id="{{item.objectId}}" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
+                        <view class="til">{{item.storeName}}</view>
                         <image class="collect" src="https://file-cloud.fmode.cn/EbxZUK5lBI/20241121/2gcp1e030048570.png?imageView2/1/w/200/h/200"></image>
                     </view>
 
-                    <view class="miaosu" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
-                        剑仙居描述剑仙居描述剑仙居描述剑仙居描述剑仙居描述
+                    <view class="miaosu" wx:if="{{item.desc}}" data-id="{{item.objectId}}" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
+                        {{item.desc}}
                     </view>
 
                     <view class="bottom">
-                        <view class="qian" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
+                        <view class="qian" data-id="{{item.objectId}}" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
                             <view class="numbox">
-                                10000.00
+                                {{item.price}}
                             </view>
                         </view>
                         <view class="soucang">收藏</view>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
nova-tourism/components/homestay/index.wxss


+ 80 - 7
nova-tourism/pages/homestay/homestay-detail/index.js

@@ -1,4 +1,6 @@
 // nova-tourism/pages/homestay/homestay-detail/index.js
+let Parse = getApp().Parse;
+const company = getApp().globalData.company
 Page({
 
     /**
@@ -14,7 +16,14 @@ Page({
         //  轮播图数组
         imageUrls: ['https://tse4-mm.cn.bing.net/th/id/OIP-C.3r1vguZyWFUJ80A2Nf2k3AHaEK?rs=1&pid=ImgDetMain', 'https://ts1.cn.mm.bing.net/th/id/R-C.9881613a29f26488b40938427aa585e4?rik=fim4XvDejjHE%2fQ&riu=http%3a%2f%2fn.sinaimg.cn%2fsinakd20220516ac%2f797%2fw2048h1149%2f20220516%2fb0aa-5aca29fe2dfa69c385118bbc74d039de.jpg&ehk=tzq%2bJP6uMipI0aIHY3bMSVO7lS7ZQM6TKMlwZ5CFP4s%3d&risl=&pid=ImgRaw&r=0', 'https://pic3.zhimg.com/v2-5fb13110e1de13d4c11e6e7f5b8026da_r.jpg', 'https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/02/04/ChMkJ1bKyEyIMaKUAAhskHwWGqUAALIAAM2KsIACGyo249.jpg'],
         index: 1,
-
+        //
+        decodedDateStart: '',
+        decodedDateEnd: '',
+        objectId: "",
+        daysBetween: 0,
+        istoday:null,
+        storeList: [],
+        roomList: []
     },
 
     /**
@@ -29,25 +38,46 @@ Page({
         const customHeight = custom.height + 10 + 2 || 0;
         const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
 
-        const contentHeight = (screenHeight - bottomNavHeight  - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
-        if(bottomNavHeight){
+        const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
+        if (bottomNavHeight) {
             const padding_bottom = bottomNavHeight * 750 / systemInfo.windowWidth
             this.setData({
-                bottomNavHeight:padding_bottom
+                bottomNavHeight: padding_bottom
             })
             console.log(this.data.bottomNavHeight);
-        }else{
+        } else {
             this.setData({
-                bottomNavHeight:40
+                bottomNavHeight: 40
             })
         }
-        
+
         this.setData({
             statusBarHeight,
             screenHeight,
             customHeight,
             contentHeight
         });
+
+        const {
+            objectId,
+            date_start,
+            date_end,
+            daysBetween,
+            istoday
+        } = options;
+        // 解码接收到的参数
+        const decodedDateStart = decodeURIComponent(date_start);
+        const decodedDateEnd = decodeURIComponent(date_end);
+        this.setData({
+            decodedDateStart,
+            decodedDateEnd,
+            objectId,
+            daysBetween,
+            istoday
+        })
+        console.log('istoday',this.data.istoday);
+        this.gethomestay()
+        this.getroom()
     },
 
     /**
@@ -105,4 +135,47 @@ Page({
             index: currentIndex + 1
         })
     },
+    //获取名宿信息
+    async gethomestay() {
+        let ShopStore = new Parse.Query('ShopStore');
+        ShopStore.equalTo('company', company);
+        ShopStore.equalTo('type', "stay");
+        ShopStore.equalTo('objectId', this.data.objectId);
+        ShopStore.notEqualTo('isDeleted', "true");
+
+        let store = await ShopStore.find();
+        let storeList = store.map(item => item.toJSON());
+
+        this.setData({
+            storeList
+        });
+        console.log(this.data.storeList);
+    },
+    //获取房间信息
+    async getroom() {
+        let room = new Parse.Query('ShopRoom');
+        room.equalTo('company', company);
+        room.equalTo('shop', this.data.objectId);
+        room.equalTo('isEnabled', 'true');
+        room.notEqualTo('isDeleted', 'true');
+
+        let room2 = await room.find();
+        let roomList = room2.map(item => item.toJSON());
+        // 对 roomList 进行排序
+        roomList.sort((a, b) => {
+            // 先比较 remaining,remaining 为 0 的排后面
+            if (a.remaining === 0 && b.remaining !== 0) {
+                return 1; // a 排后面
+            }
+            if (a.remaining !== 0 && b.remaining === 0) {
+                return -1; // a 排前面
+            }
+            // 如果两个房间的 remaining 都不为 0,按数量升序排列
+            return a.remaining - b.remaining;
+        });
+        this.setData({
+            roomList
+        })
+        console.log('房间', this.data.roomList);
+    }
 })

+ 15 - 15
nova-tourism/pages/homestay/homestay-detail/index.wxml

@@ -16,10 +16,10 @@
     <view class="card">
         <view class="Legendary-Information">
             <view class="info-name">
-                <view class="name-tex">剑仙居民宿</view>
+                <view class="name-tex">{{storeList[0].storeName}}</view>
                 <image class="name-pic" src="https://file-cloud.fmode.cn/EbxZUK5lBI/20241121/2gcp1e030048570.png"></image>
             </view>
-            <view class="info-intr">剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述剑仙居民宿描述</view>
+            <view class="info-intr">{{storeList[0].desc}}</view>
             <view class="info-map">
                 <view class="map"></view>
                 <view class="info-call">
@@ -32,24 +32,24 @@
             <van-sticky z-index='999' offset-top="{{statusBarHeight+customHeight-5}}">
                 <view class="timebox">
                     <view class="time">
-                        <view class="time-tex">今天</view>
-                        <view class="time-time">11月11日</view>
+                        <view class="time-tex" wx:if="{{istoday=='true'}}">今天</view>
+                        <view class="time-time">{{decodedDateStart}}</view>
                     </view>
                     <van-icon name="minus" size='30rpx' custom-style='font-weight: 600;margin-bottom: 4rpx;margin-right: 6rpx;' />
                     <view class="time">
-                        <view class="time-tex">明天</view>
-                        <view class="time-time">11月12日</view>
+                        <view class="time-tex" wx:if="{{istoday=='true'}}">明天</view>
+                        <view class="time-time">{{decodedDateEnd}}</view>
                     </view>
-                    <view class="time_tex2">共1晚</view>
+                    <view class="time_tex2">共{{daysBetween}}晚</view>
                 </view>
             </van-sticky>
-            <block wx:for="{{4}}">
-                <view class="room-card">
+            <block wx:for="{{roomList}}" wx:key="index">
+                <view class="room-card" wx:if="{{item.remaining>0}}" >
                     <view class="room-card1">
-                        <image src="https://file-cloud.fmode.cn/EbxZUK5lBI/20241122/v5nu1u104043606.png"></image>
+                        <image src="{{item.images[0]}}"></image>
                         <view class="room-card-textbox">
                             <view class="room-card-textbox-titlebox">
-                                <view class="room-card-textbox-title">豪华标准房</view>
+                                <view class="room-card-textbox-title">{{item.name}}</view>
                                 <van-icon name="arrow" custom-style='margin-top: 8rpx;' />
                             </view>
                             <view class="room-card-textbox-info">
@@ -69,17 +69,17 @@
                         </view>
                     </view>
                     <view class="room-card2">
-                        <view class="price">¥199900</view>
+                        <view class="price">¥{{item.price*daysBetween}}</view>
                         <view class="submit">订</view>
                     </view>
                 </view>
                 <!-- 无房 -->
-                <view class="room-card" style="opacity: 0.5;">
+                <view class="room-card" style="opacity: 0.5;" wx:if="{{item.remaining==0}}" >
                     <view class="room-card1">
-                        <image src="https://file-cloud.fmode.cn/EbxZUK5lBI/20241122/v5nu1u104043606.png"></image>
+                        <image src="{{item.images[0]}}"></image>
                         <view class="room-card-textbox">
                             <view class="room-card-textbox-titlebox">
-                                <view class="room-card-textbox-title">豪华标准房</view>
+                                <view class="room-card-textbox-title">{{item.name}}</view>
                                 <van-icon name="arrow" custom-style='margin-top: 8rpx;' />
                             </view>
                             <view class="room-card-textbox-info">

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio