|
@@ -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)
|
|
|
}
|
|
|
}
|