Your Name hace 5 años
padre
commit
47cb64b7e1

+ 27 - 26
pages/information/chat/chat.js

@@ -7,7 +7,8 @@ Page({
7 7
    * 页面的初始数据
8 8
    */
9 9
   data: {
10
-    toView:'Stop',
10
+    hiddenName:true, // 加载更多显示隐藏
11
+    toView:'Stop',   //锚点
11 12
     scrollTopVal: 1,    //滚动条
12 13
     menu: false, //菜单显示隐藏
13 14
     Expression: false,  // 表情显示隐藏
@@ -312,52 +313,46 @@ Page({
312 313
             arrData[index].isMy = false;   //他人
313 314
           }
314 315
       
315
-        
316
-          that.ArrMsg.push(arrData[index]);
316
+          that.ArrMsg.push(arrData[index]);   //每次接到的数据拼接
317 317
         }
318 318
 
319
-
320
-        for (var index in that.ArrMsg) {     //二次赋值  
319
+        for (var index in that.ArrMsg) {     //二次赋值   把所有的数据 hooks参数 清空
321 320
               if(that.ArrMsg[index].hooks){
322 321
                 that.ArrMsg[index].hooks = '';
323 322
               }
324 323
         }
325 324
      
326
-
327
-        // // 滚动条处理
328
-   
329
-        // that.ceshi();
330
-        let Arrs1 = that.sortarr(that.ArrMsg);
325
+        let Arrs1 = that.sortarr(that.ArrMsg);       //最后要展示的数据  第11条  加上 hooks= 'Stop'; 参数  用来做加载更多数据,描点到最后一条信息
331 326
         if(Arrs1[10]){
332 327
           Arrs1[10].hooks = 'Stop';
333 328
         }
334 329
     
335 330
         console.log(Arrs1, 111112222);
336
- 
337
-
338
-     
331
+        
332
+        that.setData({   
333
+          hiddenName: true,
334
+        });
339 335
 
340
-        if (that.data.limit_page == 1) {
341 336
 
337
+        if (that.data.limit_page == 1) {   //判断  分页 1 的时候 
342 338
           that.setData({
343 339
             Receive_news: Arrs1,        //前台数据赋值 
344 340
             scrollTopVal: that.ArrMsg.length * 999,    // 滚动条赋值
345
-            toView: false,
341
+            toView: false,   //关闭锚点
346 342
           });
347 343
 
348
-        }else{
344
+        }else{   
349 345
           that.setData({
350 346
             Receive_news: Arrs1,        //前台数据赋值 
351
-            toView: 'Stop'
347
+            toView: 'Stop'      //开启锚点 赋值
352 348
           });
353 349
         }
354 350
 
355 351
 
356
-        that.setData({
352
+        that.setData({     //最后关闭锚点   方便每次进来  在开启 修复 描点会闪动
357 353
           toView: false,
358 354
         });
359
-
360
-        // that.scrollbar(that.ArrMsg);      //调用页面滚动条处理  这里不对
355
+    
361 356
         break;
362 357
 
363 358
 
@@ -475,15 +470,21 @@ Page({
475 470
   //  下拉加载聊天记录
476 471
   upper: function (e) {
477 472
     var that = this;
478
-    console.log(e,'加载')
473
+    // console.log(e,'加载')
479 474
 
480
-    that.setData({
481
-      limit_page: that.data.limit_page * 1 + 1
475
+    that.setData({   //  显示加载更多图片
476
+          hiddenName:false,    
482 477
     })
483
-    console.log(that.data.limit_page * 1 + 1)
484
-    that.SocketSend({ type: 'get_history', page: that.data.limit_page,limit:10})
485 478
 
486
-    console.log('执行')
479
+   setTimeout(function () {
480
+        that.setData({
481
+          limit_page: that.data.limit_page * 1 + 1
482
+        })
483
+        console.log(that.data.limit_page * 1 + 1)
484
+        that.SocketSend({ type: 'get_history', page: that.data.limit_page,limit:10})
485
+    }, 3000);
486
+
487
+    // console.log('执行')
487 488
   },
488 489
 
489 490
 

+ 5 - 2
pages/information/chat/chat.wxml

@@ -5,8 +5,10 @@
5 5
     bindscroll="scroll" -->
6 6
    <!-- bindscroll="ceshi" -->
7 7
 <scroll-view class="history"     scroll-top="{{scrollTopVal}}"    scroll-y="true"  bindtap="resetInputStatus"  bindscrolltoupper="upper"   scroll-into-view="{{toView}}">
8
-  <!-- <view style='height:1000px;'></view>
9
-     <view  id="red"  style='height:10px;'></view> -->
8
+
9
+          <view class='Load_img_box' hidden="{{hiddenName}}">
10
+               <view class='Load_img'><image src='/image/jz.png' mode="aspectFill"></image></view>
11
+           </view>
10 12
           <!-- 自己 -->
11 13
            <block  wx:for='{{Receive_news}}' wx:key="item">
12 14
                 <view class='my_right c' wx:if="{{item.isMy === true}}" id="{{item.hooks}}">
@@ -65,6 +67,7 @@
65 67
         </block>
66 68
 
67 69
 
70
+
68 71
 </scroll-view>
69 72
 
70 73
 

+ 3 - 1
pages/information/chat/chat.wxss

@@ -1,7 +1,9 @@
1 1
 page {background-color: #EDEDED; height: 100%;}  
2 2
 /* .HGJKHJKHJK{height: 100%;} */
3 3
 
4
-
4
+.Load_img_box{padding:20rpx  0 ;}
5
+.Load_img{width:35rpx;height:35rpx;margin:auto;}
6
+.Load_img image{width:100%;height:100%; }
5 7
 
6 8
 .history { 
7 9
   /* border:1px solid; */