TalentMission.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var TalentApi = require('../net/TalentApi');
  2. const wechat = require('../net/WeChat');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. contentNode: cc.Node,
  7. invitedPrefab: cc.Prefab,
  8. invitedScrollViewNode: cc.ScrollView,
  9. listScrollViewNode: cc.ScrollView,
  10. missionPrefab: cc.Prefab,
  11. },
  12. // LIFE-CYCLE CALLBACKS:
  13. onLoad () {
  14. },
  15. start () {
  16. },
  17. onDisable() {
  18. for (let child of this.invitedScrollViewNode.content.children) {
  19. child.destroy();
  20. }
  21. for (let child of this.listScrollViewNode.content.children) {
  22. child.destroy();
  23. }
  24. },
  25. // update (dt) {},
  26. init() {
  27. this.node.parent = cc.find('Canvas');
  28. this.node.active = true;
  29. this.contentNode.y = -cc.view.getVisibleSize().height;
  30. this.contentNode.runAction(cc.moveTo(0.2, 0, 0).easing(cc.easeCubicActionOut()));
  31. this.layout();
  32. },
  33. closeNode() {
  34. let finish = cc.callFunc(() => {
  35. this.node.active = false;
  36. }, this);
  37. this.contentNode.runAction(cc.sequence(cc.moveTo(0.2, 0, -cc.view.getVisibleSize().height).easing(cc.easeCubicActionIn()), finish));
  38. },
  39. layout() {
  40. for (var i = 0; i < 10; i++) {
  41. let item = cc.instantiate(this.invitedPrefab);
  42. item = item.getComponent('TalentInvitedItem');
  43. item.node.parent = this.invitedScrollViewNode.content;
  44. }
  45. for (var i = 0; i < 10; i++) {
  46. let item = cc.instantiate(this.missionPrefab);
  47. item = item.getComponent('TalentInviteMissionItem');
  48. item.node.parent = this.listScrollViewNode.content;
  49. item.node.width = this.listScrollViewNode.node._contentSize.width;
  50. }
  51. },
  52. inviteArtist() {
  53. wechat.inviteFriend(ShareAction.BECOME_ARTIST);
  54. },
  55. });