ShenTaiWindow.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { _decorator, Component, Node, Label } from 'cc';
  2. import { Http } from '../../core/net/Http';
  3. import { WindowManager } from '../../core/ui/window/WindowManager';
  4. import { ConfigData } from '../../Data/ConfigData';
  5. import { g } from '../../Data/g';
  6. import { platform } from '../../Data/platform';
  7. import { FsUtils } from '../../FsUtils/FsUtils';
  8. import { ShenTaiRoleGroup } from './ShenTaiRoleGroup';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('ShenTaiWindow')
  11. export class ShenTaiWindow extends Component {
  12. // @property({ type: ProgressBar, tooltip: "等级宝箱奖励进度" }) boxGiftProgress: ProgressBar;
  13. // @property({ type: ProgressBar, tooltip: "红包领取进度" }) redPacketProgress: ProgressBar;
  14. @property({ type: Http, tooltip: "消息控制" })
  15. http: Http;
  16. @property({ type: [Node], tooltip: "好友子节组" })
  17. roleGroup: Node[] = [];
  18. @property({ type: Label, tooltip: "贡献文本" })
  19. contributionLabel: Label;
  20. @property({ type: Label, tooltip: "可提现文本" })
  21. cashLabel: Label;
  22. private contribution: number = -1;
  23. start() {
  24. g.gameData.playAddMoneySound = false;
  25. this.onOpenHandler();
  26. }
  27. update() {
  28. if (this.contribution != g.userData.contribution) {
  29. this.contributionLabel.string = g.userData.contribution + '';
  30. this.cashLabel.string = '约' + FsUtils.toFixed(g.userData.contribution / ConfigData.configMap.get("systemConfig").moneyRate, 2) + '元';
  31. }
  32. }
  33. private onOpenHandler() {
  34. g.gameData.hasG1BembersUpdate = true;
  35. g.gameData.hasG2BembersUpdate = true;
  36. g.gameData.hasG3BembersUpdate = true;
  37. g.gameData.hasG4BembersUpdate = true;
  38. g.gameData.hasG5BembersUpdate = true;
  39. }
  40. public onOpenUserInfo() {
  41. console.log("onOpenUserInfo");
  42. //this.http.send("",{});
  43. // WindowManager.open("Prefabs/Windows/FriendInfoWindow", WindowOpenMode.CloseAndCover, []);
  44. }
  45. /**一键领取 */
  46. public async onGetButton() {
  47. if (g.gameData.getAllRevenueAmount()) {
  48. let result = await this.http.send("/api/fission/ReceiveFission", { receiveUserID: 0 });
  49. if (!result.code) {//
  50. g.userData.contribution += result.data.addTotalContribution;
  51. WindowManager.showTips('贡献领取成功');
  52. g.gameData.clearRevenue();
  53. this.onOpenHandler();
  54. }
  55. } else {
  56. WindowManager.showTips("当前没有贡献可领取!");
  57. }
  58. }
  59. //邀请
  60. public async onInvite() {
  61. let result = await this.http.send("/api/app/share", {});
  62. if (result.code == 0) {
  63. platform.wxShare(result.data.url, result.data.title, result.data.descroption);
  64. } else {
  65. WindowManager.showTips("分享信息获取失败,请稍后再试");
  66. }
  67. }
  68. onDestroy() {
  69. g.gameData.playAddMoneySound = true;
  70. }
  71. }