Files
fc/dev/project/assets/Scripts/mod/acts/sign15/act.sign15.page.js
T
2026-05-23 22:10:14 +08:00

138 lines
3.4 KiB
JavaScript

/******************************************************************
*
* 签到15日
*
******************************************************************/
const ActPage = require( "act.page.base" );
const NxSpine = require( "nx.fx.spine" );
const FxSVC = require( "nx.fx.sv.expand" );
const TipsController = require( "tips_controller" );
const BridgeItemBinder = require( "bridge.binder.item.icon.count" );
cc.Class( {
extends: ActPage,
properties: {
spRole: { default: null, type: NxSpine },
imgLogo: { default: null, type: cc.Node },
lstTask: { default: null, type: FxSVC },
nodDate: { default: null, type: cc.Node },
nodItem1: { default: null, type: BridgeItemBinder },
nodItem2: { default: null, type: BridgeItemBinder },
},
// 初始化
build: function( _data ) {
this._super( _data );
// 活动监听
this.mod.vbind( this, [
["sign15", this.freshTask.bind( this )],
] );
this.freshBasic();
},
// 销毁
onDestroy: function() {
// 活动监听解除
if( this.mod ) {
this.mod.vunbind( this );
}
this._super();
},
// 置空
setEmpty: function() {
},
// 基本信息
freshBasic: function() {
// 置空
if( nx.dt.objEmpty( this.data ) ) {
this.setEmpty();
return;
}
// 刷新活动日期
let time = nx.bridge.time.toNeedTime( this.data.end_time );
nx.gui.setString( this.nodDate, "txt", time );
let cfgs = this.mod.queryConfig();
if( nx.dt.objEmpty( cfgs ) ) {
return;
}
this.nodItem1.setID( cfgs.item1 );
this.nodItem2.setID( cfgs.item2 );
// 看板娘
let sp = cc.path.join( "resDB/models", cfgs.res, "show" );
this.spRole.load( sp, ( _e ) => {
if( !_e ) {
this.spRole.action( cfgs.action, true );
} else {
this.spRole.stop();
}
} );
// 文本LOGO
let img = cc.path.join( "locals/{lang}/images", cfgs.desc );
nx.gui.setSpriteFrame( this.imgLogo, "", nx.res.fmtPath( img ) );
},
// 任务刷新
freshTask: function( _lst ) {
// 空
let cfgs = this.mod.queryTaskList();
if( nx.dt.arrEmpty( _lst ) || nx.dt.objEmpty( cfgs ) ) {
this.lstTask.rebuild( [] );
return;
}
// 重建
this.tasks = [];
for( let i = 0; i < _lst.length; ++i ) {
let item = _lst[i];
let task = nx.dt.objClone( cfgs[item.day] );
task.status = item.status;
task.mod = this.mod;
this.tasks.push( task );
}
// 0不可领取 1可领取 2已领取
let PR = [2, 1, 3];
this.tasks.sort( ( a, b ) => {
if( a.status == b.status ) {
return a.day - b.day;
}
return PR[a.status] - PR[b.status];
} );
this.lstTask.rebuild( this.tasks );
},
// 点击规则
onTouchRule: function() {
let rule = this.mod ? this.mod.queryRule() : "";
if( nx.dt.strNEmpty( rule ) ) {
const TC = TipsController.getInstance();
TC.showTextPanel( "tip", rule );
}
},
// 点击商城
onTouchShop: function() {
nx.bridge.jumper.jump2Window( 474 );
},
} );