"use strict"; cc._RF.push(module, 'd74eaRSnCdOjKR/DfTeGXt+', 'cmp.adventure.shop'); // Scripts/mod/pve/adventure/cmp/cmp.adventure.shop.js "use strict"; var BridgeWindow = require("bridge.window"); var ADVCT = require("adventure_controller"); var ADEVT = require("adventure_event"); var PathTool = require("pathtool"); cc.Class({ "extends": BridgeWindow, properties: { itemNods: { "default": [], type: [cc.Node] }, fabItem: { "default": null, type: cc.Prefab } }, // LIFE-CYCLE CALLBACKS: onLoad: function onLoad() { this.ctrl = ADVCT.getInstance(); this.bindGEvent(ADEVT.Update_Shop_Data, this.updateShop.bind(this)); }, updateShop: function updateShop(data) { if (data.times <= 0) { nx.tbox("tip_eleBuyNumOver"); this.close(); return; } this.shop_data = data; this.refreshShop(); }, start: function start() {}, onOpenConfigs: function onOpenConfigs(params) { this.model_type = this.ctrl.getPlayModel(); this.evt_config = params.config; this.room_id = params.room_id; this.shop_data = this.ctrl.getShopData(); if (this.shop_data) { this.refreshShop(); } }, refreshShop: function refreshShop() { var list = this.shop_data.list; for (var i in list) { var data = list[i]; var item = this.itemNods[data.id - 1]; if (item) { var cfg = gitemdata(data.pay_type); var usual_item = false; if (cfg) { usual_item = true; //是通用道具 } if (usual_item) { var nd = nx.gui.find(item, "goods"); nd.active = true; var pre = cc.instantiate(this.fabItem); pre.parent = nd; var cmp = nx.gui.getComponent(pre, "", "cmp.item.base"); if (cmp) { cmp.rebind(i, { bid: data.bid, num: data.num }, ""); } //設置價格 if (data.discount > 0) { nx.gui.setActive(item, "dis", true); nx.gui.setString(item, "dis/txt", data.discount + "%off"); } if (data.is_buy == 1) { //已購買 nx.gui.setActive(item, "buy", false); } else { nx.gui.setActive(item, "buy", true); var pay_res = PathTool.querySmallIconPath(data.pay_type); nx.gui.setSpriteFrame(item, "buy/ico", pay_res); nx.gui.setString(item, "buy/num", data.pay_val); } } else { var prop = nx.gui.find(item, "prop"); prop.active = true; var res_id = ""; if (this.model_type == 1) { res_id = game.configs.adventure_endless_data.data_item_icon[data.bid]; } else { res_id = game.configs.adventure_weekly_data.data_adventure_event[data.bid].item_icon; } var res = cc.js.formatStr("prefab/pve/starlost/icons/%s", res_id); nx.gui.setSpriteFrame(prop, "ico", res); nx.gui.setString(prop, "count", data.num); if (data.discount > 0) { nx.gui.setActive(item, "dis", true); nx.gui.setString(item, "dis/txt", data.discount + "%off"); } if (data.is_buy == 1) { nx.gui.setActive(item, "buy/txt", true); nx.gui.setActive(item, "buy/ico", false); nx.gui.setActive(item, "buy/num", false); var buy = nx.gui.find(item, "buy"); nx.gui.setString(buy, "txt", nx.text.getKey("lab_rfm_personal_gift_window_tip2")); } else { nx.gui.setActive(item, "buy/txt", false); nx.gui.setActive(item, "buy/ico", true); nx.gui.setActive(item, "buy/num", true); var pay_res2 = cc.js.formatStr("prefab/pve/starlost/icons/%s", data.pay_type); nx.gui.setSpriteFrame(item, "buy/ico", pay_res2); nx.gui.setString(item, "buy/num", data.pay_val); } } } } }, onPreClosed: function onPreClosed() {}, clickBuyProp: function clickBuyProp(_index) { if (!this.shop_data) return; if (this.shop_data.times <= 0) { nx.tbox("tip_eleBuyNumOver"); this.close(); return; } var id = Number(_index); var select_data = null; for (var i in this.shop_data.list) { if (this.shop_data.list[i].id == id) { select_data = this.shop_data.list[i]; } } if (!select_data) return; if (select_data.is_buy == 1) { return nx.tbox("lab_mall_store_item_panel_tip1"); } this.ctrl.send29520([this.room_id], 1, [{ type: 1, val: select_data.exec_id }], this.model_type); }, clickCheckProp: function clickCheckProp(_index) { if (!this.shop_data) return; var id = Number(_index); var select_data = null; for (var i in this.shop_data.list) { if (this.shop_data.list[i].id == id) { select_data = this.shop_data.list[i]; } } if (!select_data) return; var data = {}; data.bid = select_data.exec_id; data.num = 0; data.can_use = 0; nx.bridge.createPanel("WndAdventureMsg", { type: 3, data: data }); } // update (dt) {}, }); cc._RF.pop();