110 lines
2.9 KiB
JavaScript
110 lines
2.9 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 主场景
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeController = require( "bridge.controller" );
|
|
const Payment = require( "payment.mod" );
|
|
|
|
const MainUiController = cc.Class( {
|
|
|
|
extends: BridgeController,
|
|
|
|
// 注册协议接受事件
|
|
registerProtocals: function() {
|
|
|
|
this.RegisterProtocal( 12742, this.on12742 ); // 通用获取物品奖励
|
|
this.RegisterProtocal( 21035, this.on21035 ); // 累计充值总额
|
|
this.RegisterProtocal( 16800, this.onPromptData ); // 屏幕下方提示
|
|
},
|
|
|
|
// 从服务器初始化数据
|
|
reqBaseFromServer: function( _cb ) {
|
|
|
|
// 数据清理
|
|
nx.bridge.vset( "Prompts", [] );
|
|
nx.bridge.vset( "PromptsShow", [] );
|
|
|
|
// 配置加载
|
|
let cfgs = [
|
|
"notice_data", // 提示配置
|
|
];
|
|
this.loadConfigs( cfgs, ( _ret, _data ) => {
|
|
nx.dt.fnInvoke( _cb, true );
|
|
} );
|
|
},
|
|
|
|
on21035( data ) {
|
|
// let price = Payment.getInstance().fmtPrice(data.chager_total);
|
|
nx.bridge.vset("TotalCharge", data.chager_total);
|
|
},
|
|
|
|
// 通用获取物品奖励
|
|
on12742: function( data ) {
|
|
if( data.asset_list.length == 0 ) return;
|
|
this.openGetItemView( true, data.asset_list, data.source );
|
|
},
|
|
|
|
// 屏幕下方提示
|
|
onPromptData: function( _data ) {
|
|
|
|
let data = game.configs.notice_data;
|
|
let cfg = data ? data.data_get[_data.type] : null;
|
|
if( nx.dt.objEmpty( cfg ) ) {
|
|
nx.error( "$Prompt:无效提示类型! ", _data.type );
|
|
return;
|
|
}
|
|
|
|
// 重复类型忽略
|
|
let arr = nx.bridge.vget( "Prompts" );
|
|
if( nx.dt.arrMember( arr, null, ( m ) => {
|
|
return m.type == _data.type;
|
|
})) {
|
|
return;
|
|
}
|
|
|
|
// 重复忽略
|
|
let shows = nx.bridge.vget( "PromptsShow" );
|
|
if( nx.dt.arrMember( shows, null, ( 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( 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;
|