ShareDialog.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var wechat = require('../net/WeChat');
  2. var Api = require('../net/Api');
  3. const ShareAction = require('../utils/ShareAction');
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. transparentBg: cc.Node,
  8. view: cc.Node,
  9. bg: cc.Node,
  10. titleLabel: cc.Label,
  11. closeNode: cc.Node,
  12. messageLabel: cc.Label,
  13. picSprite: cc.Sprite,
  14. button: cc.Node,
  15. buttonText: cc.RichText,
  16. },
  17. // LIFE-CYCLE CALLBACKS:
  18. onLoad() {
  19. // this.transparentBg.on(cc.Node.EventType.TOUCH_START, () => {
  20. // this.dissmiss();
  21. // }, this);
  22. this.closeNode.on(cc.Node.EventType.TOUCH_END, () => {
  23. this.dissmiss();
  24. }, this);
  25. this.button.on(cc.Node.EventType.TOUCH_END, () => {
  26. wechat.inviteFriend(this.shareAction);
  27. this.node.destroy();
  28. }, this);
  29. Api.createImageFromUrl('http://img.mp.itc.cn/upload/20160524/522ac3b5f4a04d97b9265099adb0ba79_th.jpg', (spriteFrame) => {
  30. this.picSprite.spriteFrame = spriteFrame;
  31. });
  32. },
  33. start() {
  34. this.view.scaleX = 0;
  35. this.view.scaleY = 0;
  36. this.view.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
  37. },
  38. dissmiss() {
  39. let finish = cc.callFunc(() => {
  40. this.node.destroy();
  41. }, this);
  42. let sq = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
  43. this.view.runAction(sq);
  44. },
  45. showTalent() {
  46. this.shareAction = ShareAction.BECOME_ARTIST;
  47. this.titleLabel.string = '派出星探';
  48. this.messageLabel.string = '派出你的星探,为你免费寻找艺人。';
  49. this.buttonText.string = '<outline color=#55000000><b>派出</b></outline>';
  50. },
  51. showInviteFriend() {
  52. this.shareAction = ShareAction.ADD_FRIEND;
  53. this.titleLabel.string = '添加好友';
  54. this.messageLabel.string = '发送微信链接给你的微信好友即可添加为游戏好友。';
  55. this.buttonText.string = '<outline color=#55000000><b>邀请</b></outline>';
  56. },
  57. });