77 lines
2.1 KiB
JavaScript
77 lines
2.1 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 活动菜单项
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const SvcItem = require( "nx.fx.sv.expand.item" )
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: SvcItem,
|
||
|
|
|
||
|
|
properties: {},
|
||
|
|
|
||
|
|
// 数据重置
|
||
|
|
rebind: function( _idx, _data, _key ) {
|
||
|
|
|
||
|
|
this._super( _idx, _data, _key );
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
if( _data ) {
|
||
|
|
this.fresh();
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 聚焦获得
|
||
|
|
onFocus: function() {
|
||
|
|
nx.gui.setActive( this, "on", true );
|
||
|
|
nx.gui.setActive( this, "off", false );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 聚焦失去
|
||
|
|
outFocus: function() {
|
||
|
|
nx.gui.setActive( this, "on", false );
|
||
|
|
nx.gui.setActive( this, "off", true );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
fresh: function() {
|
||
|
|
|
||
|
|
this.outFocus();
|
||
|
|
|
||
|
|
// 图标
|
||
|
|
let icon = cc.path.join( "prefab/acts/coms/ui", this.mdata.icon || "icon1" );
|
||
|
|
nx.gui.setSpriteFrame( this, "off/icon/img", icon );
|
||
|
|
nx.gui.setSpriteFrame( this, "on/icon/img", `${ icon }s` );
|
||
|
|
|
||
|
|
// 活动名
|
||
|
|
let txt = nx.text.getKey( this.mdata.name );
|
||
|
|
nx.gui.setString( this, "off/txt", txt );
|
||
|
|
nx.gui.setString( this, "on/txt", txt );
|
||
|
|
|
||
|
|
// 标记
|
||
|
|
// if( nx.dt.strEmpty( this.mdata.activity_icon ) ||
|
||
|
|
// nx.dt.strEmpty( this.mdata.end_icon ) ) {
|
||
|
|
// nx.gui.setSpriteFrame( this, "off/ico", null );
|
||
|
|
// } else {
|
||
|
|
// let time = this.mdata.end_time - Math.floor( cc.sys.now() / 1000 ) > 0 ? this.mdata.end_time - Math.floor( cc.sys.now() / 1000 ) : 0;
|
||
|
|
// let key = time > 0 ? this.mdata.activity_icon : this.mdata.end_icon;
|
||
|
|
// nx.gui.setSpriteFrame( this, "off/ico", cc.path.join( "prefab/acts/coms/ui", key ) );
|
||
|
|
// }
|
||
|
|
|
||
|
|
// 提示
|
||
|
|
let dot = nx.gui.getComponent( this, "off/tip", "nx.vb.visible" );
|
||
|
|
let act = nx.bridge.acts.queryAct( this.mdata.camp_id, false );
|
||
|
|
if( !dot || !act ) {
|
||
|
|
nx.gui.setActive( dot, "", false );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let key = act.getTipKey();
|
||
|
|
dot.setTarget( nx.mTip, key );
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|