Files
fc/dev/project/library/imports/1e/1ed8a2ed-5343-4928-903e-5f52d726a45e.js
T
2026-05-24 10:21:26 +08:00

75 lines
2.2 KiB
JavaScript

"use strict";
cc._RF.push(module, '1ed8aLtU0NJKJA+X1LXJqRe', 'exchange_controller');
// Scripts/mod/exchange/exchange_controller.js
"use strict";
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2018-12-25 16:37:10
// --------------------------------------------------------------------
var BridgeController = require("bridge.controller");
var ExchangeEvent = require("exchange_event");
var ExchangeController = cc.Class({
"extends": BridgeController,
ctor: function ctor() {},
// 初始化配置数据
initConfig: function initConfig() {
var ExchangeModel = require("exchange_model");
this.model = new ExchangeModel();
this.model.initConfig();
},
// 返回当前的model
getModel: function getModel() {
return this.model;
},
// 注册监听事件
registerEvents: function registerEvents() {},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
this.RegisterProtocal(23606, this.on23606);
this.RegisterProtocal(23607, this.on23607);
},
reqBaseFromServer: function reqBaseFromServer(_cb) {
var _this = this;
var cfgs = ["exchange_data"];
this.loadConfigs(cfgs, function (_ret, _data) {
_this.SendProtocal(23606, {}, _cb);
});
},
send23606: function send23606() {
this.SendProtocal(23606, {});
},
on23606: function on23606(data) {
for (var i = 0; i < data.list.length; i++) {
var item = data.list[i];
if (item.id == 1) {
nx.mTip.openTip("coin.free", item.max - item.num > 0);
}
}
this.model.setExchangeData(data);
gcore.GlobalEvent.fire(ExchangeEvent.Extra_Reward, data);
},
send23607: function send23607(id) {
this.SendProtocal(23607, {
id: id
});
},
on23607: function on23607(data) {
if (data.msg != "") {
nx.tbox(data.msg);
}
},
openExchangeMainView: function openExchangeMainView(status) {
if (status) {
nx.bridge.createPanel("WndPopBuyCoin");
} else {
nx.bridge.closePanel("WndPopBuyCoin");
}
}
});
module.exports = ExchangeController;
cc._RF.pop();