MailItem.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('MailItem')
  4. export class MailItem extends Component {
  5. @property(Label)
  6. lblTime: Label;
  7. @property(Label)
  8. lblFrom: Label;
  9. @property(Label)
  10. lblTitle: Label;
  11. @property(Node)
  12. hasRead: Node;
  13. @property(Node)
  14. currentFlag: Node;
  15. private _data: { mailId: string, time: number, from: string, title: string, content: string, state: string }
  16. public get data() {
  17. return this._data;
  18. }
  19. public setData(data) {
  20. this._data = data;
  21. let date = new Date(this._data.time);
  22. let str = '' + date.getFullYear();
  23. str += '-' + date.getMonth();
  24. str += '-' + date.getDate();
  25. str += ' ' + date.getHours();
  26. str += ':' + date.getMinutes();
  27. this.lblTime.string = str;
  28. this.lblTitle.string = this._data.title;
  29. this.hasRead.active = !!this._data.state;
  30. }
  31. public set selected(v: boolean) {
  32. this.currentFlag.active = v;
  33. }
  34. }