MailListView.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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("BaseView"),
  51. n = t("NotificationConst"),
  52. r = (t("ViewConst"), t("LayerManager"), t("MaillistItem")),
  53. {ccclass: l, property: h} = cc._decorator;
  54. t = class extends a.default {
  55. constructor() {
  56. super(...arguments), (this.mailItem = null), (this.content = null), (this.empty = null), (this.bgType = 1);
  57. }
  58. open() {
  59. super.open(),
  60. this.initView(),
  61. o.default.NotificationCenter.addListener(n.NotificationConst.UPDATE_MAIL_LIST, this.initView, this);
  62. }
  63. initView() {
  64. return s(this, void 0, void 0, function* () {
  65. this.content.removeAllChildren();
  66. let t = !0;
  67. const e = this.controller.serverMailData;
  68. for (var i in e) {
  69. const s = e[i];
  70. this.creatMailItem(s.id, s.title, s.expire_time, s.create_time, s.state), (t = !1);
  71. }
  72. const s = this.controller.getLocalMail();
  73. if (s)
  74. for (var o in s) {
  75. const e = s[o];
  76. this.creatMailItem(e.id, e.title, e.expire_time, e.create_time, e.state), (t = !1);
  77. }
  78. this.empty.active = t;
  79. });
  80. }
  81. creatMailItem(t, e, i, s, o) {
  82. let a = cc.instantiate(this.mailItem);
  83. this.content.addChild(a), a.getComponent(r.default).setData(t, e, i, s, o);
  84. }
  85. onDisable() {
  86. o.default.NotificationCenter.removeListener(n.NotificationConst.UPDATE_MAIL_LIST, this.initView, this);
  87. }
  88. onTouchDel() {
  89. return s(this, void 0, void 0, function* () {
  90. yield this.controller.delAllMailByReaded(), this.initView();
  91. });
  92. }
  93. onTouchGet() {
  94. return s(this, void 0, void 0, function* () {
  95. yield this.controller.gainAllMailReward(), this.initView();
  96. });
  97. }
  98. };
  99. (t.VIEW_INFO = {prefabName: "mail/MailListView", zIndex: 100, key: 45}),
  100. e([h(cc.Node)], t.prototype, "mailItem", void 0),
  101. e([h(cc.Node)], t.prototype, "content", void 0),
  102. e([h(cc.Node)], t.prototype, "empty", void 0),
  103. (t = e([l], t)),
  104. (i.default = t);