LevelHomeFriendItem.js 5.3 KB

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