Files
2026-05-23 22:10:14 +08:00

127 lines
3.0 KiB
JavaScript

/*******************************************************************************
*
* 活动: 積天好禮
*
*
******************************************************************************/
const ActBase = require( "act.base" );
const ActLuxury = cc.Class( {
extends: ActBase,
// 初始化配置数据
initConfig: function() {
// 视图附着
nx.plugin.add( this, [ "view" ] );
this.vattach( "Acts" );
},
// 注册协议接受事件
registerProtocals: function() {
this.RegisterProtocal( 16603, this.handle16603.bind( this ) ); // 請求子活動相關,來取相關的顯示數據
this.RegisterProtocal( 16604, this.handle16604.bind( this ) ); // 請求領取子活動獎勵相關,來取相關的顯示數據
},
// 从服务器初始化数据
reqBaseFromServer: function( _cb ) {
let cfgs = [
this.data.config,//付費活動
]
this.loadConfigs( cfgs, ( _ret, _data ) =>{
this.reqBaseData( _cb );
} )
},
// 请求活动信息
reqBaseData: function( _cb ) {
this.reqLuxuryData( _cb );
},
// ============================================================
// 積天好禮
// ============================================================
// 请求積天好禮信息
reqLuxuryData: function( _cb ) {
this.SendProtocal( 16603, {
bid : this.data.camp_id,
}, _cb );
},
// 请求領取積天好禮獎勵
reqGetLuxAward: function( _aim ,_cb) {
this.SendProtocal( 16604, {
bid : this.data.camp_id,
aim : _aim,
arg : 0
}, _cb);
},
// 请求相關配置信息
handle16603: function( _data ) {
if( _data.bid == this.data.camp_id ){
this.setActDay(_data.args);
this.vset( "luxuryBaseData", _data );
this.freshTips();
return;
}
},
// 请求相關配置信息
handle16604: function( _data ) {
},
// ============================================================
// 活动红点提示
// ============================================================
// 活动用到的提示KEY
tipKeys: function() {
return [ "luxuryClaim" ];
},
// 红点提示更新
freshTips: function() {
let data = this.vget( "luxuryBaseData" );
let is_reward = false;
for(let i in data.aim_list){
if(data.aim_list[i].status == 1){
is_reward = true;
break;
}
}
this.openTip( "luxuryClaim", is_reward );
},
setActDay(args){
for(let i in args){
if(args[i].args_key == 43){
this.actDay = args[i].args_val;
break;
}
}
},
getActDay(){
if(this.actDay){
return this.actDay;
}
return 0;
}
} );
// 模块导出
module.exports = ActLuxury;