Files

120 lines
3.4 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 个人推送页
*
******************************************************************/
const PPPage = require( "cmp.personal.push.page" );
const ItemLayout = require( "cmp.common.itemlayout" );
const Payment = require( "payment.mod" );
const NxSpine = require( "nx.fx.spine" );
cc.Class( {
extends: PPPage,
properties: {
spBG: { default: null, type: cc.Node },
spRole: { default: null, type: NxSpine },
spHoverd: { default: null, type: cc.Node },
nodTip: { default: null, type: cc.Node },
nodDesc: { default: null, type: cc.Node },
nodDate: { default: null, type: cc.Node },
nodPrice: { default: null, type: cc.Node },
lstReward: { default: null, type: cc.Node },
lstSL: { default: null, type: ItemLayout },
lstML: { default: null, type: ItemLayout },
},
// 重构
rebuild: function( _gift ) {
this.gift = _gift;
if( !this.gift ) {
return;
}
let path = cc.path.join( "resDB/acts/images", this.gift.bg );
nx.gui.setSpriteFrame( this.spBG, "", path );
// 角色动画
path = PathTool.getSpinePath( this.gift.model, "show", false );
this.spRole.load( path, ( _e ) => {
if( !_e ) {
this.spRole.action( this.gift.action, true );
} else {
this.spRole.stop();
}
} );
path = cc.path.join( "locals", nx.getLocLanguage(), "images/push", this.gift.hover );
nx.gui.setSpriteFrame( this.spHoverd, "", path );
if( nx.dt.strEmpty( this.gift.desc1 ) ) {
nx.gui.setActive( this.nodTip, "", false );
} else {
nx.gui.setActive( this.nodTip, "", true );
nx.gui.setString( this.nodTip, "txt", nx.text.getKey( this.gift.desc1 ) );
}
nx.gui.setString( this.nodDesc, "txt", nx.text.getKey( this.gift.desc2 ) );
// 价格
let price = Payment.getInstance().fmtPrice( this.gift.price );
nx.gui.setString( this.nodPrice, "", price );
// 奖励
let rewards = [];
this.gift.award.forEach( _t => {
rewards.push( [_t.id, _t.num] );
} );
if( rewards.length <= 3 ) {
nx.gui.setActive( this.lstReward, "mt", false );
nx.gui.setActive( this.lstReward, "st", true );
this.lstSL.rebuild( rewards );
} else {
nx.gui.setActive( this.lstReward, "mt", true );
nx.gui.setActive( this.lstReward, "st", false );
this.lstML.rebuild( rewards );
}
// 倒計時
this.updateDate();
this.schedule( () => {
this.updateDate();
}, 1, cc.macro.repeatForever );
},
// 关闭
onDisable: function() {
this.unscheduleAllCallbacks();
},
// 倒计时
updateDate: function() {
let txt = nx.bridge.time.cdSimple( this.gift ? this.gift.over_time : 0 );
txt = nx.text.getKey( txt || "已结束" );
nx.gui.setString( this.nodDate, "txt", txt );
},
// 购买
onTouchBuy: function() {
if( !this.gift ) {
return;
}
// let msg = `pay ${this.gift.charge_id}`;
Payment.getInstance().reqPayment( this.gift.charge_id );
// client.socket.send( 10399, { msg: msg } );
nx.bridge.closePanel( "WndPersonalPush" );
},
} );