Files
fc/dev/project/assets/Scripts/mod/exchange/exchange_controller.js
T
2026-05-23 22:10:14 +08:00

91 lines
2.2 KiB
JavaScript

// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2018-12-25 16:37:10
// --------------------------------------------------------------------
const BridgeController = require( "bridge.controller" );
var ExchangeEvent = require("exchange_event");
var ExchangeController = cc.Class({
extends: BridgeController,
ctor: function () {
},
// 初始化配置数据
initConfig: function () {
var ExchangeModel = require("exchange_model");
this.model = new ExchangeModel();
this.model.initConfig();
},
// 返回当前的model
getModel: function () {
return this.model;
},
// 注册监听事件
registerEvents: function () {
},
// 注册协议接受事件
registerProtocals: function () {
this.RegisterProtocal(23606, this.on23606);
this.RegisterProtocal(23607, this.on23607);
},
reqBaseFromServer: function( _cb ){
let cfgs = [
"exchange_data",
];
this.loadConfigs( cfgs, ( _ret, _data ) =>{
this.SendProtocal(23606, {}, _cb );
} );
},
send23606 : function(){
this.SendProtocal(23606, {});
},
on23606 : function(data){
for (let i = 0; i < data.list.length; i++) {
let 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(id){
this.SendProtocal(23607, {id : id});
},
on23607 : function(data){
if( data.msg != "" ){
nx.tbox(data.msg);
}
},
openExchangeMainView : function(status){
if(status){
nx.bridge.createPanel( "WndPopBuyCoin" );
}else{
nx.bridge.closePanel( "WndPopBuyCoin" );
}
}
});
module.exports = ExchangeController;