188 lines
5.3 KiB
JavaScript
188 lines
5.3 KiB
JavaScript
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const FxTogs = require( "nx.fx.togs" );
|
||
|
|
const SvcList = require( "nx.fx.sv.expand" );
|
||
|
|
const mod = require( "mail.mod" );
|
||
|
|
const MailEvent = require( "mail_event" );
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
|
||
|
|
nodTog : { default : null, type: FxTogs },
|
||
|
|
nodCnt : { default : null, type: SvcList },
|
||
|
|
nodInfo: { default : null, type: cc.Node }
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad: function(){
|
||
|
|
|
||
|
|
this.mod = mod.getInstance();
|
||
|
|
if( !this.mod ){
|
||
|
|
this.delayClose();
|
||
|
|
}
|
||
|
|
this.select_index = 0;
|
||
|
|
|
||
|
|
|
||
|
|
// //刷新邮件
|
||
|
|
this.bindGEvent( MailEvent.UPDATE_ITEM, this.freshMailList.bind( this ) );
|
||
|
|
// //刷新公告
|
||
|
|
this.bindGEvent( MailEvent.UPDATE_NOTICE, this.freshMailList.bind( this ) );
|
||
|
|
// //读取公告
|
||
|
|
this.bindGEvent( MailEvent.READ_INFO_NOTICE, this.showNoticeInfo.bind( this ) );
|
||
|
|
// //读取邮件
|
||
|
|
this.bindGEvent( MailEvent.OPEN_INFO_WIN, this.showMailInfo.bind( this ) );
|
||
|
|
this.bindGEvent( MailEvent.FRESH_ITEM, this.dealMailStatus.bind(this));
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onOpenConfigs( _param ) {
|
||
|
|
|
||
|
|
this.nodTog.posTog = this.onTogMenu.bind( this );
|
||
|
|
this.nodTog.togTo( 0 );
|
||
|
|
this.onTogMenu( 0 );
|
||
|
|
},
|
||
|
|
|
||
|
|
onPreClosed() {
|
||
|
|
|
||
|
|
this.nodCnt.rebuild( [] );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTogMenu: function( _idx ){
|
||
|
|
|
||
|
|
let id = parseInt( _idx );
|
||
|
|
|
||
|
|
this.choice = id;
|
||
|
|
let mails = id == 0 ? this.mod.getAllMailArray() : this.mod.getNoticeArray();
|
||
|
|
nx.gui.setActive( this.nodInfo, "", id == 1 ? nx.dt.arrNEmpty( mails ) : nx.dt.arrNEmpty( mails ) );
|
||
|
|
|
||
|
|
nx.gui.setActive( this.nodCnt.node, "lay", id == 1 ? nx.dt.arrNEmpty( mails ) : true );
|
||
|
|
let cmp = nx.gui.getComponent( this.nodCnt.node, "scrollCon", cc.ScrollView );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.scrollToTop( 0.01 );
|
||
|
|
}
|
||
|
|
this.nodCnt.rebuild( mails );
|
||
|
|
let chd = nx.gui.find( this.nodCnt.bindSCV, "mask/content" ).children;
|
||
|
|
this.scheduleOnce( ()=>{
|
||
|
|
this.nodCnt.addFocus( 0 );
|
||
|
|
if( chd[0] ){
|
||
|
|
chd[0].svItem ? this.onFocusChange( chd[0].svItem ) : this.onFocusChange( {} );
|
||
|
|
}
|
||
|
|
}, 0.1 );
|
||
|
|
|
||
|
|
// this.dealOp();
|
||
|
|
},
|
||
|
|
|
||
|
|
onFocusChange: function( _item ){
|
||
|
|
|
||
|
|
// 空
|
||
|
|
if( nx.dt.objEmpty( _item ) ||
|
||
|
|
nx.dt.objEmpty( _item.mdata ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let chd = nx.gui.find( this.nodCnt.bindSCV, "mask/content" ).children;
|
||
|
|
// this.list.cleanFocus();
|
||
|
|
for (let i = 0; i < chd.length; i++) {
|
||
|
|
let nod = chd[i];
|
||
|
|
if( nod.svItem ){
|
||
|
|
if( i == _item.index ){
|
||
|
|
|
||
|
|
nod.svItem.onFocus();
|
||
|
|
// break;
|
||
|
|
}else{
|
||
|
|
nod.svItem.outFocus();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 聚焦
|
||
|
|
// this.list.cleanFocus();
|
||
|
|
// this.list.addFocus( _item.index );
|
||
|
|
this.select_index = _item.index;
|
||
|
|
if( _item.mdata.status >= 0 ) {//邮件
|
||
|
|
this.mod.requireMailItem( _item.mdata.id, _item.mdata.srv_id, this.info_win);
|
||
|
|
} else if( _item.mdata.flag >= 0 ) {//公告
|
||
|
|
this.mod.readNotice( _item.mdata.id );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
showMailInfo: function( _data ){
|
||
|
|
|
||
|
|
this.readMail = _data;
|
||
|
|
let cmp = nx.gui.getComponent( this.nodInfo, "", "cmp.mail.info" );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.setData( _data );
|
||
|
|
}
|
||
|
|
nx.gui.setActive( this.nodInfo, "", true );
|
||
|
|
// this.dealMailStatus();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
dealMailStatus : function(){
|
||
|
|
|
||
|
|
let chd = nx.gui.find( this.nodCnt.bindSCV, "mask/content" ).children;
|
||
|
|
|
||
|
|
// this.list.cleanFocus();
|
||
|
|
let mails = this.choice == 0 ? this.mod.getAllMailArray() : this.mod.getNoticeArray();
|
||
|
|
let change = {};
|
||
|
|
mails.forEach( _mail =>{
|
||
|
|
if( _mail.id == this.readMail.id ){
|
||
|
|
change = _mail;
|
||
|
|
}
|
||
|
|
} )
|
||
|
|
for (let i = 0; i < chd.length; i++) {
|
||
|
|
let nod = chd[i];
|
||
|
|
if( nod.svItem && nx.dt.objNEmpty( change ) ){
|
||
|
|
if( change.id == nod.svItem.mdata.id ){
|
||
|
|
|
||
|
|
nod.svItem.rebind( i, change );
|
||
|
|
// break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// this.dealOp();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
freshMailList : function(){
|
||
|
|
|
||
|
|
this.onTogMenu( this.choice );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
touchGetAll :function() {
|
||
|
|
this.mod.getAllGoods();
|
||
|
|
},
|
||
|
|
|
||
|
|
touchDel :function(){
|
||
|
|
|
||
|
|
let mails = this.choice == 0 ? this.mod.getAllMailArray() : this.mod.getNoticeArray();
|
||
|
|
let readMails = [];
|
||
|
|
mails.forEach( _mail =>{
|
||
|
|
if( _mail.status == 2 || ( _mail.status == 1 && nx.dt.arrEmpty( _mail.assets ) ) ){
|
||
|
|
readMails.push( _mail );
|
||
|
|
}
|
||
|
|
} )
|
||
|
|
if( nx.dt.arrNEmpty( readMails ) ){
|
||
|
|
let list = this.mod.getHasReadNonRewardList();
|
||
|
|
this.mod.deletMailSend( list );
|
||
|
|
}else{
|
||
|
|
nx.tbox( "NoneMailDel" );
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
showNoticeInfo: function( _id ){
|
||
|
|
|
||
|
|
let notice_msg = this.mod.getNoticeMessage( _id );
|
||
|
|
if( notice_msg ) {
|
||
|
|
this.nodInfo.getComponent( "cmp.mail.info" ).setData( notice_msg );
|
||
|
|
}
|
||
|
|
},
|
||
|
|
});
|