123 lines
3.2 KiB
JavaScript
123 lines
3.2 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '21e82HhnlJLHbWfCf/yU+cu', 'act.stepup.sign.mod');
|
|
// Scripts/mod/acts/stepup/act.stepup.sign.mod.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 活动: StepUP签到
|
|
*
|
|
******************************************************************/
|
|
|
|
var ActBase = require("act.base");
|
|
var SummonDefine = require("summon.define");
|
|
|
|
// 桥接替换的界面
|
|
|
|
var STStage = SummonDefine.StepUpStage;
|
|
var ActStepupSign = cc.Class({
|
|
"extends": ActBase,
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
// 视图附着
|
|
nx.plugin.add(this, ["view"]);
|
|
this.vattach("Acts");
|
|
},
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(23245, this.handle23245.bind(this));
|
|
this.RegisterProtocal(23246, this.handle23246.bind(this));
|
|
},
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
var cfgs = ["holiday_checkin_data"];
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
nx.dt.fnInvoke(_cb, true);
|
|
_this.reqSignData();
|
|
});
|
|
},
|
|
// 当前配置
|
|
getConfig: function getConfig() {
|
|
// 已经存在
|
|
if (nx.dt.objNEmpty(this.configs)) {
|
|
return this.configs;
|
|
}
|
|
|
|
// 活动无效
|
|
if (nx.dt.objEmpty(this.data) || !nx.dt.numPositive(this.data.camp_id, false)) {
|
|
this.configs = null;
|
|
nx.error("STEP-UP签到当前配置无效!");
|
|
return null;
|
|
}
|
|
|
|
// 配置无效
|
|
var DATA = game.configs.holiday_checkin_data;
|
|
var campId = this.data.camp_id;
|
|
if (nx.dt.objEmpty(DATA.data_sign_in[campId])) {
|
|
this.configs = null;
|
|
nx.error("STEP-UP签到当前配置无效:", campId);
|
|
return null;
|
|
}
|
|
this.configs = DATA.data_sign_in[campId];
|
|
return this.configs;
|
|
},
|
|
// 签到数据请求
|
|
reqSignData: function reqSignData(_cb) {
|
|
this.SendProtocal(23245, {}, _cb);
|
|
},
|
|
// 签到数据更新
|
|
handle23245: function handle23245(_data) {
|
|
if (!this.isGoodData(_data)) {
|
|
return;
|
|
}
|
|
this.vset("stepSign7", _data.gift_buy_info || []);
|
|
this.freshTips();
|
|
},
|
|
// 签到领取请求
|
|
reqSignGet: function reqSignGet(_day, _cb) {
|
|
this.SendProtocal(23246, {
|
|
day: _day
|
|
}, _cb);
|
|
},
|
|
// 签到领取更新
|
|
handle23246: function handle23246(_data) {
|
|
if (!this.isGoodData(_data, false)) {
|
|
return;
|
|
}
|
|
var list = this.vget("stepSign7") || [];
|
|
for (var i in list) {
|
|
if (list[i].day == _data.day) {
|
|
list[i].status = _data.status;
|
|
break;
|
|
}
|
|
}
|
|
this.vset("stepSign7", list);
|
|
this.freshTips();
|
|
},
|
|
// ============================================================
|
|
// 活动红点提示
|
|
// ============================================================
|
|
|
|
// 活动用到的提示KEY
|
|
tipKeys: function tipKeys() {
|
|
return ["reward"];
|
|
},
|
|
// 红点提示更新
|
|
// 0不可领取 1可领取 2已领取
|
|
freshTips: function freshTips() {
|
|
var have = false;
|
|
var list = this.vget("stepSign7") || [];
|
|
for (var i in list) {
|
|
if (list[i].status == 1) {
|
|
have = true;
|
|
break;
|
|
}
|
|
}
|
|
this.openTip("reward", have);
|
|
}
|
|
});
|
|
module.exports = ActStepupSign;
|
|
|
|
cc._RF.pop(); |