102 lines
2.7 KiB
JavaScript
102 lines
2.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '37f9boahqlPopfky8EPYSid', 'mainui_controller');
|
|
// Scripts/mod/mainui/mainui_controller.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 主场景
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeController = require("bridge.controller");
|
|
var Payment = require("payment.mod");
|
|
var MainUiController = cc.Class({
|
|
"extends": BridgeController,
|
|
// 注册协议接受事件
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(12742, this.on12742); // 通用获取物品奖励
|
|
this.RegisterProtocal(21035, this.on21035); // 累计充值总额
|
|
this.RegisterProtocal(16800, this.onPromptData); // 屏幕下方提示
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
// 数据清理
|
|
nx.bridge.vset("Prompts", []);
|
|
nx.bridge.vset("PromptsShow", []);
|
|
|
|
// 配置加载
|
|
var cfgs = ["notice_data" // 提示配置
|
|
];
|
|
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
nx.dt.fnInvoke(_cb, true);
|
|
});
|
|
},
|
|
on21035: function on21035(data) {
|
|
// let price = Payment.getInstance().fmtPrice(data.chager_total);
|
|
nx.bridge.vset("TotalCharge", data.chager_total);
|
|
},
|
|
// 通用获取物品奖励
|
|
on12742: function on12742(data) {
|
|
if (data.asset_list.length == 0) return;
|
|
this.openGetItemView(true, data.asset_list, data.source);
|
|
},
|
|
// 屏幕下方提示
|
|
onPromptData: function onPromptData(_data) {
|
|
var data = game.configs.notice_data;
|
|
var cfg = data ? data.data_get[_data.type] : null;
|
|
if (nx.dt.objEmpty(cfg)) {
|
|
nx.error("$Prompt:无效提示类型! ", _data.type);
|
|
return;
|
|
}
|
|
|
|
// 重复类型忽略
|
|
var arr = nx.bridge.vget("Prompts");
|
|
if (nx.dt.arrMember(arr, null, function (m) {
|
|
return m.type == _data.type;
|
|
})) {
|
|
return;
|
|
}
|
|
|
|
// 重复忽略
|
|
var shows = nx.bridge.vget("PromptsShow");
|
|
if (nx.dt.arrMember(shows, null, function (m) {
|
|
return m.type == _data.type;
|
|
})) {
|
|
return;
|
|
}
|
|
|
|
// 加入
|
|
arr.push({
|
|
id: cfg.id,
|
|
idx: _data.idx,
|
|
type: _data.type,
|
|
icon: cfg.res,
|
|
name: cfg.name,
|
|
cmd: cfg.cmd,
|
|
args: {
|
|
u32: _data.arg_uint32,
|
|
str: _data.arg_str
|
|
}
|
|
});
|
|
nx.bridge.vset("Prompts", arr);
|
|
},
|
|
// 通用打开获取物品界面
|
|
openGetItemView: function openGetItemView(status, list, params) {
|
|
if (!status) {
|
|
nx.bridge.closePanel("PopupRewards");
|
|
return;
|
|
}
|
|
console.log(list, params);
|
|
nx.bridge.createPanel("PopupRewards", {
|
|
list: list,
|
|
params: params
|
|
});
|
|
}
|
|
});
|
|
module.exports = MainUiController;
|
|
|
|
cc._RF.pop(); |