OtherActorItem.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const Api = require('../net/Api');
  2. var DWTool = require('../utils/DWTool');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. bgSprite: cc.Sprite,
  7. headSprite: cc.Sprite,
  8. nickLabel: cc.Label,
  9. starCountLabel: cc.Label,
  10. genderIcon: cc.Sprite,
  11. roleSprite: cc.Sprite,
  12. _itemId: 0,
  13. titleLabel: cc.Label,
  14. },
  15. onLoad() {
  16. this.titleLabel.node.opacity = 0;
  17. // this.headSprite.node.width = this.headSprite.node.width / 4;
  18. // this.headSprite.node.height = this.headSprite.node.height / 4;
  19. },
  20. /**
  21. * gender [int]
  22. * head [string]
  23. * nick [string]
  24. * stars [int]
  25. * uid [int]
  26. * */
  27. updateItem(userInfo, itemId) {
  28. this._itemId = itemId;
  29. this.user = userInfo;
  30. if (userInfo.isFriend) {
  31. this.roleSprite.node.active = true;
  32. } else {
  33. this.roleSprite.node.active = false;
  34. }
  35. DWTool.setGenderIcon(userInfo.gender).then((spriteFrame) => {
  36. this.genderIcon.node.active = true;
  37. this.genderIcon.spriteFrame = spriteFrame;
  38. }, (error) => {
  39. this.genderIcon.node.active = false;
  40. });
  41. this.nickLabel.string = userInfo.nick;
  42. this.starCountLabel.string = userInfo.stars;
  43. Api.createImageFromUrl(userInfo.head, (spriteFrame) => {
  44. this.headSprite.spriteFrame = spriteFrame;
  45. }, null);
  46. },
  47. });