LevelHomeFriendItem.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. GameEvent.fire(NotiKey.ShowUserInfomation, this.info.uid);
  48. }, 1000, true), this);
  49. break;
  50. // case Style.Artist:
  51. // this.friendInfoNode.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
  52. // GameEvent.fire(NotiKey.ShowUserInfomation, this.info.uid);
  53. // }, 1000, true), this);
  54. // break;
  55. // case Style.Talent:
  56. // this.talentNode.on(cc.Node.EventType.TOUCH_END, function () {
  57. // cc.loader.loadRes('/prefabs/talent_mission', cc.Prefab, (error, prefab) => {
  58. // if (error === null) {
  59. // let mission = cc.instantiate(prefab);
  60. // mission = mission.getComponent('TalentMission');
  61. // mission.init();
  62. // } else {
  63. // console.log(JSON.stringify(error));
  64. // }
  65. // });
  66. // }, this);
  67. // break;
  68. }
  69. },
  70. setFriendInfo(info) {
  71. this.info = info;
  72. this.starsLabel.string = info.stars;
  73. this.nickLabel.string = info.nick;
  74. Api.createImageFromUrl(info.head, (spriteFrame) => {
  75. this.headSprite.spriteFrame = spriteFrame;
  76. }, null);
  77. if (info.role === 1) { // 我的老板
  78. this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[0];
  79. } else if(info.role == 2) { // 我的艺人
  80. this.identityNode.getComponent(cc.Sprite).spriteFrame = this.identitySpriteFrames[1];
  81. } else {
  82. this.identityNode.active = false;
  83. }
  84. // 显示消息提示节点
  85. // if (this.style === Style.Friend && info.isStationed) {
  86. // this.noticeNode.active = true
  87. // } else {
  88. // this.noticeNode.active = false
  89. // }
  90. },
  91. layout() {
  92. switch (this.style) {
  93. case Style.AllFriend:
  94. this.allFriendNode.active = true;
  95. this.friendInfoNode.active = false;
  96. this.talentNode.active = false;
  97. this.itemBg.active = false;
  98. // this.noticeNode.active = false
  99. break;
  100. case Style.Friend:
  101. this.friendInfoNode.active = true;
  102. this.allFriendNode.active = false;
  103. this.talentNode.active = false;
  104. this.identityNode.active = true;
  105. // this.itemBg.active = true;
  106. break;
  107. case Style.Invite:
  108. this.friendInfoNode.active = false;
  109. this.allFriendNode.active = false;
  110. this.talentNode.active = false;
  111. this.itemBg.active = true;
  112. // this.noticeNode.active = false
  113. break;
  114. case Style.Talent:
  115. this.friendInfoNode.active = false;
  116. this.allFriendNode.active = false;
  117. this.talentNode.active = true;
  118. this.itemBg.active = false;
  119. // this.noticeNode.active = false
  120. break;
  121. case Style.Artist:
  122. this.friendInfoNode.active = true;
  123. this.allFriendNode.active = false;
  124. this.talentNode.active = false;
  125. this.identityNode.active = true;
  126. this.itemBg.active = true;
  127. // this.noticeNode.active = false
  128. break;
  129. default:
  130. break;
  131. }
  132. },
  133. // update (dt) {},
  134. });