소스 검색

circle page

邹能昇 1 주 전
부모
커밋
64ff2a2365

+ 38 - 9
nova-werun/components/circle/index.js

@@ -24,6 +24,10 @@ Component({
         //朋友圈
         cardList: [],
 
+        loadedItems: 0, // 已加载的商品数量
+        pageSize: 6, // 每次加载的商品数量
+        noMoreItems: false, // 是否还有更多商品
+
 
     },
     lifetimes: {
@@ -48,7 +52,7 @@ Component({
                 bottomNavHeight,
                 contentHeight
             });
-            console.log('123', contentHeight);
+            // console.log('123', contentHeight);
             this.getcircle()
         },
 
@@ -69,9 +73,9 @@ Component({
             Profilequery2.notEqualTo('isDeleted', true)
             let P2 = await Profilequery2.find();
             let profile1List2 = P2.map(item => item.toJSON());
-            console.log(profile1List2);
+            // console.log(profile1List2);
             const department = profile1List2[0].department.objectId
-            console.log(department);
+            // console.log(department);
             let queryWhere = {
                 where: {
                     profile: {
@@ -88,25 +92,50 @@ Component({
             Profilequery.equalTo('company', company);
             Profilequery.equalTo('isVisible', true);
             Profilequery.notEqualTo('isDeleted', true)
+            Profilequery.descending('createdAt');
+            // 设置查询的限制和偏移
+            Profilequery.limit(this.data.pageSize);
+            Profilequery.skip(this.data.loadedItems);
             let P = await Profilequery.find();
             let profile1List = P.map(item => item.toJSON());
-            profile1List.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
-            console.log(profile1List);
+            // profile1List.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
+            // 检查是否还有更多商品
+            if (profile1List.length < this.data.pageSize) {
+                this.setData({
+                    noMoreItems: true
+                });
+            } else {
+                this.setData({
+                    noMoreItems: false
+                });
+            }
+
             this.setData({
-                cardList: profile1List
+                cardList: this.data.cardList.concat(profile1List),
+                loadedItems: this.data.loadedItems + profile1List.length
             })
+            console.log(this.data.cardList);
+        },
+        loadMoreData: async function () {
+            // 触底时加载更多数据
+            if (!this.data.noMoreItems) {
+                await this.getcircle();
+            }
         },
-        getcircle2(){
+        getcircle2() {
             this.setData({
-                cardList:[]
+                cardList: [],
+                loadedItems:0,
+                noMoreItems:false
             })
+            console.log('运行了');
             this.getcircle()
         },
         //跳转
         gourl(e) {
             const url = e.currentTarget.dataset.url
             wx.navigateTo({
-                url: `${url}`// 目标页面的路径
+                url: `${url}` // 目标页面的路径
             });
         },
 

+ 7 - 1
nova-werun/components/circle/index.less

@@ -6,8 +6,14 @@
         .trends{
             width: 100%;
             border-top: grey solid 1px;
-            overflow-y: scroll;
             padding-top: 20rpx;
+            .no-more{
+                width: 100%;
+                display: flex;
+                justify-content: center;
+                font-size: 28rpx;
+                margin-bottom: 35rpx;
+            }
         }
         .trends::-webkit-scrollbar {
             display: none; /* 隐藏滚动条 */

+ 3 - 2
nova-werun/components/circle/index.wxml

@@ -1,11 +1,12 @@
 <!--nova-werun/components/circle/index.wxml-->
 <nav type="title" background-color="{{'#87ceeb'}}" front-color="{{'#ffffff'}}"></nav>
 <view class="all" style="height: {{contentHeight}}rpx;">
-    <view class="trends" style="height: {{contentHeight}}rpx;">
+    <scroll-view class="trends" scroll-y="true" bindscrolltolower="loadMoreData" style="height: {{contentHeight}}rpx;">
         <block wx:for="{{cardList}}" wx:key="{{item.objectId}}">
             <circle-card objectId='{{item.objectId}}' type='surface'></circle-card>
         </block>
-    </view>
+        <view wx:if="{{noMoreItems}}" class="no-more">没有更多数据了</view>
+    </scroll-view>
     <view class="publishbox" bindtap="gourl" data-url="../../pages/circle/send-circle/index">
         <image src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241105/8qes51030838243.png?imageView2/1/w/200/h/200"></image>
     </view>

+ 1 - 1
nova-werun/components/circle/index.wxss

@@ -1 +1 @@
-.all{width:100vw;position:relative}.all .trends{width:100%;border-top:grey solid 1px;overflow-y:scroll;padding-top:20rpx}.all .trends::-webkit-scrollbar{display:none}.all .publishbox{position:absolute;bottom:214rpx;right:12rpx}.all .publishbox image{width:80rpx;height:80rpx}
+.all{width:100vw;position:relative}.all .trends{width:100%;border-top:grey solid 1px;padding-top:20rpx}.all .trends .no-more{width:100%;display:flex;justify-content:center;font-size:28rpx;margin-bottom:35rpx}.all .trends::-webkit-scrollbar{display:none}.all .publishbox{position:absolute;bottom:214rpx;right:12rpx}.all .publishbox image{width:80rpx;height:80rpx}