Files
fc/dev/project/library/imports/5f/5f515c7c-be02-4046-afa7-7b28494b2486.js
T

118 lines
3.3 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '5f515x8vgJARq+neyhJSySG', 'cmp.sell.wnd');
// Scripts/mod/backpack/cmps/cmp.sell.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 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.config.sub_type == BTT.HOLYEQUIPMENT)) {
this.bagCode = BBC.EQUIPS;
}
// 重建
this.rebuild();
},
// 重建
rebuild: function rebuild() {
var _this = this;
// 道具信息
this.cmpItem.setData(this.item);
// 数量范围&&默认
var Bag = BackPackController.getInstance().getModel();
var count = game.configs.item_data.data_unit3[this.config.id] ? 1 : Bag.getPackItemNumByBid(this.bagCode, this.config.id);
// 设置滚动条
this.cmpCounter.build(1, count, count, function (_count) {
_this.changeCount(_count);
});
if (game.configs.item_data.data_unit3[this.config.id]) {
nx.gui.setActive(this.cmpCounter, "", false);
} else {
// 数量为1不显示计数条
nx.gui.setActive(this.cmpCounter, "", count > 1);
}
// 计算价格
this.changeCount(count);
},
// 数量改变
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;
}
var icon = gdata("item_data", "data_unit1", cost[0]);
// 等价物
nx.bridge.setIcon(this.nodResult, "price/ico", icon.icon);
}
var total = this.cur * this.price;
nx.gui.setString(this.nodResult, "price/txt", Math.floor(total));
},
// 点击出售
onTouchSell: function onTouchSell() {
var BagC = BackPackController.getInstance();
var args = {
id: this.item.id,
bid: this.item.base_id,
num: this.cur
};
BagC.sender10522(this.bagCode, [args]);
BagC.openItemSellPanel(false);
}
});
cc._RF.pop();