ShopFirstView.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var 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. s =
  17. (this && this.__awaiter) ||
  18. function (t, n, r, l) {
  19. return new (r = r || Promise)(function (i, e) {
  20. function s(t) {
  21. try {
  22. a(l.next(t));
  23. } catch (t) {
  24. e(t);
  25. }
  26. }
  27. function o(t) {
  28. try {
  29. a(l.throw(t));
  30. } catch (t) {
  31. e(t);
  32. }
  33. }
  34. function a(t) {
  35. var e;
  36. t.done
  37. ? i(t.value)
  38. : ((e = t.value) instanceof r
  39. ? e
  40. : new r(function (t) {
  41. t(e);
  42. })
  43. ).then(s, o);
  44. }
  45. a((l = l.apply(t, n || [])).next());
  46. });
  47. };
  48. Object.defineProperty(i, "__esModule", {value: !0});
  49. const o = t("App"),
  50. a = t("GameText"),
  51. n = t("BaseView"),
  52. r = t("ControllerConst"),
  53. l = (t("ViewConst"), t("BagConst")),
  54. h = t("CostumeConst"),
  55. c = t("GameConst"),
  56. d = t("ShopConst"),
  57. {property: u, ccclass: p, menu: f} = cc._decorator;
  58. t = class extends n.default {
  59. constructor() {
  60. super(...arguments),
  61. (this.ani = null),
  62. (this.costumeTypeIcon = null),
  63. (this.costumeIcon = null),
  64. (this.costumeBgSpr = null),
  65. (this.diamondIconSpr = null),
  66. (this.diamonNumLab = null),
  67. (this.itemIconSpr = null),
  68. (this.itemName = null),
  69. (this.buyNode = null),
  70. (this.organiPriceLab = null),
  71. (this.ratePriceLab = null),
  72. (this.rateLab = null),
  73. (this.getBtnArray = []),
  74. (this.controller = null),
  75. (this.bgType = 1),
  76. (this.data = null);
  77. }
  78. initUI() {
  79. super.initUI(),
  80. (this.data = this.controller.model.shopGiftDatas[d.ShopGiftType.FIRST_GIFT][0]),
  81. this.ani.on(cc.Animation.EventType.FINISHED, this.onAniFinish, this);
  82. }
  83. open() {
  84. super.open(), this.updateUI(), this.ani.play("work");
  85. }
  86. updateUI() {
  87. const t = this.data.costumes[0];
  88. o.default.CommonUtils.setSpriteFrame(h.getRarityUrlByGrade(t.data.grade), this.costumeBgSpr),
  89. o.default.CommonUtils.setSpriteFrameByBundle(c.BundleType.MAP_ICON, t.getIcon(), this.costumeIcon),
  90. o.default.CommonUtils.setSpriteFrameByBundle(c.BundleType.MAP_ICON, t.getTypeIcon(), this.costumeTypeIcon);
  91. const e = o.default.ControllerManager.applyFunc(
  92. r.ControllerConst.Item,
  93. l.BagConst.GET_ITEM,
  94. this.data.items[0].id
  95. );
  96. var i;
  97. o.default.CommonUtils.setSpriteFrame(e.getItemPic(), this.itemIconSpr),
  98. (this.itemName.string = e.getName() + "x" + this.data.items[0].cnt),
  99. o.default.CommonUtils.setSpriteFrame(this.data.getDiamondIconUrl(), this.diamondIconSpr),
  100. (this.diamonNumLab.string = "钻石x" + this.data.cfg.diamond),
  101. this.data.isBuyGift()
  102. ? (this.buyNode.active = !1)
  103. : ((this.buyNode.active = !0),
  104. (i = o.default.Platform.getPriceNum(this.data.cfg.payId)),
  105. (this.ratePriceLab.string = i + "元"),
  106. (this.rateLab.string = 10 * this.data.cfg.rate + "折"),
  107. (this.organiPriceLab.string = Math.ceil(i / this.data.cfg.rate) + "元")),
  108. this.updateGetBtnState();
  109. }
  110. updateGetBtnState() {
  111. var e = this.data.buyCnt - 1;
  112. for (let t = 0; t < this.getBtnArray.length; t++) {
  113. const i = this.getBtnArray[t],
  114. s = i.node.getComponentInChildren(cc.Label);
  115. t < e
  116. ? ((i.interactable = !1), s.setMaterial(0, i.grayMaterial), (s.string = a.GameText.getText(37)))
  117. : (t == e && this.data.isCanGetFirstGift()
  118. ? ((i.interactable = !0), s.setMaterial(0, i.normalMaterial))
  119. : ((i.interactable = !1), s.setMaterial(0, i.grayMaterial)),
  120. (s.string = a.GameText.getText(9)));
  121. }
  122. }
  123. onTouchGetBtn() {
  124. o.default.ControllerManager.applyFunc(r.ControllerConst.Shop, d.ShopConst.GET_FIRST_GIFT, this.data),
  125. this.updateGetBtnState();
  126. }
  127. onTouchBuyBtn() {
  128. return s(this, void 0, void 0, function* () {
  129. yield o.default.ControllerManager.applyFunc(r.ControllerConst.Shop, d.ShopConst.BUY, this.data),
  130. this.updateUI();
  131. });
  132. }
  133. onAniFinish() {
  134. this.ani.play("idle");
  135. }
  136. onTouchCostume() {
  137. o.default.ViewManager.open(26, this.data.costumes[0]);
  138. }
  139. };
  140. e([u(cc.Animation)], t.prototype, "ani", void 0),
  141. e([u(cc.Sprite)], t.prototype, "costumeTypeIcon", void 0),
  142. e([u(cc.Sprite)], t.prototype, "costumeIcon", void 0),
  143. e([u(cc.Sprite)], t.prototype, "costumeBgSpr", void 0),
  144. e([u(cc.Sprite)], t.prototype, "diamondIconSpr", void 0),
  145. e([u(cc.Label)], t.prototype, "diamonNumLab", void 0),
  146. e([u(cc.Sprite)], t.prototype, "itemIconSpr", void 0),
  147. e([u(cc.Label)], t.prototype, "itemName", void 0),
  148. e([u(cc.Node)], t.prototype, "buyNode", void 0),
  149. e([u(cc.Label)], t.prototype, "organiPriceLab", void 0),
  150. e([u(cc.Label)], t.prototype, "ratePriceLab", void 0),
  151. e([u(cc.Label)], t.prototype, "rateLab", void 0),
  152. e([u([cc.Button])], t.prototype, "getBtnArray", void 0),
  153. (t = e([p, f("view/Shop/ShopFirstView")], t)),
  154. (i.default = t);