CashWithdrawalView.ts 4.1 KB

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