Files
fc/dev/project/library/imports/84/849d4bf4-f0ea-406b-8d43-ed7456fea458.js
T
2026-05-24 10:21:26 +08:00

85 lines
2.2 KiB
JavaScript

"use strict";
cc._RF.push(module, '849d4v08OpAa41D7XRW/qRY', 'cmp.merge.wnd');
// Scripts/mod/backpack/cmps/cmp.merge.wnd.js
"use strict";
/****
* 合成面板
*/
var ItemBase = require("cmp.item.base");
var BridgeWindow = require("bridge.window");
var SliderProgress = require("cmp.slider.prog.selector");
var BackPackController = require("backpack_controller");
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;
this.bagCode = _params[1] || 1;
if (!this.item || !this.config) {
nx.error("[Merge]合成失败,参数无效!");
return;
}
// 重建
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);
var needCount = gdata("partner_data", "data_get_compound_info", this.config.id).num;
var canMergeCount = Math.floor(parseInt(count / needCount));
this.canMerge = count >= needCount ? true : false;
if (!this.canMerge) {
this.cmpCounter.build(0, 0, 0, 0);
} else {
// 设置滚动条
this.cmpCounter.build(1, canMergeCount, canMergeCount, function (_count) {
_this.changeCount(_count);
});
}
this.cmpItem.setCount(0);
},
// 数量改变
changeCount: function changeCount(_count) {
if (this.cur == _count || !nx.dt.numPositive(_count, false)) {
return;
}
this.cur = _count;
},
// 点击合成按钮
onTouchSell: function onTouchSell() {
var BagC = BackPackController.getInstance();
if (!this.canMerge) {
nx.tbox("insufficent amount!");
this.cmpCounter.build(0, 0, 0, 0);
return;
}
BagC.sender11008(this.config.id, this.cur);
BagC.openItemMergePanel(false);
}
});
cc._RF.pop();