LevelHomeFriendItem.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.setEvent();
  30. this.layout();
  31. }
  32. },
  33. },
  34. // LIFE-CYCLE CALLBACKS:
  35. onLoad() {
  36. },
  37. setEvent() {
  38. switch (this.style) {
  39. case Style.AllFriend:
  40. this.allFriendNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  41. GameEvent.fire(NotiKey.ShowFriendSystem);
  42. }, 1000, true), this);
  43. break;
  44. case Style.Friend:
  45. this.friendInfoNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  46. GameEvent.fire(NotiKey.VisitFriendHome, this.info.uid);
  47. }, 1000, true), this);
  48. break;
  49. case Style.Artist:
  50. this.friendInfoNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  51. GameEvent.fire(NotiKey.ShowUserInfomation, this.info.uid);
  52. }, 1000, true), this);
  53. break;
  54. case Style.Talent:
  55. this.talentNode.on(cc.Node.EventType.TOUCH_END, function () {
  56. AlertManager.showTalentAlert();
  57. }, this);
  58. break;
  59. }
  60. },
  61. setFriendInfo(info) {
  62. this.info = info;
  63. this.starsLabel.string = info.stars;
  64. this.nickLabel.string = info.nick;
  65. Api.createImageFromUrl(info.head, (spriteFrame) => {
  66. this.headSprite.spriteFrame = spriteFrame;
  67. }, null);
  68. if (info.role === 1) { // 我的老板
  69. this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[0];
  70. } else { // 我的艺人
  71. this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[1];
  72. }
  73. // 显示消息提示节点
  74. if (this.style === Style.Friend && info.isStationed) {
  75. this.noticeNode.active = true
  76. } else {
  77. this.noticeNode.active = false
  78. }
  79. },
  80. layout() {
  81. switch (this.style) {
  82. case Style.AllFriend:
  83. this.allFriendNode.active = true;
  84. this.friendInfoNode.active = false;
  85. this.talentNode.active = false;
  86. this.itemBg.active = false;
  87. this.noticeNode.active = false
  88. break;
  89. case Style.Friend:
  90. this.friendInfoNode.active = true;
  91. this.allFriendNode.active = false;
  92. this.talentNode.active = false;
  93. this.identityNode.active = false;
  94. this.itemBg.active = true;
  95. break;
  96. case Style.Invite:
  97. this.friendInfoNode.active = false;
  98. this.allFriendNode.active = false;
  99. this.talentNode.active = false;
  100. this.itemBg.active = true;
  101. this.noticeNode.active = false
  102. break;
  103. case Style.Talent:
  104. this.friendInfoNode.active = false;
  105. this.allFriendNode.active = false;
  106. this.talentNode.active = true;
  107. this.itemBg.active = false;
  108. this.noticeNode.active = false
  109. break;
  110. case Style.Artist:
  111. this.friendInfoNode.active = true;
  112. this.allFriendNode.active = false;
  113. this.talentNode.active = false;
  114. this.identityNode.active = true;
  115. this.itemBg.active = true;
  116. this.noticeNode.active = false
  117. break;
  118. default:
  119. break;
  120. }
  121. },
  122. // update (dt) {},
  123. });