200 lines
4.8 KiB
JavaScript
200 lines
4.8 KiB
JavaScript
/*******************************************************************************
|
|
*
|
|
* 活动: 升星有禮活動
|
|
*
|
|
*
|
|
******************************************************************************/
|
|
|
|
const ActBase = require( "act.base" );
|
|
|
|
const ActUpStar = cc.Class( {
|
|
|
|
extends: ActBase,
|
|
|
|
// 初始化配置数据
|
|
initConfig: function() {
|
|
|
|
// 视图附着
|
|
nx.plugin.add( this, [ "view" ] );
|
|
this.vattach( "Acts" );
|
|
|
|
},
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function() {
|
|
this.RegisterProtocal(29200, this.handle29200.bind(this) );//获取主界面信息
|
|
this.RegisterProtocal(29201, this.handle29201.bind(this) );//请求可以参加専屬升星的英雄
|
|
this.RegisterProtocal(29202, this.handle29202.bind(this) );//选择英雄
|
|
this.RegisterProtocal(29203, this.handle29203.bind(this) );//锁定英雄
|
|
this.RegisterProtocal(29204, this.handle29204.bind(this) );//领取免费奖励
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function( _cb ) {
|
|
let cfgs = [
|
|
"holiday_upstars_data",
|
|
]
|
|
this.loadConfigs( cfgs, ( _ret, _data ) =>{
|
|
this.reqBaseData(_cb);
|
|
} )
|
|
},
|
|
|
|
// 请求剧情信息
|
|
reqBaseData: function( _cb ) {
|
|
this.reqUpstarData(_cb);
|
|
},
|
|
|
|
|
|
reqUpstarData( _cb ){
|
|
this.send29200(_cb);
|
|
},
|
|
|
|
// ============================================================
|
|
// 升星操作
|
|
// ============================================================
|
|
|
|
//任務信息
|
|
send29200(_cb){
|
|
this.SendProtocal(29200, {},_cb)
|
|
},
|
|
|
|
handle29200: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
this.vset( "upstarAwards", [] );
|
|
return;
|
|
}
|
|
this.setChooseHero(_data.choose_partner_bid,_data.choose_partner_star);
|
|
this.setIsLock(_data.islock);
|
|
this.setLimitTime(_data.end_time);
|
|
this.vset( "upstarAwards", _data.award_list);//獎勵列表
|
|
// let partner = {};
|
|
// if( _data.choose_partner_bid > 0 ){
|
|
// partner.bidid = _data.choose_partner_bid,
|
|
// partner.star = _data.choose_partner_star
|
|
// }
|
|
// if( nx.dt.objNEmpty( partner ) ){
|
|
// this.vset( "upstarHeros", partner );
|
|
// }
|
|
|
|
// 提示刷新
|
|
this.freshTips( _data );
|
|
},
|
|
|
|
send29201(_cb){
|
|
this.SendProtocal(29201, {},_cb)
|
|
},
|
|
|
|
handle29201: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
// this.vset( "upstarHeros", {});
|
|
return;
|
|
}
|
|
this.vset( "upstarHeros", _data);
|
|
},
|
|
|
|
//選擇英雄
|
|
send29202(_partner_id,_cb){
|
|
this.SendProtocal(29202, {
|
|
partner_id:_partner_id
|
|
},_cb)
|
|
},
|
|
|
|
handle29202: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
//鎖定英雄
|
|
send29203(_cb){
|
|
this.SendProtocal(29203,{},_cb)
|
|
},
|
|
|
|
handle29203: function( _data ) {
|
|
|
|
if( !this.isGoodData( _data ) ) {
|
|
return;
|
|
}
|
|
},
|
|
|
|
//领取免费奖励
|
|
send29204(_partner_star,_cb){
|
|
this.SendProtocal(29204,{
|
|
partner_star:_partner_star
|
|
},_cb)
|
|
},
|
|
|
|
handle29204: function( _data ) {
|
|
|
|
nx.bridge.acts.reqActsRewards();
|
|
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;
|
|
},
|
|
|
|
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 = ActUpStar; |