98 lines
2.3 KiB
JavaScript
98 lines
2.3 KiB
JavaScript
|
|
const SvcItem = require( "nx.fx.sv.expand.item" );
|
||
|
|
var PathTool = require( "pathtool" )
|
||
|
|
var ChatEvent = require( "chat_event" )
|
||
|
|
cc.Class( {
|
||
|
|
extends: SvcItem,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
bg: {
|
||
|
|
default: null,
|
||
|
|
type: cc.Sprite
|
||
|
|
},
|
||
|
|
icon: {
|
||
|
|
default: null,
|
||
|
|
type: cc.Sprite
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
// 数据重置
|
||
|
|
rebind: function( _idx, _data, _key ) {
|
||
|
|
|
||
|
|
this._super( _idx, _data, _key );
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
this.setData( _data, _key )
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad() {
|
||
|
|
},
|
||
|
|
|
||
|
|
start() {
|
||
|
|
},
|
||
|
|
|
||
|
|
onFocus() {
|
||
|
|
if( nx.dt.objEmpty( this.mdata ) ) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
let params = {};
|
||
|
|
if( this.type_key == 2 ) {
|
||
|
|
params.item_data = this.mdata.info;
|
||
|
|
gcore.GlobalEvent.fire( ChatEvent.INPUT_SELECT_ITEM, this.type_key, params );
|
||
|
|
} else {
|
||
|
|
params.hero_info = this.mdata.hero_info;
|
||
|
|
params.item_data = this.mdata.item_data;
|
||
|
|
gcore.GlobalEvent.fire( ChatEvent.INPUT_SELECT_ITEM, this.type_key, params );
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
outFocus() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
setData( data, _key ) {
|
||
|
|
if( nx.dt.objEmpty( data ) ) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
this.type_key = _key;
|
||
|
|
|
||
|
|
if( _key == 2 ) {
|
||
|
|
// 图标设置
|
||
|
|
nx.bridge.setIcon( this.icon, "", data.info.config.icon );
|
||
|
|
this.setQuality( data.info.config.quality );
|
||
|
|
|
||
|
|
this.select_cb = data.cb;
|
||
|
|
} else if( _key == 3 ) {
|
||
|
|
// 图标设置
|
||
|
|
nx.bridge.setIcon( this.icon, "", data.item_data.config.icon );
|
||
|
|
this.setQuality( data.item_data.quality );
|
||
|
|
|
||
|
|
this.select_cb = data.cb;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 单设:品质
|
||
|
|
setQuality: function( _qa ) {
|
||
|
|
|
||
|
|
if( this.bg ) {
|
||
|
|
let qa = null;
|
||
|
|
if( nx.dt.numPositive( _qa ) ) {
|
||
|
|
qa = cc.path.join( "coms/images", "bg_qa" + _qa );
|
||
|
|
}
|
||
|
|
nx.gui.setSpriteFrame( this.bg, "", qa );
|
||
|
|
}
|
||
|
|
|
||
|
|
// if( this.nodName ) {
|
||
|
|
// let color = BackPackConst.quality_color( _qa );
|
||
|
|
// let cur = this.nodName.node.color;
|
||
|
|
// cur.fromHEX( color );
|
||
|
|
// this.nodName.node.color = cur;
|
||
|
|
// }
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// update (dt) {},
|
||
|
|
} );
|