FriendHelpClick.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. const WeChat = require('../net/WeChat');
  2. const AlertManager = require('../utils/AlertManager');
  3. const GameModule = require("../utils/GameModule");
  4. const { GameNotificationKey, WechatShareType } = require('../utils/GameEnum');
  5. const InviteApi = require('../net/InviteApi');
  6. cc.Class({
  7. extends: cc.Component,
  8. properties: {
  9. itemPrefab: cc.Prefab,
  10. listScrollViewNode: cc.ScrollView,
  11. shareButtonNode: cc.Node
  12. },
  13. // LIFE-CYCLE CALLBACKS:
  14. onLoad () {
  15. },
  16. start () {
  17. let scaleAction1 = cc.scaleTo(0.6, 1.1, 1.1);
  18. let scaleAction2 = cc.scaleTo(0.6, 0.8, 0.8);
  19. let seq = cc.repeatForever(cc.sequence(scaleAction1, scaleAction2));
  20. this.shareButtonNode.runAction(seq);
  21. this.getNetworkData();
  22. },
  23. getNetworkData() {
  24. InviteApi.getFriendRewardList((responseData) => {
  25. this.configData(responseData);
  26. }, (error) => {
  27. console.log('mission error' + error);
  28. });
  29. },
  30. configData(responseData) {
  31. this.list = responseData.list;
  32. for (var i = 0; i < this.list.length; i++) {
  33. let model = this.list[i];
  34. let item = cc.instantiate(this.itemPrefab);
  35. item = item.getComponent('FriendHelpItem');
  36. item.node.width = this.listScrollViewNode.node._contentSize.width;
  37. item.node.parent = this.listScrollViewNode.content;
  38. item.configData(model);
  39. }
  40. },
  41. closeNode() {
  42. GameModule.audioMng.playClickButton();
  43. this.node.destroy();
  44. },
  45. inviteFriend() {
  46. GameModule.audioMng.playClickButton();
  47. WeChat.shareAction(WechatShareType.InviteFriend, () => {
  48. }, () => {
  49. console.log('分享失败或取消');
  50. });
  51. Global.isIgnoreShareStatus = true;
  52. },
  53. // update (dt) {},
  54. });