CashWithdrawalView.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. console.log(">>>>>>>>>>>金钱数量", num)
  41. if (num > 0) {
  42. if (this.lab_cashNum) {
  43. this.lab_cashNum.string = `¥${num}`;
  44. //正则替换$m为num
  45. this.lab_tips.string = this.lab_tips.string.replace(/\$m/g, `${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. // 创建中间变量对象
  68. console.log("显示加载")
  69. const progressObj = { value: 0 };
  70. tween(progressObj)
  71. .to(2, { value: 1 }, {
  72. onUpdate: (target) => {
  73. this.loadProgressBar.progress = target.value;
  74. },
  75. easing: 'linear' // 匀速,也可以换成 'quadIn', 'cubicOut' 等
  76. })
  77. .call(() => {
  78. this.loadNode.active = false;
  79. if (this.mainNode) {
  80. this.mainNode.active = true;
  81. this.showAnimation();
  82. }
  83. })
  84. .start();
  85. }
  86. }
  87. showAnimation() {
  88. if (this.mainNode) {
  89. const aniNode = this.mainNode.getChildByPath("Bg/Mask");
  90. if (aniNode) {
  91. const animationComponent = aniNode.getComponent(Animation);
  92. if (animationComponent) {
  93. animationComponent.play();
  94. }
  95. }
  96. }
  97. }
  98. async btn_continue() {
  99. //打开提现返利界面--判断从哪打开如果从红包币那打开就只是关闭
  100. if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
  101. const type = smc.game.GameModel.txType;
  102. if (type == 1) {
  103. ServerHandler.inst.getTxbfInfo();
  104. }
  105. oops.gui.remove(UIID.WithSussce);
  106. } else {
  107. //
  108. await oops.gui.open(UIID.CashRebate);
  109. oops.gui.remove(UIID.WithSussce);
  110. }
  111. }
  112. protected onDestroy(): void {
  113. this.mainNode.active = false;
  114. this.loadNode.active = false;
  115. }
  116. }