StageUpgradeView.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 });
  17. const o = t("App"),
  18. s = t("BaseView"),
  19. a = t("NotificationConst"),
  20. n = t("StageUpgradeService"),
  21. r = t("StageUpgradeViewItem"),
  22. { ccclass: l, property: h, menu: c } = cc._decorator;
  23. t = class extends s.default {
  24. constructor() {
  25. super(...arguments),
  26. (this.content = null),
  27. (this.scrollView = null),
  28. (this.itemPre = null),
  29. (this.empty = null),
  30. (this.items = null),
  31. (this.bgType = 1);
  32. }
  33. open() {
  34. super.open();
  35. }
  36. initUI() {
  37. super.initUI(), this.initItem();
  38. }
  39. onDisable() {
  40. o.default.NotificationCenter.removeListener(a.NotificationConst.STAGE_UPGRADE_UPDATE, this.updateUI, this);
  41. }
  42. updateUI(t) {
  43. this.empty.active = !t;
  44. }
  45. initItem() {
  46. var s = n.default.ins.datas;
  47. for (let i = 0; i < s.length; i++) {
  48. let t = cc.instantiate(this.itemPre);
  49. this.content.addChild(t);
  50. let e = t.getComponent(r.default);
  51. if ((e.setData(s[i]), i < 6 && e.show(), 50 <= i)) break;
  52. }
  53. s.length ?
  54. o.default.NotificationCenter.addListener(a.NotificationConst.STAGE_UPGRADE_UPDATE, this.updateUI, this) :
  55. (this.empty.active = !0);
  56. }
  57. updateItem() {
  58. for (const t of this.content.getComponentsInChildren(r.default)) t.updtaeBtnState();
  59. }
  60. onTouchScrollView() {
  61. var t = this.content.getComponentsInChildren(r.default),
  62. e = this.scrollView.getContentPosition().y;
  63. for (const o of t) {
  64. var i = o.node.y + e,
  65. s = o.node.y - o.node.height + e;
  66. i < -525 || -47 < s ? o.hide() : o.show();
  67. }
  68. }
  69. };
  70. e([h(cc.Node)], t.prototype, "content", void 0),
  71. e([h(cc.ScrollView)], t.prototype, "scrollView", void 0),
  72. e([h(cc.Prefab)], t.prototype, "itemPre", void 0),
  73. e([h(cc.Node)], t.prototype, "empty", void 0),
  74. (t = e([l], t)),
  75. (i.default = t);