CashWithdrawalView.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-03-21 15:03:37
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-23 17:45:40
  6. * @Description: 微信提现到零钱,需要有一个动画展示步骤
  7. */
  8. import { _decorator, Node, Animation } from 'cc';
  9. import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil';
  10. import { GameComponent } from "db://oops-framework/module/common/GameComponent";
  11. import { ServerHandler } from '../common/manager/ServerHandler';
  12. import { oops } from 'db://oops-framework/core/Oops';
  13. import { UIID } from '../common/config/GameUIConfig';
  14. import { Label } from 'cc';
  15. import { ProgressBar } from 'cc';
  16. import { tween } from 'cc';
  17. import { smc } from '../common/SingletonModuleComp';
  18. import { Format } from '../utils/Format';
  19. import { DCHandler } from '../common/manager/DCHandler';
  20. const { ccclass, property } = _decorator;
  21. /** 显示对象控制 */
  22. @ccclass('CashWithdrawalView')
  23. export class CashWithdrawalView extends GameComponent {
  24. @property(Label)
  25. lab_cashNum: Label = null!;
  26. @property(Label)
  27. lab_tips: Label = null!;
  28. @property(Node)
  29. private loadNode: Node = null!;
  30. @property(Node)
  31. private mainNode: Node = null!
  32. @property(ProgressBar)
  33. private loadProgressBar: ProgressBar = null!;
  34. protected start() {
  35. DCHandler.inst.reportData(3000700);
  36. this.setButton();
  37. this.setData();
  38. }
  39. setData() {
  40. const curLevel = smc.account.AccountModel.curLevel;
  41. DCHandler.inst.reportData(3000101, curLevel);
  42. this.mainNode.active = false;
  43. this.loadNode.active = false;
  44. const num = smc.game.GameModel.txNum;
  45. if (num > 0) {
  46. if (this.lab_cashNum) {
  47. this.lab_cashNum.string = `¥${Format.formatRedPacketCoin(num)}`;
  48. //正则替换$m为num
  49. this.lab_tips.string = this.lab_tips.string.replace(/\$m/g, `${Format.formatRedPacketCoin(num)}`);
  50. }
  51. }
  52. let eventType = smc.game.GameModel.eventType; //用来判断要不要显示加载进度条
  53. if (eventType) {
  54. if (eventType == "WITHDRAW_POINT" && smc.game.GameModel.txType == 1) {
  55. this.showLoad();
  56. } else {
  57. this.loadNode.active = false;
  58. this.mainNode.active = true;
  59. this.showAnimation();
  60. }
  61. } else {
  62. this.loadNode.active = false;
  63. this.mainNode.active = true;
  64. this.showAnimation();
  65. }
  66. }
  67. showLoad() {
  68. if (this.loadNode && this.loadProgressBar) {
  69. this.loadProgressBar.progress = 0;
  70. this.loadNode.active = true;
  71. const progressObj = { value: 0 };
  72. tween(progressObj)
  73. .to(2, { value: 1 }, {
  74. onUpdate: (target) => {
  75. this.loadProgressBar.progress = target.value;
  76. },
  77. easing: 'linear' // 匀速,也可以换成 'quadIn', 'cubicOut' 等
  78. })
  79. .call(() => {
  80. this.loadNode.active = false;
  81. if (this.mainNode) {
  82. this.mainNode.active = true;
  83. this.showAnimation();
  84. }
  85. })
  86. .start();
  87. }
  88. }
  89. showAnimation() {
  90. if (this.mainNode) {
  91. const aniNode = this.mainNode.getChildByPath("Bg/Mask");
  92. if (aniNode) {
  93. const animationComponent = aniNode.getComponent(Animation);
  94. if (animationComponent) {
  95. animationComponent.play();
  96. }
  97. }
  98. }
  99. }
  100. async btn_continue() {
  101. //打开提现返利界面--判断从哪打开如果从红包币那打开就只是关闭
  102. if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
  103. const type = smc.game.GameModel.txType;
  104. if (type == 1) {
  105. ServerHandler.inst.getTxbfInfo();
  106. }
  107. oops.gui.remove(UIID.WithSussce);
  108. DCHandler.inst.reportData(3000701);
  109. } else {
  110. await oops.gui.open(UIID.CashRebate);
  111. oops.gui.remove(UIID.WithSussce);
  112. }
  113. }
  114. protected onDestroy(): void {
  115. this.mainNode.active = false;
  116. this.loadNode.active = false;
  117. }
  118. }