Files
fc/dev/project/assets/Scripts/mod/acts/sign30/cmp.act.sign30.js
T

165 lines
4.6 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const BasePage = require( "act.page.base" );
const FxSVC = require( "nx.fx.sv.expand" );
const NxSpine = require( "nx.fx.spine" );
const FID = require( "bridge.function.ids" );
cc.Class({
extends: BasePage,
properties: {
nodReward:{
default: null,
type : FxSVC
},
spRole: { default: null, type: NxSpine },
},
// 初始化
build: function( _data ) {
this._super( _data );
this.unscheduleAllCallbacks();
let cfgs = gdata( this.data.config, "data_award" );
let now = new Date();
let tomon = now.getMonth();
let rlist = [];
let rewards = cfgs[tomon + 1];
if( rewards ){
for (let mon in rewards ) {
let reward = rewards[mon];
rlist.push( reward.rewards[0] );
}
}
this.nodReward.rebuild( rlist );
this.spRole.load( "resDB/models/H30069/show", ( _e ) => {
if( !_e ) {
this.spRole.action( "action1", true );
} else {
this.spRole.stop();
}
} );
// 视图监听
nx.bridge.acts.vbind( this, [
[ "sign30", this.freshDayReward.bind( this ) ],
] );
// this.mod.reqBaseData();
nx.debug( "$ActPage onEnable");
// 获取指定主题信息
},
// 开启
onEnable: function() {
this.mod.reqBaseData();
if( nx.bridge.plot && nx.bridge.plot.isDoing() ){
this.scheduleOnce( ()=>{
this.dealPlot();
}, 0.005 );
// this.nodFocus.getComponent( "cmp.plot.trigger" ).pID = "sign";
// this.nodFocus.getComponent( "cmp.plot.trigger" ).regist();
}
// console.log( "當前的首次充值信息" + JSON.stringify( this.mod.reqChargeData() ) );
},
// 销毁
onDestroy: function() {
// 活动监听解除
if( nx.bridge.acts ) {
nx.bridge.acts.vunbind( this );
}
this._super();
},
freshDayReward: function( _data ){
if( nx.dt.objEmpty( _data ) ){
return;
}
this.chargeinfo = this.mod.reqChargeData();
this.freshState( _data );
},
freshState: function( _data ){
if( !_data ){
return;
}
let day = _data.day;
let status = _data.status;
let children = this.nodReward.bindSCV.content.children;
for( let i = 0; i < children.length; ++i ) {
let temp = children[ i ];
if( temp.svItem ) {
temp.svItem.setAgainFun( ()=>{
if( this.chargeinfo && this.chargeinfo.status == 0 ){
// 否则提示退出游戏
nx.mbox( "lab_sign_panel_tip1", [ "Cancle", "Sure" ], ( _key, _box ) => {
_box.close();
if( _key == "Sure" ) {
nx.bridge.jumper.jump2Window( FID.Charge );
}
} )
// nx.tbox( "充值" );
}else{
this.mod.reqSign();
}
// 提示 彈充值相關
});
if( i == day && status == 0 ){
temp.svItem.onFocus();
temp.svItem.setStaus( 0 );
temp.svItem.setFun( ()=>{
this.mod.reqSign();
} )
}else if( i == ( day - 1 ) && status == 1 ){
temp.svItem.outFocus();
temp.svItem.setStaus( 1, this.chargeinfo && this.chargeinfo.status == 1 );
}else {
if( ( i < day && status == 2 ) || i < day ) {
temp.svItem.outFocus();
let state = 2;
temp.svItem.setStaus( state );
}
}
}
}
},
dealPlot: function(){
let children = this.nodReward.bindSCV.content.children;
let nod = children[0];
let cell = nx.gui.find( this, "plot" );
let pos = nod.convertToWorldSpaceAR( cc.Vec2.ZERO );
cell.position = cell.parent.convertToNodeSpaceAR( pos );
cell.width = nod.width;
cell.height = nod.height;
},
onTouchSign: function(){
this.mod.reqSign();
}
});