future 1 年之前
父节点
当前提交
5c5e8d6e5f
共有 2 个文件被更改,包括 48 次插入12 次删除
  1. 8 5
      assets/resources/ui/mailbox_view.prefab
  2. 40 7
      assets/script/ui/mailbox_view/mailbox_view.ts

+ 8 - 5
assets/resources/ui/mailbox_view.prefab

@@ -1327,7 +1327,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 713.9999999999999,
+      "y": 653.9999999999999,
       "z": 0
     },
     "_lrot": {
@@ -1368,7 +1368,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1011,
-      "height": 1427.9999999999998
+      "height": 1367.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -1465,7 +1465,7 @@
     "_target": null,
     "_left": 0,
     "_right": 0,
-    "_top": 0,
+    "_top": 60,
     "_bottom": 0,
     "_horizontalCenter": 0,
     "_verticalCenter": 0,
@@ -1513,7 +1513,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 1011,
-      "height": 30
+      "height": 0
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -1584,7 +1584,7 @@
     "_startAxis": 0,
     "_paddingLeft": 0,
     "_paddingRight": 0,
-    "_paddingTop": 30,
+    "_paddingTop": 0,
     "_paddingBottom": 0,
     "_spacingX": 0,
     "_spacingY": 0,
@@ -6776,6 +6776,9 @@
     "content_bg": {
       "__id__": 29
     },
+    "content_scrollView": {
+      "__id__": 30
+    },
     "content": {
       "__id__": 48
     },

+ 40 - 7
assets/script/ui/mailbox_view/mailbox_view.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
+import { _decorator, Component, instantiate, Node, Prefab, ScrollView } from 'cc';
 import { base_ui } from '../../fw/base_ui';
 import { mailbox_read_item } from './mailbox_read_item';
 import { http } from '../../http';
@@ -14,6 +14,7 @@ export class mailbox_view extends base_ui {
 
     @property(Node) img_empty:Node = null
     @property(Node) content_bg:Node = null
+    @property(Node) content_scrollView:Node = null
     @property(Node) content:Node = null
     @property(Prefab) read_item:Prefab = null
     @property(Node) btn_delete_read:Node = null
@@ -24,6 +25,8 @@ export class mailbox_view extends base_ui {
     private data_list:mail_item_data[] = []
     private page:number = 1
     private limit:number = 15
+    private is_loading:boolean = false
+    private is_request:boolean = true
     start() {
         this.onButtonListen(this.btn_back, ()=>{
             this.close()
@@ -32,7 +35,7 @@ export class mailbox_view extends base_ui {
             uiManager.showModal('删除已读?', '', (res)=>{
                 if(res.confirm) {
                     this.requestDelete(1,0, ()=>{
-                        this.requestListData(()=>{
+                        this.requestListData(false,()=>{
                             uiManager.showToast('删除成功')
                         })
                     })
@@ -43,15 +46,27 @@ export class mailbox_view extends base_ui {
             uiManager.showModal('全部领取?', '', (res)=>{
                 if(res.confirm) {
                     this.requestRetrieve(1,0,()=>{
-                        this.requestListData(()=>{
+                        this.requestListData(false, ()=>{
                             uiManager.showToast('领取成功')
                         })
                     })
                 }
             })
         })
+        this.content_scrollView.on(ScrollView.EventType.SCROLL_TO_BOTTOM, this.onScrollToBottom, this)
 
-        this.requestListData()
+        this.requestListData(false)
+    }
+
+    private onScrollToBottom() {
+        if(this.is_request==false) { 
+            return
+        }
+        if(this.is_loading) { 
+            return 
+        }
+        console.log('滑动到底部开始加载数据=',this.page)
+        this.requestListData(true)
     }
 
     private showEmpty(show:boolean) {
@@ -64,15 +79,27 @@ export class mailbox_view extends base_ui {
         }
     }
 
-    private requestListData(suc_cb=null) {
+    private requestListData(is_load_more:boolean, suc_cb=null) {
+        if(is_load_more==false) {
+            this.page = 1
+        }
+
+        this.is_loading = true
+        uiManager.Instance().showLoading()
         let opt = {'page':this.page, 'limit':this.limit}
         http.post(config.API.mail_lists,opt, (err,d)=>{
+            setTimeout(()=>{
+                this.is_loading = false
+                uiManager.Instance().hideLoading()
+            },500)
             if(!err){
                 let nd = JSON.parse(d)
                 if(nd.code === config.status.SUCCESS){
                     // console.log("mail data", nd.content)
-                    this.data_list = []
-                    this.content.removeAllChildren()
+                    if(this.page==1) {
+                        this.data_list = []
+                        this.content.removeAllChildren()
+                    }
                     this.data_list = this.data_list.concat(nd.content)
                     if(this.data_list.length > 0) {
                         this.showEmpty(false)
@@ -82,7 +109,13 @@ export class mailbox_view extends base_ui {
                             item.parent = this.content
                             item.getComponent(mailbox_read_item).initView(element,this.onClickItem.bind(this))
                         }
+
+                        this.page += 1
+                        if(nd.content.length<this.limit) {
+                            this.is_request = false
+                        }
                     } else {
+                        this.is_request = false
                         this.showEmpty(true)
                     }
                 }