ShareDialog.js 2.0 KB

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