ShopGiftItem.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. e =
  5. (this && this.__decorate) ||
  6. function (t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", {value: !0}), (i.ShopGiftItem = void 0);
  17. const a = t("App"),
  18. s = t("SwitchFrame"),
  19. n = t("ControllerConst"),
  20. r = (t("ViewConst"), t("BagConst")),
  21. o = t("CostumeBagItem"),
  22. l = t("ShopConst"),
  23. h = t("ShopItem"),
  24. c = t("ShopNormalItem"),
  25. {property: d, ccclass: u, menu: p} = cc._decorator;
  26. t = class extends h.ShopItem {
  27. constructor() {
  28. super(...arguments),
  29. (this.bigBg = null),
  30. (this.huawen = null),
  31. (this.smallBg = null),
  32. (this.switchFram = null),
  33. (this.nameLabelOutLine = null),
  34. (this.giftNameLab = null),
  35. (this.rateLab = null),
  36. (this.organiPriceLab = null),
  37. (this.diamondItem = null),
  38. (this.costumeBagItem = null),
  39. (this.shopNormalItem = null),
  40. (this.iconSwitchFrame = null),
  41. (this.data = null);
  42. }
  43. setData(t) {
  44. this.data = t;
  45. }
  46. isRemove() {
  47. return !this.data.isShowInShopView();
  48. }
  49. initItem() {
  50. (this.isShow = !0), (this.giftNameLab.string = this.data.getName());
  51. let e = a.default.Platform.getPriceNum(this.data.cfg.payId);
  52. (this.costLab.string = e + "元"),
  53. this.data.cfg.rate
  54. ? ((this.rateLab.string = 10 * this.data.cfg.rate + "折"),
  55. (this.organiPriceLab.string = Math.ceil(e / this.data.cfg.rate) + "元"))
  56. : ((this.rateLab.node.parent.active = !1),
  57. (this.organiPriceLab.node.active = !1),
  58. (this.costLab.node.y = 0));
  59. var i,
  60. s = this.data.items;
  61. this.diamondItem.setData(this.data.getDiamondIconUrl(), "" + this.data.cfg.diamond);
  62. for (let t = 0; t < s.length; t++) {
  63. 0 == t
  64. ? (i = this.shopNormalItem)
  65. : ((i = cc.instantiate(this.shopNormalItem)), this.shopNormalItem.parent.addChild(i));
  66. const e = i.getComponent(c.ShopNormalItem),
  67. o = a.default.ControllerManager.applyFunc(n.ControllerConst.Item, r.BagConst.GET_ITEM, s[t].id);
  68. o.data.itemType == r.ItemType.REMOVE_AD
  69. ? e.setData(o.getItemPic(), "NO ADS")
  70. : e.setData(o.getItemPic(), "" + s[t].cnt);
  71. }
  72. this.data.costumes
  73. ? (this.costumeBagItem.setData(this.data.costumes[0]), this.costumeBagItem.node.setSiblingIndex(9))
  74. : (this.costumeBagItem.node.active = !1);
  75. let o = this.data.cfg.shopGift.color;
  76. if (o) {
  77. const e = f[o];
  78. (this.bigBg.color = a.default.Color.getColorFromHex(e.bgColor)),
  79. (this.huawen.color = a.default.Color.getColorFromHex(e.iconColor)),
  80. (this.nameLabelOutLine.color = a.default.Color.getColorFromHex(e.nameOutLinColor)),
  81. (this.smallBg.color = a.default.Color.getColorFromHex(e.smallBgColor)),
  82. (this.switchFram.frameIndex = e.frameIndex);
  83. }
  84. this.iconSwitchFrame.frameIndex = this.data.giftType == l.ShopGiftType.REMOVE_AD_GIFT ? 1 : 0;
  85. }
  86. onTouchBuyBtn() {
  87. this.data.giftType == l.ShopGiftType.FIRST_GIFT
  88. ? a.default.ViewManager.open(40)
  89. : this.data.giftType == l.ShopGiftType.REMOVE_AD_GIFT
  90. ? a.default.ViewManager.open(53, this.data)
  91. : a.default.ControllerManager.applyFunc(n.ControllerConst.Shop, l.ShopConst.BUY, this.data);
  92. }
  93. };
  94. e([d(cc.Node)], t.prototype, "bigBg", void 0),
  95. e([d(cc.Node)], t.prototype, "huawen", void 0),
  96. e([d(cc.Node)], t.prototype, "smallBg", void 0),
  97. e([d(s.default)], t.prototype, "switchFram", void 0),
  98. e([d(cc.LabelOutline)], t.prototype, "nameLabelOutLine", void 0),
  99. e([d(cc.Label)], t.prototype, "giftNameLab", void 0),
  100. e([d(cc.Label)], t.prototype, "rateLab", void 0),
  101. e([d(cc.Label)], t.prototype, "organiPriceLab", void 0),
  102. e([d(c.ShopNormalItem)], t.prototype, "diamondItem", void 0),
  103. e([d(o.CostumeBagItem)], t.prototype, "costumeBagItem", void 0),
  104. e([d(cc.Node)], t.prototype, "shopNormalItem", void 0),
  105. e([d(s.default)], t.prototype, "iconSwitchFrame", void 0),
  106. (t = e([u, p("view/Shop/item/ShopGiftItem")], t)),
  107. (i.ShopGiftItem = t);
  108. const f = {
  109. yellow: {
  110. bgColor: "#fff1a5",
  111. nameOutLinColor: "#ecb154",
  112. iconColor: "#fde395",
  113. smallBgColor: "#fffad4",
  114. frameIndex: 0
  115. },
  116. red: {bgColor: "#ffd5d0", nameOutLinColor: "#e17d73", iconColor: "#ffc2bc", smallBgColor: "#ffeadf", frameIndex: 1},
  117. purple: {
  118. bgColor: "#daddff",
  119. nameOutLinColor: "#aa83c6",
  120. iconColor: "#ceceff",
  121. smallBgColor: "#daf2ff",
  122. frameIndex: 2
  123. }
  124. };