OtherArtistItem.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const Api = require('../net/Api');
  2. const DWTool = require('../utils/DWTool');
  3. const { GameNotificationKey } = require('../utils/GameEnum')
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. bgSprite: cc.Sprite,
  8. artistLevelSprite: cc.Sprite,
  9. headSprite: cc.Sprite,
  10. nickLabel: cc.Label,
  11. starCountLabel: cc.Label,
  12. genderIcon: cc.Sprite,
  13. roleSprite: cc.Sprite,
  14. _itemId: 0,
  15. jobLevelNameLabel: cc.Label,
  16. artistLevelBgs: [cc.SpriteFrame],
  17. femaleFrame: cc.SpriteFrame,
  18. maleFrame: cc.SpriteFrame,
  19. },
  20. onLoad() {
  21. // 这个地方不用跳转到别人的家园了
  22. // this.node.on(cc.Node.EventType.TOUCH_END, () => {
  23. // if (this.user.isFriend) {
  24. // this.cb();
  25. // GameEvent.fire(GameNotificationKey.VisitFriendHome, this.user.uid);
  26. // }
  27. // }, this);
  28. },
  29. /**
  30. * gender [int]
  31. * head [string]
  32. * nick [string]
  33. * stars [int]
  34. * uid [int]
  35. * */
  36. updateItem(userInfo, itemId, cb) {
  37. this._itemId = itemId;
  38. this.user = userInfo;
  39. this.cb = cb || function () { };
  40. if (userInfo.isFriend) {
  41. this.roleSprite.node.active = true;
  42. } else {
  43. this.roleSprite.node.active = false;
  44. }
  45. this.genderIcon.spriteFrame = userInfo.gender == 1 ? this.maleFrame : this.femaleFrame;
  46. this.nickLabel.string = userInfo.nick;
  47. this.starCountLabel.string = userInfo.stars;
  48. Api.createImageFromUrl(userInfo.head, (spriteFrame) => {
  49. this.headSprite.spriteFrame = spriteFrame;
  50. }, null);
  51. if (userInfo.jobLevelName) {
  52. this.jobLevelNameLabel.node.active = true;
  53. this.jobLevelNameLabel.string = userInfo.jobLevelName;
  54. } else {
  55. this.jobLevelNameLabel.node.active = false;
  56. }
  57. if (userInfo.jobLevel) {
  58. this.artistLevelSprite.node.active = true;
  59. this.artistLevelSprite.spriteFrame = this.artistLevelBgs[userInfo.jobLevel - 1];
  60. } else {
  61. this.artistLevelSprite.node.active = false;
  62. }
  63. },
  64. });