67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '013c1GrXs9PAanASjUEGL7H', 'cmp.guildmarket.item.shop');
|
|
// Scripts/mod/guild/marketplace/cmp/cmp.guildmarket.item.shop.js
|
|
|
|
"use strict";
|
|
|
|
var ItemBase = require("nx.fx.sv.expand.item");
|
|
var MarketMod = require("guildmarketplace_controller");
|
|
cc.Class({
|
|
"extends": ItemBase,
|
|
properties: {
|
|
fabItem: {
|
|
"default": null,
|
|
type: cc.Prefab
|
|
},
|
|
tag: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
rebind: function rebind(_index, _data, _key) {
|
|
this._super(_index, _data, _key);
|
|
this.setData(_data);
|
|
},
|
|
setData: function setData(data) {
|
|
if (nx.dt.objEmpty(data)) {
|
|
return;
|
|
}
|
|
var iCfg = MarketMod.getInstance().getModel().getMarketCfg(data.base_id);
|
|
if (iCfg) {
|
|
nx.gui.setString(this.node, "txt", iCfg.name);
|
|
nx.gui.setString(this.node, "price", cc.js.formatStr("<img src='%s'/>%s", iCfg.price[0][0], iCfg.price[0][1]));
|
|
this.is_limit = false;
|
|
if (iCfg.day_buy > 0) {
|
|
//限購
|
|
var buy_num = MarketMod.getInstance().getModel().getBuyByBid(data.base_id);
|
|
nx.gui.setString(this.node, "num", nx.text.getKey("action_str7") + data.num);
|
|
if (buy_num == data.num) {
|
|
this.is_limit = true;
|
|
}
|
|
} else {
|
|
nx.gui.setString(this.node, "num", cc.js.formatStr(nx.text.getKey("GuildMktKc"), data.num));
|
|
}
|
|
}
|
|
if (!this.item) {
|
|
this.item = cc.instantiate(this.fabItem);
|
|
this.item.parent = this.tag;
|
|
}
|
|
var cmp = nx.gui.getComponent(this.item, "", "cmp.item.base");
|
|
if (cmp) {
|
|
cmp.rebind(0, {
|
|
bid: data.base_id,
|
|
num: 0
|
|
}, "");
|
|
}
|
|
},
|
|
buyItem: function buyItem() {
|
|
if (this.is_limit) {
|
|
return nx.tbox("GuildMktLim");
|
|
}
|
|
nx.bridge.createPanel("WndGuildMarketBuy", {
|
|
data: this.mdata
|
|
});
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |