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;
            });
        }

        var nameColor = '#fd7979';
        if (model.gender == 1) {
            nameColor = '#0eb7db';
        }
        var textString = "<color="+ nameColor +">" + model.nick + "</color>";

        this.timelineText.string = textString + "<color=#FFFFFF> "+ model.postMsg +"</color>";

        this.timeLabel.string = DWTool.timeParse((model.createTime / 1000));
    },

    // update (dt) {},
});
