ShopView.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s =
  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 });
  17. const n = t("App"),
  18. o = t("BaseView"),
  19. a = t("ShopConst"),
  20. r = t("ShopContent"),
  21. l = t("EffectUtils"),
  22. h = t("BagController"),
  23. { property: c, ccclass: d, menu: u } = cc._decorator;
  24. (e = cc.Class({
  25. name: "ShopContenteSet",
  26. properties: { shopType: { type: cc.Enum(a.ShopType), default: 0 }, content: r.ShopContent }
  27. })),
  28. (t = class extends o.default {
  29. constructor() {
  30. super(...arguments),
  31. (this.moneyBarList = []),
  32. (this.scrollView = null),
  33. (this.widgets = []),
  34. (this.shopContentes = []),
  35. (this.controller = null),
  36. (this.bgType = 1);
  37. }
  38. onLoad() {
  39. n.default.Platform.checkIsNotch() && (this.node.getComponent(cc.Widget).top = 60);
  40. }
  41. initUI() {
  42. super.initUI();
  43. var t = this.controller.model.shopItemDatas;
  44. for (const e of this.shopContentes) {
  45. e.content.setData(t[e.shopType]);
  46. }
  47. n.default.Platform.checkIsNotch() &&
  48. this.widgets.forEach(t => {
  49. t.top += 50;
  50. });
  51. }
  52. open(e) {
  53. super.open();
  54. for (const t of this.shopContentes)
  55. this.isShowContent(t.shopType) ? t.content.initContent() : (t.content.node.active = !1);
  56. this.onTouchScrollView(),
  57. n.default.TimerManager.doTimer(
  58. 500,
  59. 1,
  60. () => {
  61. for (let t = 0; t < this.shopContentes.length; t++)
  62. if (e == this.shopContentes[t].shopType) {
  63. this.scrollView.scrollToOffset(cc.v2(0, -this.shopContentes[t].content.node.y), 1);
  64. break;
  65. }
  66. },
  67. this
  68. );
  69. }
  70. updateContentUI(t) {
  71. for (const e of this.shopContentes) t == e.shopType && e.content.updateUI();
  72. }
  73. updateMonthCard(t) { }
  74. updateTime(t) {
  75. for (const e of this.shopContentes) e.shopType == a.ShopType.BOX && e.content.updateUI();
  76. }
  77. playGetCoinAni(t, e = 0) {
  78. t %= h.CostType.coin;
  79. let i = this.moneyBarList[t];
  80. const s = n.default.ViewManager.uiRoot;
  81. var o = cc.Vec2.ZERO,
  82. a = i.convertToWorldSpaceAR(i.getChildByName("icon").position),
  83. a = s.convertToNodeSpaceAR(a);
  84. l.default.instance.playMoneyAni(o, a, t, s, e);
  85. }
  86. onTouchScrollView() {
  87. var t = this.scrollView.getContentPosition().y;
  88. for (const s of this.shopContentes) {
  89. var e = t + s.content.node.y,
  90. i = t + (s.content.node.y - s.content.node.height);
  91. e < -this.scrollView.node.height || 0 < i
  92. ? s.content.hideContent()
  93. : this.isShowContent(s.shopType) && s.content.showContent();
  94. }
  95. }
  96. isShowContent(t) {
  97. let e = !0;
  98. switch (t) {
  99. case a.ShopType.Diamond:
  100. case a.ShopType.GIFT:
  101. e = n.default.Platform.getIsShowPay();
  102. }
  103. return e;
  104. }
  105. });
  106. s([c([cc.Node])], t.prototype, "moneyBarList", void 0),
  107. s([c(cc.ScrollView)], t.prototype, "scrollView", void 0),
  108. s([c([cc.Widget])], t.prototype, "widgets", void 0),
  109. s([c(e)], t.prototype, "shopContentes", void 0),
  110. (t = s([d, u("view/Shop/ShopView")], t)),
  111. (i.default = t);