Files

134 lines
3.3 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
/*******************************************************************************
*
* 活动: 升星计划
*
*
******************************************************************************/
const ActBase = require( "act.base" );
const ActHeroUpStar = cc.Class( {
extends: ActBase,
// 初始化配置数据
initConfig: function() {
// 视图附着
nx.plugin.add( this, [ "view" ] );
this.vattach( "Acts" );
},
// 注册协议接受事件
registerProtocals: function() {
this.RegisterProtocal(29211, this.handle29211.bind(this) );//获取主界面信息
this.RegisterProtocal(29212, this.handle29212.bind(this) );//领取免费奖励
},
// 从服务器初始化数据
reqBaseFromServer: function( _cb ) {
let cfgs = [
"holiday_upstars_new_data",
]
this.loadConfigs( cfgs, ( _ret, _data ) =>{
this.reqBaseData( this.data.camp_id, _cb );
} )
},
// 请求剧情信息
reqBaseData: function( _camp_id, _cb ) {
this.send29211( _camp_id, _cb );
},
// ============================================================
// 升星操作
// ============================================================
//任務信息
send29211( _camp_id, _cb){
this.SendProtocal(29211, {
camp_id : _camp_id,
},_cb)
},
handle29211: function( _data ) {
if( !this.isGoodData( _data ) ) {
this.vset( "heroUpstarAwards", [] );
return;
}
this.setChooseHero(_data.partner_bid,_data.partner_star);
this.setLimitTime(_data.end_time);
this.vset( "heroUpstarAwards", _data.award_list);//獎勵列表
// 提示刷新
this.freshTips( _data );
},
//领取免费奖励
send29212(_partner_star, _camp_id,_cb){
this.SendProtocal(29212,{
partner_star:_partner_star,
camp_id : _camp_id,
},_cb)
},
handle29212: function( _data ) {
nx.bridge.acts.reqActsRewards();
if( !this.isGoodData( _data ) ) {
return;
}
},
// ============================================================
// 活动红点提示
// ============================================================
// // 活动用到的提示KEY
// tipKeys: function() {
// return ["star5","star6","star7","star8","star9","star10"];
// },
// 红点提示更新
freshTips: function( _data ) {
let tasks = this.vget("upstarAwards");
let count = 0;
for(let i=0;i<tasks.length;i++){
if(tasks[i].free_state == 1){
// this.openTip( this.tipKeys()[i], true );
count ++;
}else{
}
}
this.openTip( "reward", count > 0 || _data.islock == 0 );
},
setChooseHero(bid,star){
this.tag_partner = {};
this.tag_partner.bid = bid;
this.tag_partner.star = star;
},
getChooseHero(){
return this.tag_partner;
},
setLimitTime(time){
this.end_time = time;
},
getLimitTime(){
if(this.end_time){
return this.end_time;
}
return 0;
}
} );
// 模块导出
module.exports = ActHeroUpStar;