188 lines
4.4 KiB
JavaScript
188 lines
4.4 KiB
JavaScript
/*******************************************************************************
|
|
*
|
|
* 活动: 限时招募五选一升星活动
|
|
*
|
|
*
|
|
******************************************************************************/
|
|
|
|
const ActBase = require( "act.base" );
|
|
|
|
const LimitActUpStar = cc.Class( {
|
|
|
|
extends: ActBase,
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
|
|
// 视图附着
|
|
nx.plugin.add( this, [ "view" ] );
|
|
this.vattach( "Acts" );
|
|
|
|
},
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function() {
|
|
this.RegisterProtocal(29220, this.handle29220.bind(this) );//获取主界面信息
|
|
this.RegisterProtocal(29221, this.handle29221.bind(this) );//请求可以参加升星的英雄
|
|
this.RegisterProtocal(29222, this.handle29222.bind(this) );//选择英雄
|
|
this.RegisterProtocal(29223, this.handle29223.bind(this) );//锁定英雄
|
|
this.RegisterProtocal(29224, this.handle29224.bind(this) );//领取免费奖励
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function( _cb ) {
|
|
let cfgs = [
|
|
"holiday_upstars_new_data",
|
|
]
|
|
this.loadConfigs( cfgs, ( _ret, _data ) =>{
|
|
this.reqBaseData(_cb);
|
|
} )
|
|
},
|
|
|
|
// 请求剧情信息
|
|
reqBaseData: function( _cb ) {
|
|
this.reqUpstarData(_cb);
|
|
},
|
|
|
|
|
|
reqUpstarData( _cb ){
|
|
this.send29220(_cb);
|
|
},
|
|
|
|
// ============================================================
|
|
// 升星操作
|
|
// ============================================================
|
|
|
|
//任務信息
|
|
send29220(_cb){
|
|
this.SendProtocal(29220, {},_cb)
|
|
},
|
|
|
|
handle29220: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
this.vset( "limitUpstarAwards", [] );
|
|
return;
|
|
}
|
|
this.setChooseHero(_data.choose_partner_bid,_data.choose_partner_star);
|
|
this.setIsLock(_data.islock);
|
|
this.setLimitTime(_data.end_time);
|
|
this.vset( "limitUpstarAwards", _data.award_list);//獎勵列表
|
|
|
|
// 提示刷新
|
|
this.freshTips( _data );
|
|
},
|
|
|
|
send29221(_cb){
|
|
this.SendProtocal(29221, {},_cb)
|
|
},
|
|
|
|
handle29221: function( _data ) {
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
this.vset( "limitHeros", _data);
|
|
},
|
|
|
|
//選擇英雄
|
|
send29222(_bid,_cb){
|
|
this.SendProtocal(29222, {
|
|
partner_Bid:_bid
|
|
},_cb)
|
|
},
|
|
|
|
handle29222: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
//鎖定英雄
|
|
send29223(_cb){
|
|
this.SendProtocal(29223,{},_cb)
|
|
},
|
|
|
|
handle29223: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
//领取免费奖励
|
|
send29224(_partner_star,_cb){
|
|
this.SendProtocal(29224,{
|
|
partner_star:_partner_star
|
|
},_cb)
|
|
},
|
|
|
|
handle29224: 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("limitUpstarAwards");
|
|
|
|
let count = 0;
|
|
for(let i=0;i<tasks.length;i++){
|
|
if(tasks[i].free_state == 1){
|
|
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;
|
|
},
|
|
|
|
setIsLock(status){
|
|
this.is_lock = status;
|
|
},
|
|
|
|
getIsLock(){
|
|
if(this.is_lock != null){
|
|
return this.is_lock;
|
|
}
|
|
return 0;
|
|
},
|
|
|
|
setLimitTime(time){
|
|
this.end_time = time;
|
|
},
|
|
|
|
getLimitTime(){
|
|
if(this.end_time){
|
|
return this.end_time;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
} );
|
|
|
|
// 模块导出
|
|
module.exports = LimitActUpStar; |