212 lines
5.8 KiB
JavaScript
212 lines
5.8 KiB
JavaScript
// --------------------------------------------------------------------
|
|
// @author: shiraho@syg.com(必填, 创建模块的人员)
|
|
// @description:
|
|
// 竖版邮件
|
|
// <br/>Create: new Date().toISOString()
|
|
// --------------------------------------------------------------------
|
|
|
|
var PathTool = require( "pathtool" );
|
|
var MailController = require( "mail.mod" );
|
|
var MailEvent = require( "mail_event" );
|
|
var BridgeWindow = require( "bridge.window" )
|
|
const FxSVC = require( "nx.fx.sv.expand" );
|
|
const FxTogs = require( "nx.fx.togs" );
|
|
|
|
cc.Class( {
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
list: {
|
|
default: null,
|
|
type: FxSVC
|
|
},
|
|
togs: {
|
|
default: null,
|
|
type: FxTogs
|
|
},
|
|
view: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
delBtn:{
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
getBtn:{
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
cur_index: 1,
|
|
info_pre: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
this.ctrl = MailController.getInstance();
|
|
this.select_index = 0;
|
|
//刷新邮件
|
|
this.bindGEvent( MailEvent.UPDATE_ITEM, this.freshMial.bind( this ) );
|
|
//刷新公告
|
|
this.bindGEvent( MailEvent.UPDATE_NOTICE, this.freshMial.bind( this ) );
|
|
//读取公告
|
|
this.bindGEvent( MailEvent.READ_INFO_NOTICE, this.readOneNotice.bind( this ) );
|
|
//读取邮件
|
|
this.bindGEvent( MailEvent.OPEN_INFO_WIN, this.readOneMail.bind( this ) );
|
|
this.bindGEvent( MailEvent.FRESH_ITEM, this.setItemsStatus.bind(this));
|
|
|
|
this.togs.posTog = this.onTogMenu.bind( this );
|
|
this.togs.togTo( 0 );
|
|
},
|
|
|
|
freshMial() {
|
|
if( this.cur_index == 1 )
|
|
this.info_win.getComponent( "cmp.mail.info" ).resetData();
|
|
this.selectedTabCallBack( this.cur_index );
|
|
},
|
|
|
|
freshNotice( flag, data ) {
|
|
if( this.cur_index == 2 )
|
|
this.info_win.getComponent( "cmp.mail.info" ).resetData();
|
|
this.selectedTabCallBack( this.cur_index );
|
|
},
|
|
|
|
setItemsStatus(){
|
|
let index = this.cur_index;
|
|
var list = [];
|
|
if( index == 1 ) {
|
|
var array = this.ctrl.getAllMailArray();
|
|
for( var i = 0; i < array.length; i++ ) {
|
|
list.push( array[ i ] );
|
|
}
|
|
} else if( index == 2 ) {
|
|
var array = this.ctrl.getNoticeArray();
|
|
|
|
for( var i = 0; i < array.length; i++ ) {
|
|
list.push( array[ i ] );
|
|
}
|
|
}
|
|
this.list.rebuild( list );
|
|
this.list.addFocus( this.select_index );
|
|
},
|
|
|
|
readOneNotice( id ) {
|
|
let notice_msg = this.ctrl.getNoticeMessage( id )
|
|
if( notice_msg ) {
|
|
this.info_win.getComponent( "cmp.mail.info" ).setData( notice_msg );
|
|
}
|
|
},
|
|
|
|
readOneMail( data ) {
|
|
//打开info界面
|
|
if( data ) {
|
|
this.info_win.getComponent( "cmp.mail.info" ).setData( data );
|
|
}
|
|
},
|
|
|
|
start() {
|
|
|
|
},
|
|
|
|
onDisable() {
|
|
if( nx.bridge.prompt ) {
|
|
nx.bridge.prompt.delPrompt( 1 );
|
|
}
|
|
},
|
|
|
|
// registerEvent: function () {
|
|
|
|
// //更新红点状态
|
|
// // if(this.red_status_event == null){
|
|
// // this.red_status_event = gcore.GlobalEvent.bind(MailEvent.UPDATEREDSTATUS, (function (bid, num) {
|
|
|
|
// // }).bind(this))
|
|
// // }
|
|
// },
|
|
|
|
selectedTabCallBack: function( index ) {
|
|
this.cur_index = index;
|
|
var list = [];
|
|
if( index == 1 ) {
|
|
var array = this.ctrl.getAllMailArray();
|
|
for( var i = 0; i < array.length; i++ ) {
|
|
list.push( array[ i ] );
|
|
}
|
|
this.delBtn.active = true;
|
|
this.getBtn.active = true;
|
|
} else if( index == 2 ) {
|
|
var array = this.ctrl.getNoticeArray();
|
|
|
|
for( var i = 0; i < array.length; i++ ) {
|
|
list.push( array[ i ] );
|
|
}
|
|
this.delBtn.active = false;
|
|
this.getBtn.active = false;
|
|
}
|
|
this.list.rebuild( list );
|
|
if( list.length == 0 ) {
|
|
this.info_win.getComponent( "cmp.mail.info" ).resetData();
|
|
this.info_win.active = false;
|
|
} else {
|
|
this.info_win.active = true;
|
|
this.scheduleOnce( () => {
|
|
this.onFocusChanged( { index: 0, mdata: list[ 0 ] } );
|
|
}, 0.5 );
|
|
}
|
|
},
|
|
|
|
touchDel() {
|
|
var list = this.ctrl.getHasReadNonRewardList();
|
|
this.ctrl.deletMailSend( list );
|
|
},
|
|
|
|
touchGet() {
|
|
this.ctrl.getAllGoods();
|
|
},
|
|
|
|
onOpenConfigs() {
|
|
this.info_win = cc.instantiate( this.info_pre );
|
|
this.info_win.setParent( this.view );
|
|
this.selectedTabCallBack( this.cur_index )
|
|
},
|
|
|
|
onPreClosed() {
|
|
this.list.rebuild( [] );
|
|
},
|
|
|
|
onTogMenu( _index ) {
|
|
this.info_win.getComponent( "cmp.mail.info" ).resetData();
|
|
this.selectedTabCallBack( _index + 1 );
|
|
},
|
|
|
|
// 选中切换
|
|
onFocusChanged: function( _item ) {
|
|
|
|
// 空
|
|
if( nx.dt.objEmpty( _item ) ||
|
|
nx.dt.objEmpty( _item.mdata ) ) {
|
|
return;
|
|
}
|
|
|
|
// 聚焦
|
|
this.list.cleanFocus();
|
|
this.list.addFocus( _item.index );
|
|
this.select_index = _item.index;
|
|
if( _item.mdata.status >= 0 ) {//邮件
|
|
this.ctrl.requireMailItem( _item.mdata.id, _item.mdata.srv_id, this.info_win);
|
|
} else if( _item.mdata.flag >= 0 ) {//公告
|
|
this.ctrl.readNotice( _item.mdata.id )
|
|
}
|
|
},
|
|
|
|
touchClose() {
|
|
// if(this.info_win){
|
|
// this.info_win.deleteMe();
|
|
// }
|
|
this.ctrl.openMailUI( false )
|
|
},
|
|
// update (dt) {},
|
|
} ); |