MailMain.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { BaseView } from '../../../framework/layer/BaseView';
  3. import { MailItem } from './MailItem';
  4. import { StringUtil } from '../../../framework/util/StringUtil';
  5. import { MailData } from '../../data/MailData';
  6. import { GlobalConf } from '../../config/GlobalConf';
  7. import List from '../../../framework/list/List';
  8. import { Framework } from '../../../framework/Framework';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('MailMain')
  11. export class MailMain extends BaseView {
  12. @property({ type: Label, tooltip: "关闭提示" })
  13. closeTips: Label = null;
  14. @property({ type: Label, tooltip: "标题" })
  15. titlteTx: Label = null;
  16. @property({ type: Label, tooltip: "邮件数文字" })
  17. numTx: Label = null;
  18. @property({ type: List, tooltip: "滑动容器" })
  19. sv: List = null;
  20. @property({ type: Node, tooltip: "为空提示节点" })
  21. noneNode: Node = null;
  22. @property({ type: Label, tooltip: "为空提示文字" })
  23. noneTx: Label = null;
  24. @property({ type: Node, tooltip: "一键删除按钮" })
  25. delAutoBtn: Node = null;
  26. @property({ type: Label, tooltip: "一键删除按钮文字" })
  27. delAutoBtnTx: Label = null;
  28. @property({ type: Node, tooltip: "一键领取按钮" })
  29. getAutoBtn: Node = null;
  30. @property({ type: Label, tooltip: "一键领取按钮文字" })
  31. getAutoBtnTx: Label = null;
  32. private _mailList = [];
  33. private _nowMailId: number = 0;
  34. onLoad() {
  35. super.onLoad();
  36. this.closeTips.string = StringUtil.getLanguageData('点击空白关闭');
  37. this.titlteTx.string = StringUtil.getLanguageData('邮件');
  38. this.noneTx.string = StringUtil.getLanguageData('当前空空如也哦~');
  39. this.delAutoBtnTx.string = StringUtil.getLanguageData('一键删除');
  40. this.getAutoBtnTx.string = StringUtil.getLanguageData('一键领取');
  41. }
  42. onDestroy() {
  43. super.onDestroy();
  44. }
  45. onOpen() {
  46. this.updateMainPanel();
  47. this.updateMailNum();
  48. }
  49. onClose() {
  50. }
  51. onShow() {
  52. }
  53. onHide() {
  54. }
  55. private onTouchButton(event: Event, customStr) {
  56. let target: any = event.target;
  57. if (target.name == 'mask') {
  58. Framework.layer.close(this);
  59. } else if (target.name == 'auto_del_btn') {
  60. } else if (target.name == 'auto_get_btn') {
  61. }
  62. }
  63. onEventList(item, idx) {
  64. item.getComponent(MailItem).refreshItem(this._mailList[idx]);
  65. }
  66. private updateMainPanel() {
  67. this._mailList = MailData.orderMail();
  68. this._nowMailId = this._mailList.length > 0 ? this._mailList[0].id : 0;
  69. if (this._mailList.length == 0) {
  70. this.noneNode.active = true;
  71. this.delAutoBtn.active = false;
  72. this.getAutoBtn.active = false;
  73. this.numTx.node.active = false;
  74. } else {
  75. this.noneNode.active = false;
  76. this.delAutoBtn.active = true;
  77. this.getAutoBtn.active = true;
  78. this.numTx.node.active = true;
  79. }
  80. this.sv.numItems = this._mailList.length;
  81. }
  82. private updateMailNum() {
  83. this.numTx.string = `${StringUtil.getLanguageData('邮件数: ')}${this._mailList.length}/${GlobalConf.data.MailMaxCount.Value}`;
  84. }
  85. }