MailBoxView.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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("Toast"),
  52. r = t("NotificationConst"),
  53. l = (t("ViewConst"), t("LayerManager"), t("MailAwardItem")),
  54. h = t("MailController"),
  55. {ccclass: c, property: d} = cc._decorator;
  56. t = class extends a.default {
  57. constructor() {
  58. super(...arguments),
  59. (this.title = null),
  60. (this.context = null),
  61. (this.time = null),
  62. (this.awardItem = null),
  63. (this.content = null),
  64. (this.gainBtn = null),
  65. (this.delBtn = null),
  66. (this.bgType = 1);
  67. }
  68. open(t, e) {
  69. super.open(), (this.id = t), (this.status = e), this.updateView();
  70. }
  71. updateBtnState() {
  72. switch (this.status) {
  73. case h.MailStatus.readed:
  74. (this.gainBtn.active = !0), (this.delBtn.active = !1);
  75. break;
  76. case h.MailStatus.geted:
  77. case h.MailStatus.read_get:
  78. (this.gainBtn.active = !1), (this.delBtn.active = !0);
  79. }
  80. }
  81. updateView() {
  82. return s(this, void 0, void 0, function* () {
  83. this.content.removeAllChildren();
  84. var e = yield this.controller.readMailById(this.id);
  85. if (e) {
  86. (this.status = e.state), this.updateBtnState();
  87. var t = o.default.DateUtils.getTimezoneOffset();
  88. (this.title.string = e.title), (this.context.string = e.content);
  89. (t = e.expire_time - t), (t = new Date(1e3 * t).Format("yyyy-MM-dd hh:mm"));
  90. if (((this.time.string = t), (this.awards = e.awards), e.awards.length)) {
  91. this.content.active = !0;
  92. for (let t = 0; t < e.awards.length; t++) this.creatAwardItem(e.awards[t].item, e.awards[t].number);
  93. } else (this.content.active = !1), (this.gainBtn.active = !1), (this.delBtn.active = !0);
  94. }
  95. });
  96. }
  97. creatAwardItem(t, e) {
  98. let i = cc.instantiate(this.awardItem);
  99. this.content.addChild(i), i.getComponent(l.default).setData(t, e);
  100. }
  101. onTouchGet() {
  102. return s(this, void 0, void 0, function* () {
  103. (yield this.controller.gainAndSenReward(this.id))
  104. ? ((this.gainBtn.active = !1), (this.delBtn.active = !0))
  105. : n.default.launch("领取邮件失败");
  106. });
  107. }
  108. onTouchDel() {
  109. return s(this, void 0, void 0, function* () {
  110. (yield this.controller.delMailById(this.id))
  111. ? (o.default.NotificationCenter.dispatch(r.NotificationConst.UPDATE_MAIL_LIST),
  112. o.default.ViewManager.close(44))
  113. : n.default.launch("删除邮件失败");
  114. });
  115. }
  116. };
  117. (t.VIEW_INFO = {prefabName: "mail/MailBoxView", zIndex: 100, key: 44}),
  118. e([d(cc.Label)], t.prototype, "title", void 0),
  119. e([d(cc.Label)], t.prototype, "context", void 0),
  120. e([d(cc.Label)], t.prototype, "time", void 0),
  121. e([d(cc.Node)], t.prototype, "awardItem", void 0),
  122. e([d(cc.Node)], t.prototype, "content", void 0),
  123. e([d(cc.Node)], t.prototype, "gainBtn", void 0),
  124. e([d(cc.Node)], t.prototype, "delBtn", void 0),
  125. (t = e([c], t)),
  126. (i.default = t);