Browse Source

mingsu page

邹能昇 4 months ago
parent
commit
fbe3f5d05c

+ 68 - 5
nova-tourism/components/homestay/index.js

@@ -26,7 +26,9 @@ Component({
         //店铺数据
         storeList: [],
         //价格
-        price: 211
+        price: 211,
+        //搜索
+        value: ''
     },
     lifetimes: {
         detached: function () {},
@@ -278,20 +280,81 @@ Component({
                 }
             }
         },
+
+        //搜索功能
+        search(e) {
+            const value = e.detail;
+            console.log(value);
+            this.getRooms(value)
+        },
+        //清零后
+        change(e) {
+            const value = e.detail;
+            if (!value) {
+                console.log('运行');
+                this.gethomestar()
+            }
+        },
+        // 搜索函数
+        async getRooms(value) {
+            // 确保 value 不为空
+            if (!value) {
+                console.log('搜索值为空');
+                return; // 如果没有输入值,直接返回
+            }
+
+            let queryParams = {
+                where: {
+                    $or: [{
+                        storeName: {
+                            $regex: `.*${value}.*` // 使用 value 进行正则匹配
+                        }
+                    }, {
+                        storeAddress: {
+                            $regex: `.*${value}.*` // 使用 value 进行正则匹配
+                        }
+                    }]
+                }
+            };
+
+            let ShopStore = Parse.Query.fromJSON('ShopStore', queryParams);
+            ShopStore.equalTo('company', company);
+            ShopStore.equalTo('type', "stay");
+            ShopStore.notEqualTo('isDeleted', "true");
+
+            try {
+                let store = await ShopStore.find();
+                let storeListPromises = store.map(async item => {
+                    let storeItem = item.toJSON();
+                    // 为每一项添加价格属性
+                    storeItem.price = storeItem.perCapita * this.data.daysBetween;
+                    storeItem.iscollect = await this.iscollect(storeItem.objectId); // 等待 iscollect 的结果
+                    return storeItem;
+                });
+
+                let storeList = await Promise.all(storeListPromises); // 等待所有的 Promise 完成
+
+                this.setData({
+                    storeList // 更新 storeList
+                });
+            } catch (error) {
+                console.error("查询商店时出现错误:", error);
+            }
+        }
         //添加后台经纬度
         //  async setadd() {
         //     let ShopStore = new Parse.Query('ShopStore');
         //     ShopStore.equalTo('company', company);
         //     ShopStore.equalTo('objectId', "GyeSIi3zwL");
-        
+
         //     let store = await ShopStore.first();
-            
+
         //     // 创建 GeoPoint 对象
         //     let location = new Parse.GeoPoint(28.679224,117.818856); // 注意:GeoPoint 的参数是 (latitude, longitude)
-            
+
         //     // 设置 location 字段
         //     store.set('location', location);
-            
+
         //     try {
         //         let saveDate = await store.save();
         //         console.log(saveDate);

+ 2 - 1
nova-tourism/components/homestay/index.json

@@ -3,6 +3,7 @@
     "usingComponents": {
         "van-icon": "@vant/weapp/icon/index",
         "van-calendar": "@vant/weapp/calendar/index",
-        "van-search": "@vant/weapp/search/index"
+        "van-search": "@vant/weapp/search/index",
+        "van-empty": "@vant/weapp/empty/index"
     }
 }

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

@@ -3,7 +3,6 @@
 .all{
     width: 100vw;
     height: 100vh;
-    background-color: #f7f7f7;
     .picturebox{
         width: 100%;
         height: 430rpx;
@@ -178,5 +177,14 @@
             }
         }
     }
+     .Legendary-Information2{
+        margin-top: 204rpx;
+        width: 100%;
+        background-color: white;
+        overflow-y: hidden;
+        padding-left: 3%;
+        padding-right: 3%;
+        padding-bottom: 40rpx;
+    }
 
 }

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

@@ -7,7 +7,7 @@
         <!-- 日期 -->
         <view class="infobox">
             <view class="seach">
-                <van-search shape="round" value="{{ value }}" placeholder="请输入地点/门店名称/关键词" />
+                <van-search shape="round" model:value="{{ value }}" placeholder="请输入地点/门店名称/关键词" bind:search="search" bind:change="change"  />
             </view>
             <view class="datebox" bindtap="onDisplay">
                 <view class="start">{{date_start}}</view>
@@ -19,7 +19,8 @@
             <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">
+    <!-- 卡片 -->
+    <view class="Legendary-Information" wx:if="{{storeList.length!=0}}">
         <block wx:for="{{storeList}}">
             <view class="picbox" wx:if="{{index==1}}">
                 <view class="pic-2"></view>
@@ -57,9 +58,11 @@
                 </view>
             </view>
         </block>
-
-
     </view>
-
+    <!-- 无搜索内容 -->
+    <view class="Legendary-Information2" wx:if="{{storeList.length==0}}">
+        <van-empty wx:if="{{storeList.length==0}}"  image="network" description="暂无该店铺" />
+    </view>
+    
 
 </scroll-view>

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


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