Files
fc/dev/project/library/imports/d4/d4b7c930-dbba-406b-b9d8-6199eb8c2468.js
T
2026-05-24 10:21:26 +08:00

204 lines
5.3 KiB
JavaScript

"use strict";
cc._RF.push(module, 'd4b7ckw27pAa7nYYZnrjCRo', 'cmp.guildmarket.main');
// Scripts/mod/guild/marketplace/cmp/cmp.guildmarket.main.js
"use strict";
var GuildMarketMod = require("guildmarketplace_controller");
var BridgeWindow = require("bridge.window");
var MarketEvent = require("guildmarketplace_event");
var MarketConst = require("guildmarketplace_const");
var NxExpand = require("nx.fx.sv.expand");
var NxTogs = require("nx.fx.togs");
var BackPackConst = require("backpack_const");
var BackPackController = require("backpack_controller");
var NxSpine = require("nx.fx.spine");
var BTT = BackPackConst.item_sub_type;
// 标签页对应关系
var TabPage = [{
key: "PROPS",
tab: BTT.PROPS,
"goto": 2
}, {
key: "EQUIPS",
tab: BTT.EQUIPS,
"goto": 1
}, {
key: "HERO",
tab: BTT.HERO,
"goto": 0
}, {
key: "SPECIAL",
tab: BTT.SPECIAL,
"goto": 3
}];
cc.Class({
"extends": BridgeWindow,
properties: {
placeList: {
"default": null,
type: NxExpand
},
bagList: {
"default": null,
type: NxExpand
},
pushBtn: {
"default": null,
type: cc.Node
},
returnBtn: {
"default": null,
type: cc.Node
},
topTog: {
"default": null,
type: NxTogs
},
roleSp: {
"default": null,
type: NxSpine
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function onLoad() {
this.mod = GuildMarketMod.getInstance();
this.pType = MarketConst.PanelType.eMarket;
this.bagType = 0;
this.topTog.posTog = this.onTogMenu.bind(this);
this.topTog.togTo(0);
//放入物品,並從背包中刪除
this.bindGEvent(EventId.DELETE_GOODS, this.onUpdateGoods.bind(this));
//倉庫初始化刷新物品
this.bindGEvent(MarketEvent.GUILD_MARKET_PLACE_ITEM_EVENT, this.updateMarketItems.bind(this));
},
//倉庫相関/////////////////
updateMarketItems: function updateMarketItems(item_list) {
if (this.pType == MarketConst.PanelType.eMarket) {
var sub_type = TabPage[this.bagType];
var use_list = [];
for (var i in item_list) {
var cfg = this.mod.getModel().getMarketCfg(item_list[i].base_id);
if (cfg && cfg.type == sub_type["goto"]) {
use_list.push(item_list[i]);
}
}
this.placeList.rebuild(use_list);
}
},
freshMarketItems: function freshMarketItems() {
var items = this.mod.getModel().getMarketItems();
this.updateMarketItems(items);
},
//倉庫相関/////////////////
//背包相関/////////////////
onTogMenu: function onTogMenu(bag_type) {
this.bagType = bag_type;
if (this.pType == MarketConst.PanelType.eMarket) {
this.freshMarketItems();
} else {
this.freshItemList();
}
},
// 更新
onUpdateGoods: function onUpdateGoods(_bagCode, _itemList) {
// 不处理: 列表为空
if (nx.dt.objEmpty(_itemList)) {
return;
}
// 当前页有改变
var upd = false;
for (var k in _itemList) {
var tm = _itemList[k];
if (tm && tm.sub_type == this.bagType) {
upd = true;
break;
}
}
// 强刷
if (upd) {
this.freshItemList();
}
},
// 背包更新
freshItemList: function freshItemList() {
var page = TabPage[this.bagType];
var model = BackPackController.getInstance().getModel();
var list = model.getAllBackPackArray(page.tab);
//清除所有聚焦
this.bagList.cleanFocus();
if (nx.dt.arrEmpty(list)) {
this.bagList.rebuild([]);
return;
}
var sell_list = [];
for (var i in list) {
var is_allow = this.mod.getModel().isAllowSell(list[i].base_id);
if (is_allow) {
sell_list.push(list[i]);
}
}
this.bagList.rebuild(sell_list);
},
// 选中切换
onFocusChanged: function onFocusChanged(_item) {
// 空
if (nx.dt.objEmpty(_item) || nx.dt.objEmpty(_item.mdata)) {
return;
}
// 聚焦
this.bagList.cleanFocus();
this.bagList.addFocus(_item.index);
nx.bridge.createPanel("WndGuildMarketBuy", {
data: _item.mdata,
is_sell: true
});
},
//背包相関/////////////////
onOpenConfigs: function onOpenConfigs(params) {
var _this = this;
this.changePanel();
this.roleSp.load("resDB/models/H30045/show", function (_e) {
if (!_e) {
_this.roleSp.action("action1", true);
} else {
_this.roleSp.stop();
}
});
},
changePanel: function changePanel() {
if (this.pType == MarketConst.PanelType.eMarket) {
// this.topTog.node.active = false;
this.placeList.node.active = true;
this.bagList.node.active = false;
this.pushBtn.active = true;
this.returnBtn.active = false;
this.mod.sender26900();
} else if (this.pType == MarketConst.PanelType.eBag) {
// this.topTog.node.active = true;
this.placeList.node.active = false;
this.bagList.node.active = true;
this.pushBtn.active = false;
this.returnBtn.active = true;
this.freshItemList();
}
},
touchPush: function touchPush() {
this.pType = MarketConst.PanelType.eBag;
this.changePanel();
},
touchReturn: function touchReturn() {
this.pType = MarketConst.PanelType.eMarket;
this.changePanel();
},
onPreClosed: function onPreClosed() {
this.placeList.rebuild([]);
this.bagList.rebuild([]);
}
});
cc._RF.pop();