|
@@ -4,16 +4,16 @@ import { mailbox_read_item } from './mailbox_read_item';
|
|
import { http } from '../../http';
|
|
import { http } from '../../http';
|
|
import { config } from '../../config';
|
|
import { config } from '../../config';
|
|
import { mail_item_data } from '../../data';
|
|
import { mail_item_data } from '../../data';
|
|
|
|
+import { uiManager } from '../../manager/uiManager';
|
|
|
|
+import { mailbox_details } from './mailbox_details';
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('mailbox_view')
|
|
@ccclass('mailbox_view')
|
|
export class mailbox_view extends base_ui {
|
|
export class mailbox_view extends base_ui {
|
|
- @property(Node) bg:Node = null
|
|
|
|
|
|
+ @property(Node) btn_back:Node = null
|
|
|
|
|
|
- @property(Node) list_bg:Node = null
|
|
|
|
@property(Node) img_empty:Node = null
|
|
@property(Node) img_empty:Node = null
|
|
@property(Node) content_bg:Node = null
|
|
@property(Node) content_bg:Node = null
|
|
- @property(Node) scrollView:Node = null
|
|
|
|
@property(Node) content:Node = null
|
|
@property(Node) content:Node = null
|
|
@property(Prefab) read_item:Prefab = null
|
|
@property(Prefab) read_item:Prefab = null
|
|
@property(Node) btn_delete_read:Node = null
|
|
@property(Node) btn_delete_read:Node = null
|
|
@@ -25,85 +25,140 @@ export class mailbox_view extends base_ui {
|
|
private page:number = 1
|
|
private page:number = 1
|
|
private limit:number = 15
|
|
private limit:number = 15
|
|
start() {
|
|
start() {
|
|
- this.onButtonListen(this.bg, ()=>{
|
|
|
|
- if(this.details_bg.active==true) {
|
|
|
|
- this.list_bg.active = true
|
|
|
|
- this.details_bg.active = false
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ this.onButtonListen(this.btn_back, ()=>{
|
|
this.close()
|
|
this.close()
|
|
})
|
|
})
|
|
this.onButtonListen(this.btn_delete_read, ()=>{
|
|
this.onButtonListen(this.btn_delete_read, ()=>{
|
|
- this.requestDelete(1,0)
|
|
|
|
|
|
+ uiManager.showModal('删除已读?', '', (res)=>{
|
|
|
|
+ if(res.confirm) {
|
|
|
|
+ this.requestDelete(1,0, ()=>{
|
|
|
|
+ this.requestListData(()=>{
|
|
|
|
+ uiManager.showToast('删除成功')
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
})
|
|
})
|
|
this.onButtonListen(this.btn_get_all, ()=>{
|
|
this.onButtonListen(this.btn_get_all, ()=>{
|
|
- this.requestRetrieve(1,0)
|
|
|
|
|
|
+ uiManager.showModal('全部领取?', '', (res)=>{
|
|
|
|
+ if(res.confirm) {
|
|
|
|
+ this.requestRetrieve(1,0,()=>{
|
|
|
|
+ this.requestListData(()=>{
|
|
|
|
+ uiManager.showToast('领取成功')
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
})
|
|
})
|
|
|
|
|
|
this.requestListData()
|
|
this.requestListData()
|
|
}
|
|
}
|
|
|
|
|
|
- private requestListData() {
|
|
|
|
- this.content_bg.active = true
|
|
|
|
- this.img_empty.active = true
|
|
|
|
|
|
+ private showEmpty(show:boolean) {
|
|
|
|
+ if(show) {
|
|
|
|
+ this.content_bg.active = false
|
|
|
|
+ this.img_empty.active = true
|
|
|
|
+ } else {
|
|
|
|
+ this.content_bg.active = true
|
|
|
|
+ this.img_empty.active = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private requestListData(suc_cb=null) {
|
|
let opt = {'page':this.page, 'limit':this.limit}
|
|
let opt = {'page':this.page, 'limit':this.limit}
|
|
http.post(config.API.mail_lists,opt, (err,d)=>{
|
|
http.post(config.API.mail_lists,opt, (err,d)=>{
|
|
if(!err){
|
|
if(!err){
|
|
let nd = JSON.parse(d)
|
|
let nd = JSON.parse(d)
|
|
if(nd.code === config.status.SUCCESS){
|
|
if(nd.code === config.status.SUCCESS){
|
|
// console.log("mail data", nd.content)
|
|
// console.log("mail data", nd.content)
|
|
|
|
+ this.data_list = []
|
|
|
|
+ this.content.removeAllChildren()
|
|
this.data_list = this.data_list.concat(nd.content)
|
|
this.data_list = this.data_list.concat(nd.content)
|
|
if(this.data_list.length > 0) {
|
|
if(this.data_list.length > 0) {
|
|
- this.content_bg.active = true
|
|
|
|
- this.img_empty.active = false
|
|
|
|
|
|
+ this.showEmpty(false)
|
|
for (let index = 0; index < this.data_list.length; index++) {
|
|
for (let index = 0; index < this.data_list.length; index++) {
|
|
const element = this.data_list[index];
|
|
const element = this.data_list[index];
|
|
let item = instantiate(this.read_item)
|
|
let item = instantiate(this.read_item)
|
|
item.parent = this.content
|
|
item.parent = this.content
|
|
item.getComponent(mailbox_read_item).initView(element,this.onClickItem.bind(this))
|
|
item.getComponent(mailbox_read_item).initView(element,this.onClickItem.bind(this))
|
|
}
|
|
}
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
- this.content_bg.active = false
|
|
|
|
- this.img_empty.active = true
|
|
|
|
|
|
+ this.showEmpty(true)
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ suc_cb && suc_cb()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
private onClickItem(item:mailbox_read_item) {
|
|
private onClickItem(item:mailbox_read_item) {
|
|
- if(item.getData().state==1) {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.list_bg.active = false
|
|
|
|
this.details_bg.active = true
|
|
this.details_bg.active = true
|
|
|
|
+ this.details_bg.getComponent(mailbox_details).initView(item.getData(),
|
|
|
|
+ (v:mailbox_details)=>{
|
|
|
|
+ uiManager.showModal('删除已读?', '', (res)=>{
|
|
|
|
+ if(res.confirm) {
|
|
|
|
+ this.details_bg.active = false
|
|
|
|
+ this.requestDelete(0,v.getData().id, ()=>{
|
|
|
|
+ this.deleteDataLocalHandle(item)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }, (v:mailbox_details)=>{
|
|
|
|
+ this.details_bg.active = false
|
|
|
|
+ let data = v.getData()
|
|
|
|
+ if(data.state==0) {
|
|
|
|
+ this.requestRetrieve(0,v.getData().id, ()=>{
|
|
|
|
+ data.state = 1
|
|
|
|
+ item.setData(data)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
// 领取邮件 stype 0:普通领取 1:一键领取
|
|
// 领取邮件 stype 0:普通领取 1:一键领取
|
|
- private requestRetrieve(stype:number, id:number) {
|
|
|
|
|
|
+ private requestRetrieve(stype:number, id:number, success_cb) {
|
|
let opt = {'stype':stype, 'id':id}
|
|
let opt = {'stype':stype, 'id':id}
|
|
|
|
+ uiManager.Instance().showLoading('正在领取...')
|
|
http.post(config.API.mail_retrieve,opt, (err,d)=>{
|
|
http.post(config.API.mail_retrieve,opt, (err,d)=>{
|
|
|
|
+ uiManager.Instance().hideLoading()
|
|
if(!err){
|
|
if(!err){
|
|
let nd = JSON.parse(d)
|
|
let nd = JSON.parse(d)
|
|
if(nd.code === config.status.SUCCESS){
|
|
if(nd.code === config.status.SUCCESS){
|
|
|
|
+ success_cb && success_cb()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
// 删除邮件 stype 0:普通删除 1:一键删除
|
|
// 删除邮件 stype 0:普通删除 1:一键删除
|
|
- private requestDelete(stype:number, id:number) {
|
|
|
|
|
|
+ private requestDelete(stype:number, id:number, success_cb) {
|
|
let opt = {'stype':stype, 'id':id}
|
|
let opt = {'stype':stype, 'id':id}
|
|
- http.post(config.API.mail_retrieve,opt, (err,d)=>{
|
|
|
|
|
|
+ uiManager.Instance().showLoading('正在删除...')
|
|
|
|
+ http.post(config.API.mail_del,opt, (err,d)=>{
|
|
|
|
+ uiManager.Instance().hideLoading()
|
|
if(!err){
|
|
if(!err){
|
|
let nd = JSON.parse(d)
|
|
let nd = JSON.parse(d)
|
|
if(nd.code === config.status.SUCCESS){
|
|
if(nd.code === config.status.SUCCESS){
|
|
|
|
+ success_cb && success_cb()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private deleteDataLocalHandle(item:mailbox_read_item) {
|
|
|
|
+ if(item.node.isChildOf(this.content)) {
|
|
|
|
+ this.content.removeChild(item.node)
|
|
|
|
+ for (let index = 0; index < this.data_list.length; index++) {
|
|
|
|
+ const element = this.data_list[index];
|
|
|
|
+ if(element.id==item.getData().id) {
|
|
|
|
+ this.data_list.splice(index,1)
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(this.data_list.length<=0) {
|
|
|
|
+ this.showEmpty(true)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|