Files
fc/dev/project/assets/Scripts/mod/acts/poweraim/act.poweraim.wnd.js
T

218 lines
6.4 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const BasePage = require( "act.page.base" );
const RoleEvent = require( "role_event" );
const NxSpine = require( "nx.fx.spine" );
const TipsController = require( "tips_controller" );
const RoleController = require( "role_controller" );
cc.Class({
extends: BasePage,
properties: {
nodReward:{ default: null, type : cc.Node },
nodEndTime : { default: null, type: cc.Node },
nodRole: { default: null, type: cc.Node },
nodGotos: { default: null, type: cc.Node },
nodPower: { default: null, type: cc.Node },
},
// 初始化
build: function( _data ) {
this._super( _data );
this.cfg = gdata( this.data.config, "data_get_info" );
let ccfg = gdata( this.data.config, "data_source" );
let list = [];
let jumps = [];
for (let i in this.cfg ) {
let item = this.cfg[i];
let ccf = ccfg[i];
if( ccf ){
jumps.push( ccf );
}
list.push( item );
}
nx.gui.gocChildren( this.nodGotos, "", jumps.length );
let jhd = this.nodGotos.children;
nx.gui.gocChildren( this.nodReward, "", list.length );
let icopath = "prefab/acts/poweraim/ui/ico";
let chd = this.nodReward.children;
for (let c = 0; c < jhd.length; c++) {
let jnod = jhd[c];
if( jnod ){
jnod.goto = jumps[c].source_id;
nx.gui.setString( jnod, "txt", jumps[c].desc );
nx.gui.setSpriteFrame( jnod, "ico", c == 4 || c == 5 ? icopath + ( c - 3 ) : icopath + ( c + 1 ) );
}
}
let role = RoleController.getInstance().getRoleVo();
let lfg = game.configs.looks_data.data_data[role.look_id];
let server = role.srv_id;
let desc = server.split( "_" );
nx.gui.setString( this.nodRole, "info/vip/lev", role.vip_lev );
nx.gui.setString( this.nodPower, "txt", role.power );
nx.gui.setString( this.nodRole, "info/name", nx.text.format( "ActPowerSelfTip", desc[1], role.name ) );
let cd = _data.end_time - Math.floor( cc.sys.now() / 1000 ) > 0 ? _data.end_time - Math.floor( cc.sys.now() / 1000 ) : 0.1;
nx.gui.setCdTxt( this.nodEndTime, "txt", cd, () => {
nx.gui.setString( this.nodEndTime, "txt", nx.text.getKey( "lab_planesafk_main_have_over" ) );
} );
// 获取指定主题信息
let path = cc.path.join( "resDB/models/", lfg.model + "/" + lfg.model );
let nodrole = nx.gui.getComponent( this.nodRole, "nodrole", NxSpine );
if( nodrole ){
nodrole.load( path, ( _e ) => {
if( !_e ) {
nodrole.action( "stand2" , true );
} else {
nodrole.stop();
}
} );
}
// 视图监听
this.mod.vbind( this, [
[ "ActsPowerAimProve", this.freshInfo.bind( this ) ],
] );
this.bindGEvent( RoleEvent.UpdateModel, this.freshRoleFigure.bind( this ) );
},
// 开启
onEnable: function() {
this.mod.reqBaseData();
// console.log( "當前的首次充值信息" + JSON.stringify( this.mod.reqChargeData() ) );
},
freshRoleFigure : function( _data ){
let rolefigure = _data.code == 1 ? _data.id : 0;
if( rolefigure > 0 ){
let lfg = game.configs.looks_data.data_data[rolefigure];
let path = cc.path.join( "resDB/models/", lfg.model + "/" + lfg.model );
let nodrole = nx.gui.getComponent( this.nodRole, "nodrole", NxSpine );
if( nodrole ){
nodrole.load( path, ( _e ) => {
if( !_e ) {
nodrole.action( "stand2" , true );
} else {
nodrole.stop();
}
} );
}
}
},
// 销毁
onDestroy: function() {
// 活动监听解除
if( this.mod ) {
this.mod.vunbind( this );
}
this.unbindGEvents();
this._super();
},
freshInfo: function( _data ){
/***
* [23400]:{"power_gift_list":
* [{"id":1,"status":1},
* {"id":2,"status":1},
* {"id":3,"status":1},
* {"id":4,"status":1},
* {"id":5,"status":1},
* {"id":6,"status":1},
* {"id":7,"status":1},
* {"id":8,"status":1},
* {"id":9,"status":1},
* {"id":10,"status":1},
* {"id":11,"status":1},
* {"id":12,"status":1},
* {"id":13,"status":1}]}
* */
if( !_data || nx.dt.objEmpty( _data ) ){
return;
}
_data.power_gift_list.sort( ( a, b )=>{
return a.sortid - b.sortid;
} )
let chd = this.nodReward.children;
let list = _data.power_gift_list;
for (let i = 0; i < list.length; i++) {
let info = list[i];
let rfg = this.cfg[info.id];
let nod = chd[i];
if( info ){
nx.gui.setString( nod, "desc/aim", rfg.val );
let ccmp = nx.gui.getComponent( nod, "rewards", "cmp.common.itemlayout" );
if( ccmp ){
ccmp.rebuild( rfg.rewards );
}
nx.gui.find( nod, "get" ).getid = rfg.id;
nx.gui.setActive( nod, "get", info.status == 1 );
nx.gui.setActive( nod, "cannot", info.status == 0 );
nx.gui.setActive( nod, "got", info.status == 2 );
}
}
},
onTouchGoto: function( _nod ){
let fid = _nod.goto;
nx.bridge.jumper.jump2Window( fid );
},
onTouchGet: function( _nod ){
let fid = _nod.getid;
this.mod.reqGet( fid );
},
onTouchChange: function(){
let RC = RoleController.getInstance();
RC.fetchFigureData( ( _ret, _data ) => {
if( !_ret ) {
nx.tbox( _data );
return;
}
nx.bridge.createPanel( "WndPersonalFigure", _data );
} );
},
onTouchHelp: function(){
let TC = TipsController.getInstance();
let explain = gdata( this.mod.data.config, "data_explain" )[1];
TC.showTextPanel( explain.title, explain.desc );
},
});