const Api = require('../net/Api'); var DWTool = require('../utils/DWTool'); cc.Class({ extends: cc.Component, properties: { avatar: cc.Sprite, timeLabel: cc.Label, timelineText: cc.RichText, }, // LIFE-CYCLE CALLBACKS: onLoad() { }, start () { }, configData(model) { if (model.head) { Api.createImageFromUrl(model.head, (spriteFrame) => { this.avatar.spriteFrame = spriteFrame; }); } else { this.avatar.spriteFrame = null; } var nameColor = '#fd7979'; if (model.gender == 1) { nameColor = '#0eb7db'; } var textString = "" + model.nick + " "; this.timelineText.string = textString + model.postMsg; this.timeLabel.string = DWTool.timeParse((model.createTime / 1000)); let textHeight = this.timelineText.node._contentSize.height + 30; this.node.height = Math.max(textHeight, 100); }, // update (dt) {}, });