145 lines
3.5 KiB
JavaScript
145 lines
3.5 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 常规活动列表
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeWindow = require( "bridge.window" );
|
|
const ActDefine = require( "acts.define" );
|
|
const FxSVC = require( "nx.fx.sv.expand" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
|
|
nodHead: { default: null, type: cc.Node },
|
|
nodContent: { default: null, type: cc.Node },
|
|
lstMenu: { default: null, type: FxSVC },
|
|
},
|
|
|
|
// 重载:参数打开
|
|
onOpenConfigs: function( _params ) {
|
|
|
|
// 无效参数
|
|
if( nx.dt.objEmpty( _params ) ||
|
|
!nx.dt.numPositive( _params.theme_id, false ) ) {
|
|
this.delayClose();
|
|
return;
|
|
}
|
|
|
|
this.configs = _params;
|
|
|
|
// 标题
|
|
nx.gui.setString( this.nodHead, "txt", nx.text.getKey( _params.name ) );
|
|
|
|
// 列表构建
|
|
this.menus = _params.theme_holiday_list || [];
|
|
|
|
this.menus.sort( ( a, b ) => {
|
|
return a.sort - b.sort;
|
|
} )
|
|
|
|
this.lstMenu.rebuild( this.menus );
|
|
|
|
// 延迟跳转
|
|
this.scheduleOnce( () => {
|
|
this.jumpToMenu( _params.focus );
|
|
}, 0.1 );
|
|
|
|
},
|
|
|
|
// 重载:关闭前
|
|
onPreClosed: function() {
|
|
// nx.bridge.acts.reqActsRewards();
|
|
},
|
|
|
|
close: function() {
|
|
this._super();
|
|
|
|
//判断下是不是要回到openserver
|
|
let needShow = cc.sys.localStorage.getItem("needBackOpenServerAct");
|
|
if(needShow == 1)
|
|
{
|
|
//cc.sys.localStorage.removeItem("needBackOpenServerAct")
|
|
nx.bridge.createPanel("WndOpenServer");
|
|
}
|
|
},
|
|
|
|
// 关闭
|
|
onDisable: function() {
|
|
|
|
},
|
|
|
|
// 跳转指定标签
|
|
jumpToMenu: function( _camp_id = 0 ) {
|
|
|
|
// 默认页
|
|
let order = 0;
|
|
for( let i = 0; i < this.menus.length; ++i ) {
|
|
let t = this.menus[ i ];
|
|
if( t && t.camp_id == _camp_id ) {
|
|
order = i;
|
|
break;
|
|
}
|
|
}
|
|
this.onSelectMenu( { index: order, mdata: this.menus[ order ] } );
|
|
},
|
|
|
|
// 菜单切换
|
|
onSelectMenu: function( _item ) {
|
|
|
|
if( !_item.mdata ) {
|
|
return;
|
|
}
|
|
// 聚焦
|
|
this.lstMenu.cleanFocus();
|
|
this.lstMenu.addFocus( _item.index );
|
|
|
|
let self = this;
|
|
let focus = function( _name ) {
|
|
let chds = self.nodContent.children;
|
|
chds.forEach( _page => {
|
|
_page.active = ( _page.name == _name );
|
|
} );
|
|
};
|
|
|
|
let key = "P" + _item.mdata.camp_id;
|
|
let page = nx.gui.find( this.nodContent, key );
|
|
if( page ) {
|
|
focus( key );
|
|
return;
|
|
}
|
|
|
|
// 加载
|
|
let mod = ActDefine.ActsMods[ _item.mdata.source ];
|
|
if( !mod ) {
|
|
nx.error( "$Acts:无效活动页:", _item.mdata.source );
|
|
return;
|
|
}
|
|
|
|
let path = cc.path.join( "prefab/acts", mod.prefab );
|
|
nx.res.loadPrefab( path, ( _err, _data ) => {
|
|
|
|
if( _err ) {
|
|
return;
|
|
}
|
|
|
|
let node = cc.instantiate( _data );
|
|
let cmp = node.getComponent( "act.page.base" );
|
|
if( cmp ) {
|
|
cmp.actRoot = this;
|
|
cmp.build( _item.mdata );
|
|
}
|
|
node.name = key;
|
|
node.parent = this.nodContent;
|
|
|
|
focus( key );
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
} );
|