Withdrawal.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. const { ccclass, property } = _decorator;
  9. /**神台提现面板 */
  10. @ccclass('Withdrawal')
  11. export class Withdrawal extends Component {
  12. @property({ tooltip: "可提现余额", type: Label })
  13. public moneyLabel: Label;
  14. @property({ type: Http, tooltip: "消息控制" })
  15. http: Http;
  16. private contribution: number = -1;
  17. private systemConfig;
  18. start() {
  19. this.systemConfig = ConfigData.configMap.get("systemConfig");
  20. }
  21. update() {
  22. if (this.contribution != g.userData.contribution) {
  23. this.moneyLabel.string = FsUtils.toFixed(g.userData.contribution / ConfigData.configMap.get("systemConfig").moneyRate, 2);
  24. }
  25. }
  26. /**
  27. * 贡献提现
  28. */
  29. public async onWithdrawal() {
  30. if (g.userData.contribution < this.systemConfig.minWithdraw) {
  31. WindowManager.showTips(g.CodeMsg[119]);
  32. return;
  33. }
  34. let result = await this.http.send("/api/wealth/Withdraw", { type: 1 });
  35. g.gameData.hasNewwithdrawalLog = true;
  36. if (result.code && result.code > 0) {
  37. WindowManager.showTips(g.CodeMsg[result.code]);
  38. } else {
  39. if (result.message) {
  40. WindowManager.showTips(result.message);
  41. }
  42. else {
  43. platform.volcanicReport('withdrawForContribution');
  44. WindowManager.showTips("提现成功,72小时内到账");
  45. g.userData.contribution = 0;
  46. }
  47. }
  48. }
  49. }