ShareAlertWindow.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { _decorator, Component, Button, Node } from 'cc';
  2. import { Http } from '../../core/net/Http';
  3. import { WindowManager } from '../../core/ui/window/WindowManager';
  4. import { g } from '../../Data/g';
  5. import { platform } from '../../Data/platform';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('ShareAlertWindow')
  8. export class ShareAlertWindow extends Component {
  9. @property({ type: Http, tooltip: "http组件" }) http: Http;
  10. @property({ type: Node, tooltip: "立即邀请按钮" }) inviteButton: Node;
  11. @property({ type: Node, tooltip: "邀请文字" }) inviteByte: Node;
  12. public async onInviteButton() {
  13. let result = await this.http.send("/api/app/share", {});
  14. if (result.code == 0) {
  15. platform.wxShare(result.data.url, result.data.title, result.data.descroption);
  16. } else {
  17. WindowManager.showTips("分享信息获取失败,请稍后再试");
  18. }
  19. }
  20. update() {
  21. if (g.wechatData.shareSuccess) {
  22. g.wechatData.shareSuccess = false;
  23. this.shareComplete();
  24. }
  25. }
  26. private async shareComplete() {
  27. WindowManager.close(this.node);
  28. }
  29. }