/****************************************************************** * * 支付页 * ******************************************************************/ const MenuPage = require( "cmp.com.menu.page" ); const RoleController = require( "role_controller" ); const Payment = require( "payment.mod" ); const SVCList = require( "nx.fx.sv.expand" ); cc.Class( { extends: MenuPage, properties: { nodVipLev: { default: null, type: cc.Node }, lstGoods: { default: null, type: SVCList }, }, // 载入 onLoad: function() { // 模板隐藏 // nx.gui.hideAllChildren( this.lstGoods, "" ); }, onEnable: function(){ // 视图监听 this.vbind( [ [ "RechargeList", this.onRechargeListFresh.bind( this ) ] ] ); // 角色属性监听 // this.role = RoleController.getInstance().getRoleVo(); // this.handler = this.role.bind( EventId.UPDATE_ROLE_ATTRIBUTE, ( _key, _val ) => { // this.onVipChange( _key, _val ); // } ); // this.onVipChange(); }, // 关闭 onDisable: function() { // 视图监听解除 this.vunbind(); // // 角色属性监听解除 // if( this.role && this.handler ) { // this.role.unbind( this.handler ); // this.handler = null; // this.role = null; // } }, onVipChange: function( _key, _val ){ let vip = RoleController.getInstance().getRoleVo().vip_lev; nx.gui.setString( this.nodVipLev, "panel/level/txt", vip ); let total = vip+1 < 13 ? game.configs.vip_data.data_get_reward[vip+1].gold :game.configs.vip_data.data_get_reward[vip].gold ; let now = RoleController.getInstance().getRoleVo().vip_exp; nx.gui.setString( this.nodVipLev, "panel/prog", now + "/" + total ); let cmp = nx.gui.getComponent( this.nodVipLev, "panel/bar", cc.ProgressBar ); if( cmp ){ cmp.progress = parseFloat( now / total ); } nx.gui.setStringRich( this.nodVipLev, "panel/tip", nx.text.format( "ChargeTip", ( vip + 1 ) < 13 ? ( total - now ) : 0, ( vip + 1 ) < 13 ? ( vip + 1 ) : vip ) ); }, // 更新充值项 updateGoods: function() { // // 空 // if( nx.dt.arrEmpty( this.goods ) ) { // nx.gui.hideAllChildren( this.lstGoods, "" ); // return; // } let chd = nx.gui.find( this.lstGoods.bindSCV, "view/content" ).children; if( nx.dt.arrEmpty( chd ) ){ this.lstGoods.rebuild( this.goods ); }else{ for (let i = 0; i < this.goods.length; i++) { let info = this.goods[i]; let nod = chd[i]; let cmp = nod.svItem; if( cmp ){ if( cmp.mdata != info ){ cmp.rebind( i, info ); } } } } }, // 充值項改变 onRechargeListFresh: function( _list ) { this.goods = _list || []; this.goods.sort( Utils.tableLowerSorter( [ "need_rmb" ] ) ) this.updateGoods(); }, // 点击充值项 onTouchItem: function( _item ) { if( nx.dt.objEmpty( _item.mdata ) ) { return; } // GM临时发送 // let msg = "pay " + _item.good.id; // VIP.getInstance().SendProtocal( 10399, { // msg:msg // } ); Payment.getInstance().reqPayment( _item.mdata.id ); }, } );