114 lines
3.1 KiB
JavaScript
114 lines
3.1 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'eedc842uplECJbU9HWq62pb', 'cmp.decompose.wnd');
|
|
// Scripts/mod/backpack/cmps/cmp.decompose.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 出售界面
|
|
*
|
|
******************************************************************/
|
|
|
|
var ItemBase = require("cmp.item.base");
|
|
var BridgeWindow = require("bridge.window");
|
|
var SliderProgress = require("cmp.slider.prog.selector");
|
|
var BackPackConst = require("backpack_const");
|
|
var BackPackController = require("backpack_controller");
|
|
var PathTool = require("pathtool");
|
|
var HeroController = require("hero_controller");
|
|
var BBC = BackPackConst.Bag_Code;
|
|
var 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 onOpenConfigs(_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 rebuild() {
|
|
var _this = this;
|
|
// 道具信息
|
|
this.cmpItem.setData(this.item);
|
|
|
|
// 数量范围&&默认
|
|
var Bag = BackPackController.getInstance().getModel();
|
|
var count = Bag.getPackItemNumByBid(this.bagCode, this.config.id);
|
|
|
|
// 设置滚动条
|
|
this.cmpCounter.build(1, 1, 1, function (_count) {
|
|
_this.changeCount(_count);
|
|
});
|
|
|
|
// 数量为1不显示计数条
|
|
nx.gui.setActive(this.cmpCounter, "", count > 1);
|
|
|
|
// 计算价格
|
|
this.changeCount(1);
|
|
},
|
|
// 数量改变
|
|
changeCount: function changeCount(_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;
|
|
}
|
|
var 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]);
|
|
}
|
|
var total = this.cur * this.price;
|
|
nx.gui.setString(this.nodResult, "price/txt", Math.floor(total));
|
|
},
|
|
// 点击分解
|
|
onTouchDecompose: function onTouchDecompose() {
|
|
var HC = HeroController.getInstance();
|
|
var BagC = BackPackController.getInstance();
|
|
// BagC.sender10522( this.bagCode, [ args ] );
|
|
HC.sender11035(this.item.id);
|
|
BagC.openItemDecomposePanel(false);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |