WithdrawalNode.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { utils } from "./Utils";
  2. import { SubLocation } from "./YZ_Constant";
  3. import PlatUtils from "./PlatUtils";
  4. import CompatibleTool from "./CompatibleTool";
  5. const { ccclass, property } = cc._decorator;
  6. @ccclass
  7. export default class WithdrawalNode extends cc.Component {
  8. balanceLbl: cc.Label = null;
  9. onLoad() {
  10. this.balanceLbl = this.node.getComponentInChildren(cc.Label)
  11. }
  12. public init(data?: any) {
  13. if (utils.yzRedBagInfo.balance > 0) {
  14. this.balanceLbl.string = `¥${utils.yzRedBagInfo.balance}`
  15. } else {
  16. this.balanceLbl.string = `¥0.00`
  17. }
  18. }
  19. showWithdrawalPanel() {
  20. utils.SendEvent("红包提现框-点击提现按钮!");
  21. utils.showWithdrawalPanel();
  22. }
  23. onEnable() {
  24. utils.SendEvent("红包提现框-展示成功!");
  25. this.init();
  26. cc.game.on("YZ_RED_BAG_BALANCE_CHANGE", () => {
  27. this.init();
  28. }, this);
  29. }
  30. onDisable() {
  31. this.unscheduleAllCallbacks();
  32. this.node.targetOff(this);
  33. cc.game.targetOff(this);
  34. }
  35. }