Files
fc/dev/project/library/imports/32/328adb05-0c31-4185-b8c5-9c1e5202ecbc.js
2026-05-24 10:21:26 +08:00

170 lines
4.8 KiB
JavaScript

"use strict";
cc._RF.push(module, '328adsFDDFBhbjFnB5SAuy8', 'act.upstar.mod');
// Scripts/mod/acts/upstar/act.upstar.mod.js
"use strict";
/*******************************************************************************
*
* 活动: 升星有禮活動
*
*
******************************************************************************/
var ActBase = require("act.base");
var ActUpStar = cc.Class({
"extends": ActBase,
// 初始化配置数据
initConfig: function initConfig() {
// 视图附着
nx.plugin.add(this, ["view"]);
this.vattach("Acts");
},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
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 reqBaseFromServer(_cb) {
var _this = this;
var cfgs = ["holiday_upstars_data"];
this.loadConfigs(cfgs, function (_ret, _data) {
_this.reqBaseData(_cb);
});
},
// 请求剧情信息
reqBaseData: function reqBaseData(_cb) {
this.reqUpstarData(_cb);
},
reqUpstarData: function reqUpstarData(_cb) {
this.send29200(_cb);
},
// ============================================================
// 升星操作
// ============================================================
//任務信息
send29200: function send29200(_cb) {
this.SendProtocal(29200, {}, _cb);
},
handle29200: function handle29200(_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: function send29201(_cb) {
this.SendProtocal(29201, {}, _cb);
},
handle29201: function handle29201(_data) {
if (!this.isGoodData(_data)) {
// this.vset( "upstarHeros", {});
return;
}
this.vset("upstarHeros", _data);
},
//選擇英雄
send29202: function send29202(_partner_id, _cb) {
this.SendProtocal(29202, {
partner_id: _partner_id
}, _cb);
},
handle29202: function handle29202(_data) {
if (!this.isGoodData(_data)) {
return;
}
},
//鎖定英雄
send29203: function send29203(_cb) {
this.SendProtocal(29203, {}, _cb);
},
handle29203: function handle29203(_data) {
if (!this.isGoodData(_data)) {
return;
}
},
//领取免费奖励
send29204: function send29204(_partner_star, _cb) {
this.SendProtocal(29204, {
partner_star: _partner_star
}, _cb);
},
handle29204: function handle29204(_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 freshTips(_data) {
var tasks = this.vget("upstarAwards");
var count = 0;
for (var 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: function setChooseHero(bid, star) {
this.tag_partner = {};
this.tag_partner.bid = bid;
this.tag_partner.star = star;
},
getChooseHero: function getChooseHero() {
return this.tag_partner;
},
setIsLock: function setIsLock(status) {
this.is_lock = status;
},
getIsLock: function getIsLock() {
if (this.is_lock != null) {
return this.is_lock;
}
return 0;
},
setLimitTime: function setLimitTime(time) {
this.end_time = time;
},
getLimitTime: function getLimitTime() {
if (this.end_time) {
return this.end_time;
}
return 0;
}
});
// 模块导出
module.exports = ActUpStar;
cc._RF.pop();