325 lines
8.7 KiB
JavaScript
325 lines
8.7 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '7a0160nh+lHnbipmdQlSVyn', 'act.star.mod');
|
||
|
|
// Scripts/mod/acts/startravel/act.star.mod.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/*******************************************************************************
|
||
|
|
*
|
||
|
|
* 活动: 月卡
|
||
|
|
*
|
||
|
|
*
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
var ActBase = require("act.base");
|
||
|
|
var ActStartravel = cc.Class({
|
||
|
|
"extends": ActBase,
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function initConfig() {
|
||
|
|
// 视图附着
|
||
|
|
nx.plugin.add(this, ["view"]);
|
||
|
|
this.vattach("Acts");
|
||
|
|
},
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function registerProtocals() {
|
||
|
|
this.RegisterProtocal(28700, this.handle28700.bind(this)); //戰靈任務信息
|
||
|
|
this.RegisterProtocal(28701, this.handle28701.bind(this)); //任務信息更新
|
||
|
|
this.RegisterProtocal(28702, this.handle28702.bind(this)); //提交任務
|
||
|
|
this.RegisterProtocal(28703, this.handle28703.bind(this)); //等级奖励展示
|
||
|
|
this.RegisterProtocal(28704, this.handle28704.bind(this)); //领取等级礼包(成功推送28703)
|
||
|
|
this.RegisterProtocal(28705, this.handle28705.bind(this)); //等级变更(只会主动推)
|
||
|
|
this.RegisterProtocal(28706, this.handle28706.bind(this)); //进阶卡情况
|
||
|
|
// this.RegisterProtocal(28707, this.handle28707.bind(this) )//是否要弹窗
|
||
|
|
this.RegisterProtocal(28708, this.handle28708.bind(this)); //周期重置红点
|
||
|
|
},
|
||
|
|
|
||
|
|
// 从服务器初始化数据
|
||
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
||
|
|
var _this = this;
|
||
|
|
// nx.dt.fnInvoke( _cb, true );
|
||
|
|
var cfgs = [this.data.config];
|
||
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
||
|
|
_this.reqBaseData(_cb);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
// 请求剧情信息
|
||
|
|
reqBaseData: function reqBaseData(_cb) {
|
||
|
|
this.reqOrderData(_cb);
|
||
|
|
},
|
||
|
|
reqOrderData: function reqOrderData(_cb) {
|
||
|
|
this.send28700(_cb);
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 首充操作
|
||
|
|
// ============================================================
|
||
|
|
//任務信息
|
||
|
|
send28700: function send28700(_cb) {
|
||
|
|
this.SendProtocal(28700, {}, _cb);
|
||
|
|
},
|
||
|
|
// 请求戰靈任務信息返回
|
||
|
|
handle28700: function handle28700(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
this.vset("orderTasks", []);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.setCurPeriod(_data.period); //週期數
|
||
|
|
this.setCurDay(_data.cur_day); //天數
|
||
|
|
this.setRMBStatus(_data.rmb_status); //是否激活特權
|
||
|
|
this.setCurLev(_data.lev); //當前等級
|
||
|
|
this.setCurExp(_data.exp); //當前經驗
|
||
|
|
this.setPeriodLev(_data.period_lev); //週期開始等級
|
||
|
|
this.setDayLev(_data.day_lev); //天開始等級
|
||
|
|
this.setWeekLev(_data.week_lev); //周開始等級
|
||
|
|
this.vset("orderTasks", _data.list); //任務列表
|
||
|
|
this.vset("orderLastTime", _data.end_time);
|
||
|
|
|
||
|
|
// 提示刷新
|
||
|
|
this.freshTips();
|
||
|
|
this.freshAwardTips();
|
||
|
|
},
|
||
|
|
//任務更新
|
||
|
|
handle28701: function handle28701(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var tasks = this.vget("orderTasks");
|
||
|
|
for (var i in tasks) {
|
||
|
|
var task = tasks[i];
|
||
|
|
for (var j in _data.list) {
|
||
|
|
if (_data.list[j].id == task.id) {
|
||
|
|
tasks[i] = _data.list[j];
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.vset("orderTasks", tasks);
|
||
|
|
},
|
||
|
|
// 提交任務
|
||
|
|
reqTask: function reqTask(_id, _cb) {
|
||
|
|
this.SendProtocal(28702, {
|
||
|
|
id: _id
|
||
|
|
}, _cb);
|
||
|
|
},
|
||
|
|
// 提交任務返回
|
||
|
|
handle28702: function handle28702(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 提示刷新
|
||
|
|
this.freshTips();
|
||
|
|
this.freshAwardTips();
|
||
|
|
},
|
||
|
|
//等級獎勵
|
||
|
|
send28703: function send28703(_cb) {
|
||
|
|
this.SendProtocal(28703, {}, _cb);
|
||
|
|
},
|
||
|
|
handle28703: function handle28703(data) {
|
||
|
|
if (!this.isGoodData(data)) {
|
||
|
|
this.vset("orderRewards", []);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.setCurLev(data.lev); //當前等級
|
||
|
|
this.vset("orderRewards", data.reward_list);
|
||
|
|
|
||
|
|
// 提示刷新
|
||
|
|
this.freshAwardTips();
|
||
|
|
},
|
||
|
|
// 領取等級禮包
|
||
|
|
reqGift: function reqGift(_id, _cb) {
|
||
|
|
this.SendProtocal(28704, {
|
||
|
|
id: _id
|
||
|
|
}, _cb);
|
||
|
|
},
|
||
|
|
handle28704: function handle28704(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 等級變更(只會主動推)
|
||
|
|
handle28705: function handle28705(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.setCurExp(_data.exp);
|
||
|
|
this.setCurLev(_data.lev);
|
||
|
|
this.send28700();
|
||
|
|
},
|
||
|
|
//進階卡情況
|
||
|
|
send28706: function send28706() {
|
||
|
|
this.SendProtocal(28706, {});
|
||
|
|
},
|
||
|
|
handle28706: function handle28706(_data) {
|
||
|
|
if (!this.isGoodData(_data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.setRMBStatus(_data.rmb_status);
|
||
|
|
if (_data.list.length > 0) {
|
||
|
|
this.setOrderCardId(_data.list[0].id);
|
||
|
|
var reward_list = this.vget("orderRewards");
|
||
|
|
this.vset("orderRewards", reward_list);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//週期重置紅點
|
||
|
|
send28708: function send28708() {
|
||
|
|
this.SendProtocal(28708);
|
||
|
|
},
|
||
|
|
handle28708: function handle28708(data) {
|
||
|
|
if (!this.isGoodData(data)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (data && data.flag && data.flag == 1) {
|
||
|
|
this.setPeriodRed(true);
|
||
|
|
}
|
||
|
|
this.setPeriodRed(false);
|
||
|
|
},
|
||
|
|
// ============================================================
|
||
|
|
// 活动红点提示
|
||
|
|
// ============================================================
|
||
|
|
|
||
|
|
// 活动用到的提示KEY
|
||
|
|
tipKeys: function tipKeys() {
|
||
|
|
return ["orderTask", "reward"];
|
||
|
|
},
|
||
|
|
// 红点提示更新
|
||
|
|
freshTips: function freshTips() {
|
||
|
|
var tasks = this.vget("orderTasks");
|
||
|
|
var is_reward = false;
|
||
|
|
for (var i in tasks) {
|
||
|
|
if (tasks[i].finish == 1) {
|
||
|
|
is_reward = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.openTip("orderTask", is_reward);
|
||
|
|
},
|
||
|
|
freshAwardTips: function freshAwardTips() {
|
||
|
|
var awards = this.vget("orderRewards");
|
||
|
|
var is_reward = false;
|
||
|
|
var exp_data = game.configs.holiday_new_war_order_data.data_lev_reward_list[this.getCurPeriod()];
|
||
|
|
for (var idx in exp_data) {
|
||
|
|
if (this.getCurExp() >= exp_data[idx].exp) {
|
||
|
|
is_reward = true;
|
||
|
|
for (var i in awards) {
|
||
|
|
if (exp_data[idx].lev == awards[i].id) {
|
||
|
|
if (awards[i].status == 1 && this.getRMBStatus() == 0) {
|
||
|
|
//基础奖励
|
||
|
|
is_reward = false;
|
||
|
|
break;
|
||
|
|
} else if (awards[i].status == 1 && awards[i].rmb_status == 1 && this.getRMBStatus() == 1) {
|
||
|
|
//氪金奖励
|
||
|
|
is_reward = false;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.openTip("reward", is_reward);
|
||
|
|
},
|
||
|
|
//當前經驗
|
||
|
|
setCurExp: function setCurExp(exp) {
|
||
|
|
this.cur_exp = exp;
|
||
|
|
},
|
||
|
|
getCurExp: function getCurExp() {
|
||
|
|
if (this.cur_exp) {
|
||
|
|
return this.cur_exp;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
//當前週期
|
||
|
|
setCurPeriod: function setCurPeriod(period) {
|
||
|
|
this.cur_period = period;
|
||
|
|
},
|
||
|
|
//獲取當前週期
|
||
|
|
getCurPeriod: function getCurPeriod() {
|
||
|
|
if (this.cur_period) {
|
||
|
|
return this.cur_period;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
//當前天數
|
||
|
|
setCurDay: function setCurDay(day) {
|
||
|
|
this.cur_day = day;
|
||
|
|
},
|
||
|
|
getCurDay: function getCurDay() {
|
||
|
|
if (this.cur_day) {
|
||
|
|
return this.cur_day;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
//當前等級
|
||
|
|
setCurLev: function setCurLev(lev) {
|
||
|
|
this.cur_lev = lev;
|
||
|
|
},
|
||
|
|
getCurLev: function getCurLev() {
|
||
|
|
if (this.cur_lev) {
|
||
|
|
return this.cur_lev;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
//是否激活特權
|
||
|
|
setRMBStatus: function setRMBStatus(status) {
|
||
|
|
this.rmb_status = status;
|
||
|
|
},
|
||
|
|
getRMBStatus: function getRMBStatus() {
|
||
|
|
if (this.rmb_status) {
|
||
|
|
return this.rmb_status;
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
},
|
||
|
|
// 週期開始等級
|
||
|
|
setPeriodLev: function setPeriodLev(period_lev) {
|
||
|
|
this.period_lev = period_lev;
|
||
|
|
},
|
||
|
|
getPeriodLev: function getPeriodLev() {
|
||
|
|
if (this.period_lev) {
|
||
|
|
return this.period_lev;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
// 天開始等級
|
||
|
|
setDayLev: function setDayLev(day_lev) {
|
||
|
|
this.day_lev = day_lev;
|
||
|
|
},
|
||
|
|
getDayLev: function getDayLev() {
|
||
|
|
if (this.day_lev) {
|
||
|
|
return this.day_lev;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
// 周開始等級
|
||
|
|
setWeekLev: function setWeekLev(week_lev) {
|
||
|
|
this.week_lev = week_lev;
|
||
|
|
},
|
||
|
|
getWeekLev: function getWeekLev() {
|
||
|
|
if (this.week_lev) {
|
||
|
|
return this.week_lev;
|
||
|
|
}
|
||
|
|
return 1;
|
||
|
|
},
|
||
|
|
//設置週期重置紅點
|
||
|
|
setPeriodRed: function setPeriodRed(bool) {
|
||
|
|
this.period_red = bool;
|
||
|
|
},
|
||
|
|
getPeriodRed: function getPeriodRed() {
|
||
|
|
if (this.period_red) {
|
||
|
|
return this.period_red;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
},
|
||
|
|
setOrderCardId: function setOrderCardId(card_id) {
|
||
|
|
this.card_id = card_id;
|
||
|
|
},
|
||
|
|
getOrderCardId: function getOrderCardId() {
|
||
|
|
if (this.card_id) {
|
||
|
|
return this.card_id;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// 模块导出
|
||
|
|
module.exports = ActStartravel;
|
||
|
|
|
||
|
|
cc._RF.pop();
|