145 lines
3.0 KiB
JavaScript
145 lines
3.0 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 推送入口
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeComponent = require( "bridge.component" );
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeComponent,
|
|
|
|
properties: {
|
|
|
|
box: { default: null, type: cc.Node },
|
|
spRole: { default: null, type: NxSpine },
|
|
words: { default: null, type: cc.Node },
|
|
nodCD: { default: null, type: cc.Node },
|
|
},
|
|
|
|
// 显示
|
|
onEnable: function() {
|
|
|
|
this.box.active = false;
|
|
this.words.active = false;
|
|
|
|
// 视图绑定
|
|
nx.bridge.vbind( this, [
|
|
[ "PPushGifts", this.onFreshGifts.bind( this ) ],
|
|
[ "PPushNews", this.onNewGifts.bind( this ) ],
|
|
] );
|
|
|
|
// 倒计时
|
|
this.cdTick();
|
|
this.schedule( () => {
|
|
this.cdTick();
|
|
}, 1 );
|
|
},
|
|
|
|
// 关闭
|
|
onDisable: function() {
|
|
|
|
// 倒计时
|
|
this.unscheduleAllCallbacks();
|
|
|
|
// 视图监听解除
|
|
nx.bridge.vunbind( this );
|
|
},
|
|
|
|
// 礼包刷新
|
|
onFreshGifts: function( _list ) {
|
|
|
|
this.gifts = _list || [];
|
|
if( nx.dt.arrEmpty( _list ) ) {
|
|
this.box.active = false;
|
|
return;
|
|
}
|
|
|
|
if( this.box.active ) {
|
|
return;
|
|
}
|
|
|
|
// 显示
|
|
this.box.active = true;
|
|
this.spRole.action( "piay2", true );
|
|
|
|
},
|
|
|
|
// 有新礼包
|
|
onNewGifts: function( _ids ) {
|
|
|
|
// 不提示
|
|
let tmp = nx.storage.getNumber( "PPHideTip", 0 );
|
|
if( tmp == 1 ) {
|
|
this.words.active = false;
|
|
}
|
|
|
|
// 新提示
|
|
this.newTip = nx.dt.arrNEmpty( _ids );
|
|
this.tipOpen();
|
|
|
|
|
|
// 直接弹出
|
|
if( this.newTip ) {
|
|
nx.bridge.createPanel( "WndPersonalPush", { ids: _ids } );
|
|
nx.bridge.vset( "PPushNews", [] );
|
|
}
|
|
|
|
},
|
|
|
|
// 提示
|
|
tipOpen: function() {
|
|
|
|
if( !this.box.active || this.words.active ) {
|
|
return;
|
|
}
|
|
|
|
if( !this.newTip ) {
|
|
this.words.active = false;
|
|
return;
|
|
}
|
|
|
|
this.unscheduleAllCallbacks();
|
|
|
|
let self = this;
|
|
this.words.active = true;
|
|
this.scheduleOnce( () => {
|
|
self.words.active = false;
|
|
self.scheduleOnce( () => {
|
|
self.tipOpen();
|
|
}, 10 );
|
|
}, 5 );
|
|
|
|
},
|
|
|
|
// 点击打开
|
|
onTouchOpen: function() {
|
|
|
|
nx.bridge.createPanel( "WndPersonalPush" );
|
|
this.newTip = false;
|
|
this.words.active = false;
|
|
},
|
|
|
|
// 倒计时
|
|
cdTick: function() {
|
|
|
|
if( !this.nodCD ) {
|
|
return;
|
|
}
|
|
|
|
let time = nx.bridge.vget( "PPushCD" );
|
|
if( !nx.dt.numPositive( time, false ) ) {
|
|
this.nodCD.active = false;
|
|
return;
|
|
}
|
|
|
|
this.nodCD.active = true;
|
|
let txt = nx.bridge.time.cdDate( time );
|
|
nx.gui.setString( this.nodCD, "txt", txt );
|
|
|
|
},
|
|
|
|
} );
|