Browse Source

minsu page

邹能昇 4 months ago
parent
commit
79e1cba959

+ 25 - 26
nova-tourism/components/homestay/index.js

@@ -30,7 +30,12 @@ Component({
         //搜索
         value: '',
         start:'',
-        end:''
+        end:'',
+
+        //触底加载
+        loadedItems:0,
+        pageSize:5,
+        noMoreItems:false,
     },
     lifetimes: {
         detached: function () {},
@@ -156,7 +161,8 @@ Component({
             ShopStore.equalTo('company', company);
             ShopStore.equalTo('type', "stay");
             ShopStore.notEqualTo('isDeleted', "true");
-
+            ShopStore.limit(this.data.pageSize);
+            ShopStore.skip(this.data.loadedItems);
             let store = await ShopStore.find();
             let storeListPromises = store.map(async item => {
                 let storeItem = item.toJSON();
@@ -167,9 +173,18 @@ Component({
             });
 
             let storeList = await Promise.all(storeListPromises); // 等待所有的Promise完成
-
+            if(storeList.length<this.data.pageSize){
+                this.setData({
+                    noMoreItems:true
+                })
+            }else{
+                this.setData({
+                    noMoreItems:false
+                })
+            }
             this.setData({
-                storeList
+                storeList:this.data.storeList.concat(storeList),
+                loadedItems:this.data.loadedItems+storeList.length,
             });
 
             console.log(this.data.storeList);
@@ -348,28 +363,12 @@ Component({
             } catch (error) {
                 console.error("查询商店时出现错误:", error);
             }
+        },
+        //触底加载
+      async  loadMoreData(){
+            if(!this.data.noMoreItems){
+                await this.gethomestar()
+            }
         }
-        //添加后台经纬度
-        //  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);
-        //         console.log("上传地址成功");
-        //     } catch (error) {
-        //         console.error("保存数据时出现错误:", error);
-        //     }
-        // }
     }
 });

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

@@ -177,6 +177,14 @@
                 }
             }
         }
+
+    }
+    .bottom{
+        width: 100%;
+        font-size: 26rpx;
+        display: flex;
+        align-items: center;
+        justify-content: center;
     }
      .Legendary-Information2{
         margin-top: 204rpx;

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

@@ -1,5 +1,5 @@
 <nav type="title" background-color="#ffffff" frontColor="#000000" title="望仙谷" />
-<scroll-view class="all" scroll-y="true" bindscroll="onScroll" style="height: {{contentHeight}}rpx;">
+<scroll-view class="all" 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>
@@ -59,6 +59,7 @@
             </view>
         </block>
     </view>
+    <view class="bottom" wx:if="{{noMoreItems}}">没有更多民宿了...</view>
     <!-- 无搜索内容 -->
     <view class="Legendary-Information2" wx:if="{{storeList.length==0}}">
         <van-empty wx:if="{{storeList.length==0}}"  image="network" description="暂无该店铺" />

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