98 lines
2.3 KiB
JavaScript
98 lines
2.3 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 背包道具批量使用界面
|
|
*
|
|
******************************************************************/
|
|
|
|
const ItemBase = require( "cmp.item.base" );
|
|
const BridgeWindow = require( "bridge.window" );
|
|
const SliderProgress = require( "cmp.slider.prog.selector" );
|
|
const BackPackConst = require( "backpack_const" );
|
|
const BackPackController = require( "backpack_controller" );
|
|
|
|
const BBC = BackPackConst.Bag_Code;
|
|
const BTT = BackPackConst.item_sub_type;
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
|
|
cmpItem: {
|
|
default: null,
|
|
type: ItemBase,
|
|
},
|
|
|
|
cmpCounter: {
|
|
default: null,
|
|
type: SliderProgress,
|
|
},
|
|
|
|
},
|
|
|
|
// 重载:参数打开
|
|
onOpenConfigs: function( _params ) {
|
|
|
|
this.item = _params[ 0 ];
|
|
this.selects = _params[2];
|
|
|
|
// 这里暂时没有解析ItemConsumeType参数 用到再说
|
|
if( _params[ 1 ] > 1 ) {
|
|
nx.error( "[BatchUse]失败,暂无处理这种情况!" );
|
|
this.close();
|
|
return;
|
|
}
|
|
|
|
this.config = this.item ? this.item.config : null;
|
|
if( !this.item || !this.config ) {
|
|
nx.error( "[BatchUse]失败,参数无效!" );
|
|
this.close();
|
|
return;
|
|
}
|
|
|
|
// 重建
|
|
this.rebuild();
|
|
},
|
|
|
|
// 重建
|
|
rebuild: function() {
|
|
|
|
// 道具信息
|
|
this.cmpItem.setData( this.item );
|
|
|
|
// 设置滚动条
|
|
let total = this.item.quantity;
|
|
this.cmpCounter.build( 1, total, total, ( _count ) => {
|
|
this.changeCount( _count );
|
|
} );
|
|
|
|
// 数量为1不显示计数条
|
|
nx.gui.setActive( this.cmpCounter, "", total > 1 );
|
|
|
|
// 数量改变
|
|
this.changeCount( total );
|
|
},
|
|
|
|
// 数量改变
|
|
changeCount: function( _count ) {
|
|
|
|
if( this.cur == _count ||
|
|
!nx.dt.numPositive( _count, false ) ) {
|
|
return;
|
|
}
|
|
|
|
this.cur = _count;
|
|
this.cmpItem.setCount( _count );
|
|
},
|
|
|
|
// 点击确认
|
|
onTouchConfirm: function() {
|
|
|
|
let BagC = BackPackController.getInstance();
|
|
BagC.sender10515( this.item.id, this.cur, this.selects );
|
|
BagC.openItemSellPanel( false );
|
|
},
|
|
|
|
} );
|