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