109 lines
2.8 KiB
JavaScript
109 lines
2.8 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '6afd5n6qXxF1Kju/00ho7Tl', 'act.exchange.mod');
|
||
|
|
// Scripts/mod/acts/exchange/act.exchange.mod.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var ActBase = require("act.base");
|
||
|
|
var ActExchange = cc.Class({
|
||
|
|
"extends": ActBase,
|
||
|
|
// 初始化配置数据
|
||
|
|
initConfig: function initConfig() {
|
||
|
|
// 视图附着
|
||
|
|
nx.plugin.add(this, ["view"]);
|
||
|
|
this.vattach("Acts");
|
||
|
|
},
|
||
|
|
// 注册协议接受事件
|
||
|
|
registerProtocals: function registerProtocals() {
|
||
|
|
// // // 前端准备完毕
|
||
|
|
this.RegisterProtocal(14120, this.dealBaseInfoBack.bind(this));
|
||
|
|
this.RegisterProtocal(14121, this.dealExchangeDatas.bind(this));
|
||
|
|
this.RegisterProtocal(14122, this.getFreeBack.bind(this));
|
||
|
|
},
|
||
|
|
// 从服务器初始化数据
|
||
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
||
|
|
var _this = this;
|
||
|
|
var cfgs = [this.data.config //付費活動
|
||
|
|
];
|
||
|
|
|
||
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
||
|
|
nx.dt.fnInvoke(_cb, true);
|
||
|
|
_this.reqBaseInfo(_this.data.camp_id);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
reqBaseInfo: function reqBaseInfo(_id) {
|
||
|
|
var protocal = {
|
||
|
|
camp_id: _id
|
||
|
|
};
|
||
|
|
this.SendProtocal(14120, protocal);
|
||
|
|
},
|
||
|
|
// 請求基礎信息返回
|
||
|
|
dealBaseInfoBack: function dealBaseInfoBack(_data) {
|
||
|
|
this.vset("exchangeInfo", _data);
|
||
|
|
this.openTip("reward", _data.is_free == 0);
|
||
|
|
},
|
||
|
|
// 請求兌換
|
||
|
|
reqExchange: function reqExchange(_id) {
|
||
|
|
var info = {
|
||
|
|
camp_id: this.data.camp_id,
|
||
|
|
id: _id
|
||
|
|
};
|
||
|
|
this.SendProtocal(14121, info);
|
||
|
|
},
|
||
|
|
// 請求領取免費
|
||
|
|
reqGetFree: function reqGetFree() {
|
||
|
|
var info = {
|
||
|
|
camp_id: this.data.camp_id
|
||
|
|
};
|
||
|
|
this.SendProtocal(14122, info);
|
||
|
|
},
|
||
|
|
getFreeBack: function getFreeBack(_data) {},
|
||
|
|
// 處理相關的配置
|
||
|
|
dealExchangeDatas: function dealExchangeDatas(_data) {
|
||
|
|
if (_data.code == 0) {
|
||
|
|
nx.tbox(_data.msg);
|
||
|
|
}
|
||
|
|
// let cfg = game.configs.exchange_data.data_shop_exchange_gold;
|
||
|
|
},
|
||
|
|
|
||
|
|
getFreeInfo: function getFreeInfo(_data) {
|
||
|
|
var free = null;
|
||
|
|
var cfg = gdata(this.data.config, "data_shop_exchange_cost");
|
||
|
|
if (cfg) {
|
||
|
|
free = cfg.daily_gift.val;
|
||
|
|
}
|
||
|
|
return free;
|
||
|
|
},
|
||
|
|
getExchangeInfo: function getExchangeInfo() {
|
||
|
|
var cfg = gdata(this.data.config, "data_shop_exchange_gold");
|
||
|
|
var list = [];
|
||
|
|
for (var i in cfg) {
|
||
|
|
if (i == this.data.camp_id) {
|
||
|
|
var item = cfg[i];
|
||
|
|
for (var c in item) {
|
||
|
|
var citem = item[c];
|
||
|
|
if (citem.camp_id == this.data.camp_id) {
|
||
|
|
list.push(citem);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return list;
|
||
|
|
},
|
||
|
|
getExtraInfo: function getExtraInfo() {
|
||
|
|
var cfg = gdata(this.data.config, "data_shop_exchange_show");
|
||
|
|
var info = {};
|
||
|
|
for (var i in cfg) {
|
||
|
|
var item = cfg[i];
|
||
|
|
if (item.camp_id == this.data.camp_id) {
|
||
|
|
info = item;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return info;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// 模块导出
|
||
|
|
module.exports = ActExchange;
|
||
|
|
|
||
|
|
cc._RF.pop();
|