130 lines
3.4 KiB
JavaScript
130 lines
3.4 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 PathTool = require( "pathtool" );
|
|
const HeroController = require( "hero_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,
|
|
},
|
|
|
|
nodResult: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
},
|
|
|
|
// 重载:参数打开
|
|
onOpenConfigs: function( _params ) {
|
|
|
|
this.item = _params[ 0 ];
|
|
this.config = this.item ? this.item.config : null;
|
|
if( !this.item || !this.config ) {
|
|
nx.error( "[SELL]出售失败,参数无效!" );
|
|
return;
|
|
}
|
|
|
|
// 特殊转换,背包中的装备要走装备库
|
|
this.bagCode = _params[ 1 ] || 1;
|
|
if( this.bagCode == BBC.BACKPACK &&
|
|
this.config.sub_type == BTT.EQUIPS ) {
|
|
this.bagCode = BBC.EQUIPS;
|
|
}
|
|
|
|
// 重建
|
|
this.rebuild();
|
|
},
|
|
|
|
// 重建
|
|
rebuild: function() {
|
|
|
|
// 道具信息
|
|
this.cmpItem.setData( this.item );
|
|
|
|
// 数量范围&&默认
|
|
let Bag = BackPackController.getInstance().getModel();
|
|
let count = Bag.getPackItemNumByBid( this.bagCode, this.config.id );
|
|
|
|
// 设置滚动条
|
|
this.cmpCounter.build( 1, 1, 1, ( _count ) => {
|
|
this.changeCount( _count );
|
|
} );
|
|
|
|
// 数量为1不显示计数条
|
|
nx.gui.setActive( this.cmpCounter, "", count > 1 );
|
|
|
|
// 计算价格
|
|
this.changeCount( 1 );
|
|
},
|
|
|
|
// 数量改变
|
|
changeCount: function( _count ) {
|
|
|
|
if( this.cur == _count ||
|
|
!nx.dt.numPositive( _count, false ) ) {
|
|
return;
|
|
}
|
|
|
|
this.cur = _count;
|
|
this.cmpItem.setCount( _count );
|
|
|
|
// 价值信息获取
|
|
if( !nx.dt.numPositive( this.price, false ) ) {
|
|
|
|
if( nx.dt.arrEmpty( this.config.value[ 0 ] ) ) {
|
|
nx.error( "[ITEM]售卖失败,价值缺失!", this.config.id );
|
|
return;
|
|
}
|
|
let cost = this.config.value[ 0 ] ;
|
|
this.price = cost[ 1 ];
|
|
if( !nx.dt.numPositive( this.price, false ) ) {
|
|
nx.error( "[ITEM]售卖失败,价值无效!", this.config.id );
|
|
return;
|
|
}
|
|
|
|
// 等价物
|
|
nx.bridge.setIcon( this.nodResult, "price/ico", cost[ 0 ] );
|
|
|
|
}
|
|
|
|
let total = this.cur * this.price;
|
|
nx.gui.setString( this.nodResult, "price/txt", Math.floor( total ) );
|
|
|
|
},
|
|
|
|
// 点击分解
|
|
onTouchDecompose: function() {
|
|
|
|
let HC = HeroController.getInstance();
|
|
let BagC = BackPackController.getInstance();
|
|
// BagC.sender10522( this.bagCode, [ args ] );
|
|
HC.sender11035( this.item.id );
|
|
BagC.openItemDecomposePanel( false );
|
|
},
|
|
|
|
} );
|