/****************************************************************** * * STEPUP 助力禮包 * ******************************************************************/ const ActPage = require( "act.page.base" ); const STModel = require( "act.stepup.mod" ); const TDefine = require( "trace.define" ); const TTT = TDefine.TraceType; cc.Class( { extends: ActPage, properties: { lstProd: { default: null, type: cc.Node }, nodDate: { default: null, type: cc.Node }, }, // 初始化 build: function( _data ) { this._super( _data ); let model = STModel.getInstance(); if( !model ) { this.delayClose(); return; } // 视图监听 model.vbind( this, [ [ "stepGifts", this.onGiftsFresh.bind( this ) ], ] ); nx.gui.setActive( this.nodDate, "", false ); model.reqGiftList(); // 埋点 if( nx.mTrace ) { nx.mTrace.trace( TTT.actCampOpened, model.data.camp_id, 1 ); } }, // 关闭 onDestroy: function() { // 视图监听 let model = STModel.getInstance(); if( model ) { model.vunbind( this ); } }, // 礼包刷新 onGiftsFresh: function( _lst, _old, _init ) { if( _init ) return; // 空 if( nx.dt.arrEmpty( _lst ) ) { nx.gui.setActive( this.lstProd, "", false ); return; } // 重建 nx.gui.setActive( this.lstProd, "", true ); let root = nx.gui.find( this.lstProd, "view/content" ); nx.gui.gocChildren( root, "", _lst.length, root.children[ 0 ] ); for( let i = 0; i < _lst.length; ++i ) { let cmp = nx.gui.getComponent( root.children[ i ], "", "cmp.act.stepup.gift.item" ); cmp.setData( _lst[ i ] ); } } } );