import RedPoint from "../data/RedPoint"; const { ccclass, property } = cc._decorator; @ccclass export default class MailItem extends cc.Component { @property(cc.Label) mTitle: cc.Label = null; @property(cc.Label) mTime: cc.Label = null; @property(cc.Node) tipsIcon: cc.Node = null; /** * 邮件内容 */ public data: any; public index: number = 0; public callback: (mailItem: MailItem) => void; public init(data: any, index: number) { this.data = data; this.index = index; this.mTitle.string = this.data.title; this.tipsIcon.active = !data.receive; let day = this.data.xTime / 86400; if (day <= 0) { this.mTime.string = '即将过期'; } else { this.mTime.string = '剩余' + Math.floor(day) + '天'; } } public setCallback(callback: (mailItem: MailItem) => void) { this.callback = callback; } public onclick() { this.callback(this); } }