LevelHomeFriendItem.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. const Style = require('../utils/GameEnum').LevelHomeFriendItemStyle;
  2. const Api = require('../net/Api');
  3. const NotiKey = require('../utils/GameEnum').GameNotificationKey;
  4. var WeChat = require("../net/WeChat");
  5. const DWTool = require('../utils/DWTool');
  6. const AlertManager = require('../utils/AlertManager');
  7. cc.Class({
  8. extends: cc.Component,
  9. properties: {
  10. itemBg: cc.Node,
  11. allFriendNode: cc.Node,
  12. friendInfoNode: cc.Node,
  13. talentNode: cc.Node,
  14. identityNode: cc.Node,
  15. identitySpriteFrames: [cc.SpriteFrame],
  16. headSprite: cc.Sprite,
  17. nickLabel: cc.Label,
  18. starsLabel: cc.Label,
  19. noticeNode: cc.Node,
  20. style: {
  21. get: function() {
  22. if (!this._style) {
  23. this._style = Style.Friend;
  24. }
  25. return this._style;
  26. },
  27. set: function(value) {
  28. this._style = value;
  29. this.layout();
  30. }
  31. },
  32. },
  33. // LIFE-CYCLE CALLBACKS:
  34. onLoad () {
  35. this.allFriendNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  36. GameEvent.fire(NotiKey.ShowFriendSystem);
  37. }, 1000, true), this);
  38. this.friendInfoNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  39. if (this.style === Style.Friend) {
  40. GameEvent.fire(NotiKey.VisitFriendHome, this.info.uid);
  41. } else if (this.style === Style.Artist) {
  42. GameEvent.fire(NotiKey.ShowUserInfomation, this.info.uid);
  43. }
  44. }, 1000, true), this);
  45. this.talentNode.on(cc.Node.EventType.TOUCH_END, function () {
  46. AlertManager.showTalentAlert();
  47. }, this);
  48. },
  49. setFriendInfo(info) {
  50. this.info = info;
  51. this.starsLabel.string = info.stars;
  52. this.nickLabel.string = info.nick;
  53. Api.createImageFromUrl(info.head, (spriteFrame) => {
  54. this.headSprite.spriteFrame = spriteFrame;
  55. }, null);
  56. if (info.role === 1) { // 我的老板
  57. this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[0];
  58. } else { // 我的艺人
  59. this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[1];
  60. }
  61. // 显示消息提示节点
  62. if(this.style === Style.Friend && info.isStationed) {
  63. this.noticeNode.active = true
  64. } else {
  65. this.noticeNode.active = false
  66. }
  67. },
  68. layout() {
  69. switch (this.style) {
  70. case Style.AllFriend:
  71. this.allFriendNode.active = true;
  72. this.friendInfoNode.active = false;
  73. this.talentNode.active = false;
  74. this.itemBg.active = false;
  75. this.noticeNode.active = false
  76. break;
  77. case Style.Friend:
  78. this.friendInfoNode.active = true;
  79. this.allFriendNode.active = false;
  80. this.talentNode.active = false;
  81. this.identityNode.active = false;
  82. this.itemBg.active = true;
  83. break;
  84. case Style.Invite:
  85. this.friendInfoNode.active = false;
  86. this.allFriendNode.active = false;
  87. this.talentNode.active = false;
  88. this.itemBg.active = true;
  89. this.noticeNode.active = false
  90. break;
  91. case Style.Talent:
  92. this.friendInfoNode.active = false;
  93. this.allFriendNode.active = false;
  94. this.talentNode.active = true;
  95. this.itemBg.active = false;
  96. this.noticeNode.active = false
  97. break;
  98. case Style.Artist:
  99. this.friendInfoNode.active = true;
  100. this.allFriendNode.active = false;
  101. this.talentNode.active = false;
  102. this.identityNode.active = true;
  103. this.itemBg.active = true;
  104. this.noticeNode.active = false
  105. break;
  106. default:
  107. break;
  108. }
  109. },
  110. // update (dt) {},
  111. });