Files
2026-05-23 22:10:14 +08:00

93 lines
2.1 KiB
JavaScript

/******************************************************************
*
* 首充
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const ActDefine = require( "acts.define" );
cc.Class( {
extends: BridgeWindow,
properties: {
nodWin:{default:null,type:cc.Node}
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
// 无效参数
if( nx.dt.objEmpty( _params ) ||
!nx.dt.numPositive( _params.theme_id, false ) ) {
this.delayClose();
return;
}
this.configs = _params;
// 列表构建
this.menus = _params.theme_holiday_list || [];
this.menus.sort( ( a, b ) =>{
return a.sort - b.sort;
} )
// 默认页
let def = 0;
if( nx.dt.numGood( _params.focus ) ) {
for( let i = 0; i < this.menus.length; ++i ) {
let t = this.menus[i];
if( t && t.camp_id == _params.focus ) {
def = i;
break;
}
}
}
// 延迟跳转
this.scheduleOnce( () => {
this.onSelectMenu( { mdata: this.menus[ def ] } );
}, 0.1 );
},
// 关闭
onDisable: function() {
},
// 菜单切换
onSelectMenu: function( _item ) {
if( !_item.mdata ){
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.build( _item.mdata );
}
node.parent = this.nodWin;
} );
},
} );