邹能昇 3 months ago
parent
commit
338372d4da

+ 20 - 54
nova-tourism/components/homestay/index.js

@@ -1,6 +1,8 @@
 let Parse = getApp().Parse;
 const company = getApp().globalData.company
-const { getStores } = require(".././../service/request")
+const {
+    getStores
+} = require(".././../service/request")
 Component({
     /**
      * 组件的属性列表
@@ -129,12 +131,6 @@ Component({
                 })
                 console.log(this.data.istoday);
             }
-            this.setData({
-                loadedItems: 0,
-                noMoreItems: false,
-                storeList: []
-            })
-            await this.gethomestar()
             console.log(`入住日期: ${this.data.date_start}, 离店日期: ${this.data.date_end}, 天数差: ${daysBetween}天`);
         },
         gourl(e) {
@@ -164,11 +160,12 @@ Component({
         },
         //获取店铺消息
         async gethomestar() {
-          let _data = await getStores({
-            uid:Parse.User.current().id,
-            skip:this.data.loadedItems,
-            limit:this.data.pageSize
-          });
+            let _data = await getStores({
+                val: this.data.value,
+                uid: Parse.User.current().id,
+                skip: this.data.loadedItems,
+                limit: this.data.pageSize
+            });
             // let ShopStore = new Parse.Query('ShopStore');
             // ShopStore.equalTo('company', company);
             // ShopStore.equalTo('type', "stay");
@@ -187,7 +184,7 @@ Component({
             // });
 
             // let storeList = await Promise.all(storeListPromises); // 等待所有的Promise完成
-            
+
             // 合并新加载的商店和已存在的商店列表
             // let updatedStoreList = this.data.storeList.concat(storeList);
 
@@ -206,7 +203,7 @@ Component({
                 loadedItems: this.data.loadedItems + _data.length,
             });
 
-            console.log('店铺数据=====>',this.data.storeList);
+            console.log('店铺数据=====>', this.data.storeList);
         },
         //点击收藏
         async submit(e) {
@@ -310,7 +307,7 @@ Component({
         //搜索功能
         search(e) {
             const value = e.detail.value;
-            console.log(value);
+            console.log(this.data.value);
             this.getRooms(value)
         },
         //清零后
@@ -325,7 +322,8 @@ Component({
             this.setData({
                 loadedItems: 0,
                 noMoreItems: false,
-                storeList: []
+                storeList: [],
+                value:''
             })
             this.gethomestar()
         },
@@ -336,44 +334,12 @@ Component({
                 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);
-            }
+            this.setData({
+                loadedItems: 0,
+                noMoreItems: false,
+                storeList: []
+            })
+            this.gethomestar()
         },
         //触底加载
         async loadMoreData() {

+ 6 - 2
nova-tourism/components/homestay/index.wxml

@@ -1,10 +1,11 @@
 <nav type="title" background-color="#ffffff" frontColor="#000000" title="云上望仙" />
-<scroll-view class="all" scroll-y="true" bindscrolltolower="loadMoreData" style="height: {{contentHeight}}rpx;">
+<scroll-view class="all" id="scroller" bind:scroll="onScroll" scroll-y="true" bindscrolltolower="loadMoreData" style="height: {{contentHeight}}rpx;">
     <view class="picturebox">
         <view class="img">
             <image src="https://file-cloud.fmode.cn/EbxZUK5lBI/20241121/jc17lo114657420.jpg"></image>
         </view>
     </view>
+
     <!-- 日期 -->
     <view class="infobox">
         <view class="seach">
@@ -23,6 +24,9 @@
     </view>
 
 
+
+
+
     <!-- 卡片 -->
     <view class="Legendary-Information" wx:if="{{storeList.length!=0}}">
         <block>
@@ -38,7 +42,7 @@
                                 <image class="collect" wx:if="{{item.iscollect}}" src="https://file-cloud.fmode.cn/EbxZUK5lBI/20241121/8mp9uj030058190.png?imageView2/1/w/200/h/200"></image>
                             </view>
 
-                            <view class="miaosu"  data-id="{{item.objectId}}" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
+                            <view class="miaosu" data-id="{{item.objectId}}" data-url="../../pages/homestay/homestay-detail/index" bindtap="gourl">
                                 {{item.desc}}
                             </view>
                             <view class="bottom">

+ 3 - 1
nova-tourism/service/request.js

@@ -4,10 +4,12 @@ const company = getApp().globalData.company
 
 async function getStores(params) {
   let {
+    val,
     uid,
     skip,
     limit
   } = params
+  let wh1 = val ? `AND (store."storeName" LIKE '%` + val + "%'" + 'OR store."storeAddress" LIKE ' + "'%" + val + "%')" : ``
   let sql = `SELECT * ,
   ("perCapita" * 1) price,
   (SELECT room."price" FROM "ShopRoom" room 
@@ -23,12 +25,12 @@ async function getStores(params) {
    AND clt."user" = '${uid}'
    LIMIT 1 
   ) "iscollect"
-  
   FROM "ShopStore" store
   WHERE "company" = '${company}'
   AND "type" = 'stay'
   AND "isShow" = 'true'
   AND "isDeleted" IS NOT TRUE
+  ${wh1}
   ORDER BY "iscollect"
   OFFSET ${skip ?? 0} LIMIT ${limit ?? 10}`
   let res = await req.customSQL(sql);