"use strict"; cc._RF.push(module, 'e884b7lsiBJaZglc5R1o/OZ', 'cmp.act.partner.buylimit'); // Scripts/mod/acts/partnerBuyLimit/cmp/cmp.act.partner.buylimit.js "use strict"; /****************************************************************** * * 英雄限購 * ******************************************************************/ var ActPage = require("act.page.base"); var BCT = require("battle_controller"); var NxSpine = require("nx.fx.spine"); var PathTool = require("pathtool"); var ItemLay = require("cmp.common.itemlayout"); var HeroConst = require("hero_const"); var Payment = require("payment.mod"); var TxtColor = [new cc.Color(187, 7, 7), new cc.Color(29, 107, 1), new cc.Color(33, 60, 225)]; cc.Class({ "extends": ActPage, properties: { roleSp: { "default": null, type: NxSpine }, ndTi: { //標題圖片 "default": null, type: cc.Node }, ndTi2: { //標題圖片2 "default": null, type: cc.Node }, ndSmod: { "default": null, type: cc.Node }, fabSmod: { "default": null, type: cc.Prefab }, cdTime: { "default": null, type: cc.Node }, giftLay1: { "default": null, type: ItemLay }, giftLay2: { "default": null, type: ItemLay }, oldTxt: { "default": [], type: [cc.Node] }, priceTxt: { "default": [], type: [cc.Node] }, buyNds: { "default": [], type: [cc.Node] }, playBtn: { "default": null, type: cc.Node }, giftTxts: { "default": [], type: [cc.Node] }, attrNd: { "default": null, type: cc.Node }, attrPersons: { "default": null, type: cc.Node }, attrTeam: { "default": null, type: cc.Node } }, // 初始化 build: function build(_data) { this._super(_data); this.quota_data = game.configs.activity_set_quota_data; this.payId = []; // 活动监听 this.mod.vbind(this, [["buyLimitCamp", this.setCampId.bind(this)], ["buyLimitInfos", this.freshInfos.bind(this)]]); }, onEnable: function onEnable() { this.camp_id = this.data.camp_id; this.mod.reqLimitData(this.data.camp_id); }, onDisable: function onDisable() { this.giftLay1.rebuild([]); this.giftLay2.rebuild([]); }, // 销毁 onDestroy: function onDestroy() { // 活动监听解除 if (this.mod) { this.mod.vunbind(this); } this._super(); }, setCampId: function setCampId(camp_id) { this.cur_camp_id = camp_id; }, freshInfos: function freshInfos(data) { var _this = this; this.payId = []; if (nx.dt.objEmpty(data)) return; var info = data[this.data.camp_id]; if (info.bid != this.cur_camp_id) return; if (nx.dt.objEmpty(info)) return; var resInfo = this.quota_data.data_holiday_res[info.bid]; if (resInfo) { this.pv_id = resInfo.fake_battle_id; if (this.pv_id == null || this.pv_id == "") { this.playBtn.active = false; } nx.gui.setActive(this.attrNd, "", resInfo.is_skin == 1); var tiicon = cc.js.formatStr("locals/%s/images/acts/%s", nx.getLocLanguage(), resInfo.interface_art); nx.gui.setSpriteFrame(this.ndTi, "", tiicon); var skin_info = null; var h_config = null; if (resInfo.is_skin == 1) { skin_info = game.configs.partner_skin_data.data_skin_info[resInfo.skin_id]; if (skin_info) { // let tiicon3 = cc.js.formatStr("locals/%s/images/acts/%s",nx.getLocLanguage(),resInfo.skin_title); // nx.gui.setSpriteFrame(this.ndTi2,"",tiicon3); var skin_path = PathTool.getSpinePath(skin_info.res_id, "show", false); this.roleSp.node.x = -300; this.roleSp.load(skin_path, function (_e) { if (_e) { _this.roleSp.stop(); } else { _this.roleSp.action("action1", true); } }); // 个人属性加成 var attrs = skin_info.skin_attr || []; var chds = this.attrPersons.children; nx.gui.gocChildren(this.attrPersons, "", attrs.length, chds[0]); for (var i = 0; i < attrs.length; ++i) { for (var v in chds[i].children) { chds[i].children[v].color = TxtColor[i]; } nx.bridge.attrs.setAttribute(chds[i], attrs[i]); } // 团体属性加成 var allattrs = skin_info.skin_attr_all || []; if (nx.dt.arrEmpty(allattrs)) { this.attrTeam.active = false; nx.gui.setActive(this.attrNd, "ti2", false); } else { this.attrTeam.active = true; nx.gui.setActive(this.attrNd, "ti2", true); var chds2 = this.attrTeam.children; nx.gui.gocChildren(this.attrTeam, "", allattrs.length, chds2[0]); for (var _i = 0; _i < allattrs.length; ++_i) { for (var _v in chds2[_i].children) { chds2[_i].children[_v].color = TxtColor[_i]; } nx.bridge.attrs.setAttribute(chds2[_i], allattrs[_i]); } } } } else { h_config = game.configs.partner_data.data_partner_base[resInfo.partner_id]; if (h_config) { var tiicon2 = cc.js.formatStr("locals/%s/images/acts/%s", nx.getLocLanguage(), resInfo.title); var res_path = PathTool.getSpinePath(h_config.bustid, "show", false); nx.gui.setSpriteFrame(this.ndTi2, "", tiicon2); this.roleSp.load(res_path, function (_e) { if (_e) { _this.roleSp.stop(); } else { _this.roleSp.action("action1", true); } }); } } //小模型 if (!this.sHero) { this.sHero = cc.instantiate(this.fabSmod); this.sHero.parent = this.ndSmod; this.sHero.y += 25; } var scmp = nx.gui.getComponent(this.sHero, "", "cmp.partner.smod"); if (scmp) { if (resInfo.is_skin == 1) { scmp.setData({ use_skin: skin_info.skin_id }, true, false); } else { scmp.setData(h_config, true, false); } } } //倒计时cd nx.gui.setCdTxt(this.cdTime, "", info.remain_sec); for (var _i2 in info.aim_list) { var aim_data = info.aim_list[_i2]; if (aim_data) { nx.gui.setString(this.giftTxts[_i2], "", aim_data.aim_str); for (var arg_k in aim_data.aim_args) { var arg = aim_data.aim_args[arg_k]; if (arg.aim_args_key == 35) { //設置原價 nx.gui.setString(this.oldTxt[_i2], "", cc.js.formatStr("-%s%", arg.aim_args_val)); } if (arg.aim_args_key == 26) { //設置現價 var xprice = Payment.getInstance().fmtPrice(arg.aim_args_val); nx.gui.setString(this.priceTxt[_i2], "", xprice); } if (arg.aim_args_key == 33) { //獲取支付id this.payId.push(arg.aim_args_val); } //是否购买完成 if (arg.aim_args_key == 6) { if (arg.aim_args_val == 1) { var btn = nx.gui.getComponent(this.buyNds[_i2], "", cc.Button); if (btn) { btn.interactable = false; } nx.gui.setString(this.buyNds[_i2], "price", nx.text.getKey("Charged")); } // nx.gui.setActive(this.buyNds[i],"",arg.aim_args_val == 0); } } } } this.giftLay1.rebuild(info.aim_list[0].item_list); this.giftLay2.rebuild(info.aim_list[1].item_list); }, onBuyGift: function onBuyGift(_id) { var charge_id = this.payId[_id]; if (charge_id) { Payment.getInstance().reqPayment(charge_id); } }, onTryBat: function onTryBat() { if (!this.pv_id) return; BCT.getInstance().requestUseHeroBattle(1, this.pv_id); } }); cc._RF.pop();