var t = require; var e = module; var i = exports; var e = (this && this.__decorate) || function (t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }, s = (this && this.__awaiter) || function (t, n, r, l) { return new (r = r || Promise)(function (i, e) { function s(t) { try { a(l.next(t)); } catch (t) { e(t); } } function o(t) { try { a(l.throw(t)); } catch (t) { e(t); } } function a(t) { var e; t.done ? i(t.value) : ((e = t.value) instanceof r ? e : new r(function (t) { t(e); }) ).then(s, o); } a((l = l.apply(t, n || [])).next()); }); }; Object.defineProperty(i, "__esModule", {value: !0}); const o = t("App"), a = t("GameText"), n = t("BaseView"), r = t("ControllerConst"), l = (t("ViewConst"), t("BagConst")), h = t("CostumeConst"), c = t("GameConst"), d = t("ShopConst"), {property: u, ccclass: p, menu: f} = cc._decorator; t = class extends n.default { constructor() { super(...arguments), (this.ani = null), (this.costumeTypeIcon = null), (this.costumeIcon = null), (this.costumeBgSpr = null), (this.diamondIconSpr = null), (this.diamonNumLab = null), (this.itemIconSpr = null), (this.itemName = null), (this.buyNode = null), (this.organiPriceLab = null), (this.ratePriceLab = null), (this.rateLab = null), (this.getBtnArray = []), (this.controller = null), (this.bgType = 1), (this.data = null); } initUI() { super.initUI(), (this.data = this.controller.model.shopGiftDatas[d.ShopGiftType.FIRST_GIFT][0]), this.ani.on(cc.Animation.EventType.FINISHED, this.onAniFinish, this); } open() { super.open(), this.updateUI(), this.ani.play("work"); } updateUI() { const t = this.data.costumes[0]; o.default.CommonUtils.setSpriteFrame(h.getRarityUrlByGrade(t.data.grade), this.costumeBgSpr), o.default.CommonUtils.setSpriteFrameByBundle(c.BundleType.MAP_ICON, t.getIcon(), this.costumeIcon), o.default.CommonUtils.setSpriteFrameByBundle(c.BundleType.MAP_ICON, t.getTypeIcon(), this.costumeTypeIcon); const e = o.default.ControllerManager.applyFunc( r.ControllerConst.Item, l.BagConst.GET_ITEM, this.data.items[0].id ); var i; o.default.CommonUtils.setSpriteFrame(e.getItemPic(), this.itemIconSpr), (this.itemName.string = e.getName() + "x" + this.data.items[0].cnt), o.default.CommonUtils.setSpriteFrame(this.data.getDiamondIconUrl(), this.diamondIconSpr), (this.diamonNumLab.string = "钻石x" + this.data.cfg.diamond), this.data.isBuyGift() ? (this.buyNode.active = !1) : ((this.buyNode.active = !0), (i = o.default.Platform.getPriceNum(this.data.cfg.payId)), (this.ratePriceLab.string = i + "元"), (this.rateLab.string = 10 * this.data.cfg.rate + "折"), (this.organiPriceLab.string = Math.ceil(i / this.data.cfg.rate) + "元")), this.updateGetBtnState(); } updateGetBtnState() { var e = this.data.buyCnt - 1; for (let t = 0; t < this.getBtnArray.length; t++) { const i = this.getBtnArray[t], s = i.node.getComponentInChildren(cc.Label); t < e ? ((i.interactable = !1), s.setMaterial(0, i.grayMaterial), (s.string = a.GameText.getText(37))) : (t == e && this.data.isCanGetFirstGift() ? ((i.interactable = !0), s.setMaterial(0, i.normalMaterial)) : ((i.interactable = !1), s.setMaterial(0, i.grayMaterial)), (s.string = a.GameText.getText(9))); } } onTouchGetBtn() { o.default.ControllerManager.applyFunc(r.ControllerConst.Shop, d.ShopConst.GET_FIRST_GIFT, this.data), this.updateGetBtnState(); } onTouchBuyBtn() { return s(this, void 0, void 0, function* () { yield o.default.ControllerManager.applyFunc(r.ControllerConst.Shop, d.ShopConst.BUY, this.data), this.updateUI(); }); } onAniFinish() { this.ani.play("idle"); } onTouchCostume() { o.default.ViewManager.open(26, this.data.costumes[0]); } }; e([u(cc.Animation)], t.prototype, "ani", void 0), e([u(cc.Sprite)], t.prototype, "costumeTypeIcon", void 0), e([u(cc.Sprite)], t.prototype, "costumeIcon", void 0), e([u(cc.Sprite)], t.prototype, "costumeBgSpr", void 0), e([u(cc.Sprite)], t.prototype, "diamondIconSpr", void 0), e([u(cc.Label)], t.prototype, "diamonNumLab", void 0), e([u(cc.Sprite)], t.prototype, "itemIconSpr", void 0), e([u(cc.Label)], t.prototype, "itemName", void 0), e([u(cc.Node)], t.prototype, "buyNode", void 0), e([u(cc.Label)], t.prototype, "organiPriceLab", void 0), e([u(cc.Label)], t.prototype, "ratePriceLab", void 0), e([u(cc.Label)], t.prototype, "rateLab", void 0), e([u([cc.Button])], t.prototype, "getBtnArray", void 0), (t = e([p, f("view/Shop/ShopFirstView")], t)), (i.default = t);