165 lines
4.9 KiB
JavaScript
165 lines
4.9 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 開服冲級
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
const ActPage = require( "act.page.base" );
|
||
|
|
const NxSpine = require( "nx.fx.spine" );
|
||
|
|
const RoleController = require("role_controller");
|
||
|
|
const Mod = require( "act.growthrush.mod" );
|
||
|
|
const themeMod = require( "acts.mod" );
|
||
|
|
const FID = require( "bridge.function.ids" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: ActPage,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
nodContent: { default: null, type: cc.Node },
|
||
|
|
spRole: { default: null, type: NxSpine },
|
||
|
|
nodEndTime : { default: null, type: cc.Node },
|
||
|
|
},
|
||
|
|
|
||
|
|
// 初始化
|
||
|
|
build: function( _data ) {
|
||
|
|
|
||
|
|
this._super( _data );
|
||
|
|
// 无效
|
||
|
|
|
||
|
|
this.spRole.load( "resDB/models/H30108/show", ( _e ) => {
|
||
|
|
if( !_e ) {
|
||
|
|
this.spRole.action( "action1", true );
|
||
|
|
} else {
|
||
|
|
this.spRole.stop();
|
||
|
|
}
|
||
|
|
} );
|
||
|
|
|
||
|
|
|
||
|
|
this.lfgs = gdata( this.mod.data.config, "data_level_welfare" );
|
||
|
|
|
||
|
|
let len = Object.keys( this.lfgs ).length;
|
||
|
|
|
||
|
|
nx.gui.gocChildren( this.nodContent, "", len );
|
||
|
|
let chd = this.nodContent.children;
|
||
|
|
for (let i = 0; i < chd.length; i++) {
|
||
|
|
|
||
|
|
let item = this.lfgs[ i + 1 ];
|
||
|
|
let nod = chd[ i ];
|
||
|
|
|
||
|
|
// let cmp = nx.gui.getComponent( nod, "lst", "cmp.common.itemlayout" );
|
||
|
|
// if( cmp ){
|
||
|
|
// cmp.rebuild( item.reward );
|
||
|
|
// }
|
||
|
|
nx.gui.setString( nod, "descs/desc/title", item.name );
|
||
|
|
nx.gui.setActive( nod, "descs/leftdesc", false );
|
||
|
|
nx.gui.setActive( nod, "descs/leftdesc", false );
|
||
|
|
nx.gui.setActive( nod, "get", false );
|
||
|
|
nx.gui.setActive( nod, "def", false );
|
||
|
|
nx.gui.setActive( nod, "finish", false );
|
||
|
|
}
|
||
|
|
|
||
|
|
// 活动监听
|
||
|
|
this.mod.vbind( this, [
|
||
|
|
[ "growthrush", this.freshGift.bind( this ) ],
|
||
|
|
] );
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onEnable: function(){
|
||
|
|
|
||
|
|
// 请求信息
|
||
|
|
this.mod.reqGrowthRushData();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function() {
|
||
|
|
|
||
|
|
// 活动监听解除
|
||
|
|
if( this.mod ) {
|
||
|
|
this.mod.vunbind( this );
|
||
|
|
}
|
||
|
|
|
||
|
|
this._super();
|
||
|
|
},
|
||
|
|
|
||
|
|
freshGift: function( _data ){
|
||
|
|
|
||
|
|
if( !_data || nx.dt.objEmpty( _data ) ){
|
||
|
|
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
/******
|
||
|
|
* gifts":[
|
||
|
|
* {"id":1,"status":1,"num":0},
|
||
|
|
* {"id":2,"status":1,"num":0},
|
||
|
|
* {"id":3,"status":1,"num":0},
|
||
|
|
* {"id":4,"status":1,"num":0},
|
||
|
|
* {"id":5,"status":1,"num":0},
|
||
|
|
* {"id":6,"status":1,"num":0}
|
||
|
|
* ]
|
||
|
|
*/
|
||
|
|
let role = RoleController.getInstance().getRoleVo();
|
||
|
|
let lev = role.lev;
|
||
|
|
let gifts = _data.gifts;
|
||
|
|
gifts.sort( (a,b) =>{
|
||
|
|
return a.sortid - b.sortid;
|
||
|
|
} )
|
||
|
|
this.gifts = gifts;
|
||
|
|
if( this.nodContent.children ){
|
||
|
|
let chd = this.nodContent.children;
|
||
|
|
for (let i = 0; i < this.gifts.length; i++) {
|
||
|
|
let gift = this.gifts[i];
|
||
|
|
if( gift ){
|
||
|
|
|
||
|
|
let item = this.lfgs[ gift.id ];
|
||
|
|
let nod = chd[ i ];
|
||
|
|
nx.gui.find( nod, "get" ).zIndex = i;
|
||
|
|
nx.gui.setActive( nod, "def", gift.status == 0 || ( parseInt( item.num - gift.num ) == 0 && gift.status != 2 ) );
|
||
|
|
nx.gui.setString( nod, "descs/leftdesc/prog", parseInt( item.num - gift.num ) + "/" );
|
||
|
|
nx.gui.setActive( nod, "finish", gift.status == 2 );
|
||
|
|
nx.gui.setActive( nod, "get", gift.status == 1 && parseInt( item.num - gift.num ) != 0 );
|
||
|
|
nx.gui.setActive( nod, "descs/leftdesc", gift.status != 2 );
|
||
|
|
nx.gui.setString( nod, "descs/desc/title", item.name );
|
||
|
|
nx.gui.setString( nod, "descs/desc/prog", ( "(" + lev + "/" + item.lev + ")" ) );
|
||
|
|
nx.gui.setString( nod, "descs/leftdesc/total", item.num );
|
||
|
|
|
||
|
|
nx.gui.setActive( nod, "descs/desc/prog", false );
|
||
|
|
|
||
|
|
let cmp = nx.gui.getComponent( nod, "lst", "cmp.common.itemlayout" );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.rebuild( item.reward );
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchGet: function( _btn ){
|
||
|
|
|
||
|
|
let number = _btn.zIndex;
|
||
|
|
let id = this.gifts[number].id;
|
||
|
|
if( this.gifts[number].status != 1 ){
|
||
|
|
nx.tbox( "lab_ladder_main_window_tip4" );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.mod.reqGetGift( id );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// close: function(){
|
||
|
|
|
||
|
|
// let theme = themeMod.getInstance().queryTheme( this.mod.data.theme_id );
|
||
|
|
|
||
|
|
// nx.bridge.jumper.jump2Window( FID.ActOpenServer, theme );
|
||
|
|
// this._super();
|
||
|
|
// },
|
||
|
|
} );
|
||
|
|
/******************
|
||
|
|
*
|
||
|
|
*/
|