Files
fc/dev/project/library/imports/9e/9e7dbcf6-c3ad-4b90-99a2-c6282eb19904.js
2026-05-24 10:21:26 +08:00

126 lines
3.4 KiB
JavaScript

"use strict";
cc._RF.push(module, '9e7dbz2w61LkJmixigusZkE', 'onlinegift_controller');
// Scripts/mod/battle_drama/onlinegift/onlinegift_controller.js
"use strict";
// --------------------------------------------------------------------
// @author: whjing2012@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-01-05 10:37:58
// --------------------------------------------------------------------
var BridgeController = require("bridge.controller");
var OnlineGiftEvent = require("onlinegift_event");
// 桥接替换的界面
var OnlinegiftController = cc.Class({
"extends": BridgeController,
ctor: function ctor() {},
// 初始化配置数据
initConfig: function initConfig() {
var OnlinegiftModel = require("onlinegift_model");
this.model = new OnlinegiftModel();
this.model.initConfig();
this.is_create_lv = false;
this.lv_pos = {};
},
// 返回当前的model
getModel: function getModel() {
return this.model;
},
// 注册监听事件
registerEvents: function registerEvents() {},
// 注册协议接受事件
registerProtocals: function registerProtocals() {
this.RegisterProtocal(10926, this.on10926); // 已领福利
this.RegisterProtocal(10927, this.on10927); // 领取福利
this.RegisterProtocal(10936, this.on10936); // 等级福利
this.RegisterProtocal(10937, this.on10937); // 领取等级福利
},
// 已领福利处理
send10926: function send10926() {
this.SendProtocal(10926, {});
},
on10926: function on10926(data) {
this.model.updateData(data);
gcore.GlobalEvent.fire(OnlineGiftEvent.Get_Data, data);
},
// 领取福利
send10927: function send10927(time) {
this.SendProtocal(10927, {
time: time
});
},
on10927: function on10927(data) {
if (data.code == 1) {
gcore.GlobalEvent.fire(OnlineGiftEvent.Update_Data, data.time);
} else {
nx.tbox(data.msg);
}
},
// 已领福利处理
send10936: function send10936() {
this.SendProtocal(10936, {});
},
on10936: function on10936(data) {
if (data.list) {
this.model.setOnLineLvData(data);
}
gcore.GlobalEvent.fire(OnlineGiftEvent.Get_LevGift_Data, data);
if (!this.is_create_lv) {
this.is_create_lv = true;
// this.createOnLineLvItem(true);
}
},
// 领取福利
send10937: function send10937(lev) {
this.SendProtocal(10937, {
level: lev
});
},
on10937: function on10937(data) {
nx.tbox(data.msg);
if (data.code == 1) {
gcore.GlobalEvent.fire(OnlineGiftEvent.Update_LevGift_Data, data.level);
}
},
// 打开窗口
openOnlineGiftView: function openOnlineGiftView(bool) {
if (bool) {
nx.bridge.createPanel("WndBattleOnlineGift", {});
} else {
nx.bridge.closePanel("WndBattleOnlineGift");
}
},
openOnlineLvView: function openOnlineLvView(bool) {},
setOnLineLvConfig: function setOnLineLvConfig(x, y, parent) {
if (x) {
this.lv_pos.x = x;
}
if (y) {
this.lv_pos.y = y;
}
if (parent) {
this.lv_parent = parent;
}
},
deleteItem: function deleteItem() {
if (this.onlinelvitem) {
this.onlinelvitem.hide();
this.onlinelvitem.deleteMe();
}
},
getOnLineLvItem: function getOnLineLvItem() {
if (this.onlinelvitem) {
return this.onlinelvitem;
}
return null;
}
});
module.exports = OnlinegiftController;
cc._RF.pop();