146 lines
3.9 KiB
JavaScript
146 lines
3.9 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 月卡
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const BasePage = require( "act.page.base" );
|
||
|
|
const Payment = require( "payment.mod" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: BasePage,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
card1: { default: null, type: cc.Node },
|
||
|
|
card2: { default: null, type: cc.Node },
|
||
|
|
},
|
||
|
|
|
||
|
|
// 初始化
|
||
|
|
build: function( _data ) {
|
||
|
|
|
||
|
|
this._super( _data );
|
||
|
|
|
||
|
|
// 无效
|
||
|
|
if( !this.mod ) {
|
||
|
|
this.card1.active = false;
|
||
|
|
this.card2.active = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 活动监听
|
||
|
|
this.mod.vbind( this, [
|
||
|
|
[ "monthCard1", this.freshCard1.bind( this ) ],
|
||
|
|
[ "monthCard2", this.freshCard2.bind( this ) ],
|
||
|
|
] );
|
||
|
|
|
||
|
|
// 请求月卡信息
|
||
|
|
this.mod.reqMonthData();
|
||
|
|
},
|
||
|
|
|
||
|
|
// 销毁
|
||
|
|
onDestroy: function() {
|
||
|
|
|
||
|
|
// 活动监听解除
|
||
|
|
if( this.mod ) {
|
||
|
|
this.mod.vunbind( this );
|
||
|
|
}
|
||
|
|
|
||
|
|
this._super();
|
||
|
|
},
|
||
|
|
|
||
|
|
// 卡更新
|
||
|
|
freshCard1: function( _info ) {
|
||
|
|
this.freshCard( 1, _info );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 卡更新
|
||
|
|
freshCard2: function( _info ) {
|
||
|
|
this.freshCard( 2, _info );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 卡更新
|
||
|
|
freshCard: function( _type, _info ) {
|
||
|
|
|
||
|
|
let card = ( _type == 1 ) ? this.card1 : this.card2;
|
||
|
|
if( !card || nx.dt.objEmpty( _info ) ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 配置缺失
|
||
|
|
const data = game.configs.charge_data.data_constant;
|
||
|
|
if( !data ) {
|
||
|
|
nx.error( "月卡配置缺失!" );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 未激活
|
||
|
|
if( _info.is_reward == 0 ) {
|
||
|
|
nx.gui.setActive( card, "reward", false );
|
||
|
|
nx.gui.setActive( card, "active", false );
|
||
|
|
let node = nx.gui.setActive( card, "goto", true );
|
||
|
|
let key = ( _type == 1 ) ? "month_card1_sun" : "month_card2_sun";
|
||
|
|
let val = data[key].val;
|
||
|
|
nx.gui.setString( node, "tip/arr/total", Payment.getInstance().fmtPrice( val ) );
|
||
|
|
nx.gui.setString( node, "acc/total", Payment.getInstance().transPrice( val ) );
|
||
|
|
nx.gui.setString( node, "acc/cur", Payment.getInstance().transPrice( _info.acc ) );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 待激活
|
||
|
|
if( _info.is_reward == 3 ) {
|
||
|
|
nx.gui.setActive( card, "reward", false );
|
||
|
|
nx.gui.setActive( card, "goto", false );
|
||
|
|
nx.gui.setActive( card, "active", true );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setActive( card, "goto", false );
|
||
|
|
nx.gui.setActive( card, "active", false );
|
||
|
|
let node = nx.gui.setActive( card, "reward", true );
|
||
|
|
|
||
|
|
// 生效时间段
|
||
|
|
let start = nx.bridge.time.toLocalMD( _info.start_time );
|
||
|
|
let end = nx.bridge.time.toLocalMD( _info.end_time );
|
||
|
|
nx.gui.setString( node, "tip/arr/date", start + " - " + end );
|
||
|
|
|
||
|
|
// 领取天数
|
||
|
|
nx.gui.setString( node, "acc/cur", _info.days );
|
||
|
|
|
||
|
|
let have = ( _info.is_reward == 1 );
|
||
|
|
nx.gui.setActive( node, "get", have );
|
||
|
|
nx.gui.setActive( node, "got", !have );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击激活
|
||
|
|
onTouchActive: function( _type ) {
|
||
|
|
console.log( "Active:" + parseInt( _type ) );
|
||
|
|
nx.bridge.createPanel( "WndPayment", { key: "recharge" } );
|
||
|
|
this.scheduleOnce( () => {
|
||
|
|
nx.bridge.closePanel( "WndActs" );
|
||
|
|
}, 0.5 );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 激活祝福
|
||
|
|
onTouchActiveReward: function( _type ) {
|
||
|
|
|
||
|
|
let type = parseInt( _type );
|
||
|
|
this.mod.reqActiveCard( type, ( _ret, _data ) => {
|
||
|
|
} );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击领取
|
||
|
|
onTouchGet: function( _type ) {
|
||
|
|
|
||
|
|
let type = parseInt( _type );
|
||
|
|
this.mod.reqMonthReward( type, ( _ret, _data ) => {
|
||
|
|
} );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击特权
|
||
|
|
onTouchVipRight: function() {
|
||
|
|
nx.bridge.createPanel( "WndPayment", { key: "vip" } );
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|