var t = require; var e = module; var i = exports; var e = (this && this.__decorate) || function (t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }, s = (this && this.__awaiter) || function (t, n, r, l) { return new (r = r || Promise)(function (i, e) { function s(t) { try { a(l.next(t)); } catch (t) { e(t); } } function o(t) { try { a(l.throw(t)); } catch (t) { e(t); } } function a(t) { var e; t.done ? i(t.value) : ((e = t.value) instanceof r ? e : new r(function (t) { t(e); }) ).then(s, o); } a((l = l.apply(t, n || [])).next()); }); }; Object.defineProperty(i, "__esModule", {value: !0}); const o = t("App"), a = t("BaseView"), n = t("Toast"), r = t("NotificationConst"), l = (t("ViewConst"), t("LayerManager"), t("MailAwardItem")), h = t("MailController"), {ccclass: c, property: d} = cc._decorator; t = class extends a.default { constructor() { super(...arguments), (this.title = null), (this.context = null), (this.time = null), (this.awardItem = null), (this.content = null), (this.gainBtn = null), (this.delBtn = null), (this.bgType = 1); } open(t, e) { super.open(), (this.id = t), (this.status = e), this.updateView(); } updateBtnState() { switch (this.status) { case h.MailStatus.readed: (this.gainBtn.active = !0), (this.delBtn.active = !1); break; case h.MailStatus.geted: case h.MailStatus.read_get: (this.gainBtn.active = !1), (this.delBtn.active = !0); } } updateView() { return s(this, void 0, void 0, function* () { this.content.removeAllChildren(); var e = yield this.controller.readMailById(this.id); if (e) { (this.status = e.state), this.updateBtnState(); var t = o.default.DateUtils.getTimezoneOffset(); (this.title.string = e.title), (this.context.string = e.content); (t = e.expire_time - t), (t = new Date(1e3 * t).Format("yyyy-MM-dd hh:mm")); if (((this.time.string = t), (this.awards = e.awards), e.awards.length)) { this.content.active = !0; for (let t = 0; t < e.awards.length; t++) this.creatAwardItem(e.awards[t].item, e.awards[t].number); } else (this.content.active = !1), (this.gainBtn.active = !1), (this.delBtn.active = !0); } }); } creatAwardItem(t, e) { let i = cc.instantiate(this.awardItem); this.content.addChild(i), i.getComponent(l.default).setData(t, e); } onTouchGet() { return s(this, void 0, void 0, function* () { (yield this.controller.gainAndSenReward(this.id)) ? ((this.gainBtn.active = !1), (this.delBtn.active = !0)) : n.default.launch("领取邮件失败"); }); } onTouchDel() { return s(this, void 0, void 0, function* () { (yield this.controller.delMailById(this.id)) ? (o.default.NotificationCenter.dispatch(r.NotificationConst.UPDATE_MAIL_LIST), o.default.ViewManager.close(44)) : n.default.launch("删除邮件失败"); }); } }; (t.VIEW_INFO = {prefabName: "mail/MailBoxView", zIndex: 100, key: 44}), e([d(cc.Label)], t.prototype, "title", void 0), e([d(cc.Label)], t.prototype, "context", void 0), e([d(cc.Label)], t.prototype, "time", void 0), e([d(cc.Node)], t.prototype, "awardItem", void 0), e([d(cc.Node)], t.prototype, "content", void 0), e([d(cc.Node)], t.prototype, "gainBtn", void 0), e([d(cc.Node)], t.prototype, "delBtn", void 0), (t = e([c], t)), (i.default = t);