CashWithdrawalView.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. this.setButton();
  36. this.setData();
  37. }
  38. setData() {
  39. this.mainNode.active = false;
  40. this.loadNode.active = false;
  41. const num = smc.game.GameModel.txNum;
  42. if (num > 0) {
  43. if (this.lab_cashNum) {
  44. this.lab_cashNum.string = `¥${Format.formatRedPacketCoin(num)}`;
  45. //正则替换$m为num
  46. this.lab_tips.string = this.lab_tips.string.replace(/\$m/g, `${Format.formatRedPacketCoin(num)}`);
  47. }
  48. }
  49. let eventType = smc.game.GameModel.eventType; //用来判断要不要显示加载进度条
  50. if (eventType) {
  51. if (eventType == "WITHDRAW_POINT" && smc.game.GameModel.txType == 1) {
  52. this.showLoad();
  53. } else {
  54. this.loadNode.active = false;
  55. this.mainNode.active = true;
  56. this.showAnimation();
  57. }
  58. } else {
  59. this.loadNode.active = false;
  60. this.mainNode.active = true;
  61. this.showAnimation();
  62. }
  63. }
  64. showLoad() {
  65. if (this.loadNode && this.loadProgressBar) {
  66. this.loadProgressBar.progress = 0;
  67. this.loadNode.active = true;
  68. const progressObj = { value: 0 };
  69. tween(progressObj)
  70. .to(2, { value: 1 }, {
  71. onUpdate: (target) => {
  72. this.loadProgressBar.progress = target.value;
  73. },
  74. easing: 'linear' // 匀速,也可以换成 'quadIn', 'cubicOut' 等
  75. })
  76. .call(() => {
  77. this.loadNode.active = false;
  78. if (this.mainNode) {
  79. this.mainNode.active = true;
  80. this.showAnimation();
  81. }
  82. })
  83. .start();
  84. }
  85. }
  86. showAnimation() {
  87. if (this.mainNode) {
  88. const aniNode = this.mainNode.getChildByPath("Bg/Mask");
  89. if (aniNode) {
  90. const animationComponent = aniNode.getComponent(Animation);
  91. if (animationComponent) {
  92. animationComponent.play();
  93. }
  94. }
  95. }
  96. }
  97. async btn_continue() {
  98. //打开提现返利界面--判断从哪打开如果从红包币那打开就只是关闭
  99. if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
  100. const type = smc.game.GameModel.txType;
  101. if (type == 1) {
  102. ServerHandler.inst.getTxbfInfo();
  103. }
  104. oops.gui.remove(UIID.WithSussce);
  105. DCHandler.inst.reportData(3000701);
  106. } else {
  107. await oops.gui.open(UIID.CashRebate);
  108. oops.gui.remove(UIID.WithSussce);
  109. }
  110. }
  111. protected onDestroy(): void {
  112. this.mainNode.active = false;
  113. this.loadNode.active = false;
  114. }
  115. }