UserInformationTimelineItem.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const Api = require('../net/Api');
  2. var DWTool = require('../utils/DWTool');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. avatar: cc.Sprite,
  7. timeLabel: cc.Label,
  8. timelineText: cc.RichText,
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. onLoad() {
  12. },
  13. start () {
  14. },
  15. configData(model) {
  16. if (model.head) {
  17. Api.createImageFromUrl(model.head, (spriteFrame) => {
  18. this.avatar.spriteFrame = spriteFrame;
  19. });
  20. } else {
  21. this.avatar.spriteFrame = null;
  22. }
  23. var nameColor = '#fd7979';
  24. if (model.gender == 1) {
  25. nameColor = '#0eb7db';
  26. }
  27. var textString = "<color="+ nameColor +">" + model.nick + "</color> ";
  28. this.timelineText.string = textString + model.postMsg;
  29. this.timeLabel.string = DWTool.timeParse((model.createTime / 1000));
  30. let textHeight = this.timelineText.node._contentSize.height + 30;
  31. this.node.height = Math.max(textHeight, 100);
  32. },
  33. // update (dt) {},
  34. });