InvitedItem.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const Api = require('../net/Api');
  2. const ShareAction = require('../utils/ShareAction');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. inviteNode: cc.Node,
  7. avatarNode: cc.Node,
  8. avatarSprite: cc.Sprite,
  9. hasUser: {
  10. get: function () {
  11. if (!this._hasUser) {
  12. this._hasUser = false;
  13. }
  14. return this._hasUser;
  15. },
  16. set: function (value) {
  17. this._hasUser = value;
  18. if (this._hasUser) {
  19. this.inviteNode.active = false;
  20. this.avatarNode.active = true;
  21. } else {
  22. this.inviteNode.active = true;
  23. this.avatarNode.active = false;
  24. }
  25. }
  26. },
  27. },
  28. // LIFE-CYCLE CALLBACKS:
  29. onLoad() {
  30. },
  31. start() {
  32. },
  33. onDisable() {
  34. this.hasUser = false;
  35. },
  36. configData(userData) {
  37. this.hasUser = true;
  38. // if (userData.head) {
  39. Api.createImageFromUrl(userData.head, (spriteFrame) => {
  40. this.avatarSprite.spriteFrame = spriteFrame;
  41. });
  42. // } else {
  43. // this.avatarSprite.spriteFrame = null;
  44. // }
  45. },
  46. // update (dt) {},
  47. });