12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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 = "<color="+ nameColor +">" + model.nick + "</color> ";
- 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) {},
- });
|