WalletPagePOG.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { _decorator, Component, Node, Event } from "cc";
  2. import BaseUI from "../../scripts/base/BaseUI";
  3. import { Tips } from "../../scripts/mgr/Tips";
  4. import UserM from "../../scripts/api/UserM";
  5. import { GoodsId } from "../../scripts/api/GoodsId";
  6. import Utils from "../../scripts/utils/Utils";
  7. import ConfigM from "../../scripts/api/ConfigM";
  8. import WalletM, { PogHomeDto } from "../../scripts/api/WalletM";
  9. import { TipsData, TipsLayer } from "../layer/TipsLayer";
  10. import { Label } from "cc";
  11. import { Hall } from "../hall/Hall";
  12. import { PageShop } from "../hall/PageShop";
  13. import { CommonTabsTitle } from "../common/CommonTabsTitle";
  14. const { ccclass, property } = _decorator;
  15. @ccclass("WalletPagePOG")
  16. export class WalletPagePOG extends BaseUI {
  17. protected onLoad(): void {
  18. super.onLoad();
  19. this.initTitles();
  20. }
  21. initTitles() {
  22. // this.setText("lbl_my_assets_title", Utils.setI18nLabel("Wallet.MyAssets"));
  23. this.setText("lbl_pog_tips", Utils.setI18nLabel("Wallet.POGDesc"));
  24. this.setText(
  25. "lbl_booster_title",
  26. Utils.setI18nLabel("Wallet.CurrentPOGBoosterTitle")
  27. );
  28. this.setText(
  29. "lbl_game_pass_desc",
  30. Utils.setI18nLabel("Wallet.GamePassDesc")
  31. );
  32. this.setText(
  33. "lbl_game_pass_tips",
  34. Utils.setI18nLabel("Wallet.GamePassTips")
  35. );
  36. this.setText("lbl_rank_tips", Utils.setI18nLabel("Wallet.RankTips"));
  37. this.setText(
  38. "lbl_game_pass_tips",
  39. Utils.setI18nLabel("Wallet.GamePassTips")
  40. );
  41. }
  42. public onShow(): void {
  43. this.init();
  44. }
  45. async init() {
  46. let data: PogHomeDto = await WalletM.ins.pogHome();
  47. // let gradeName = UserM.ins.getGradeName();
  48. // let my_rank_desc = Utils.setI18nLabel(
  49. // "Wallet.MyRankDesc",
  50. // "" + gradeName,
  51. // "" + data.booster.seasonRank
  52. // );
  53. // this.setText("lbl_my_rank", my_rank_desc);
  54. this.setText(
  55. "lbl_booster_desc",
  56. Utils.setI18nLabel(
  57. "Wallet.TotalBoosterValue",
  58. "" + data.booster.rankAddition
  59. )
  60. );
  61. this.FindNode("i_up_rank")
  62. .getChildByName("value")
  63. .getComponent(Label).string = data.booster.totalRank + "%";
  64. this.setText("lbl_pog_balance", UserM.ins.getPogDisplay());
  65. this.setText("lbl_tog_balance", UserM.ins.getTogDisplay());
  66. this.setText(
  67. "lbl_game_pass",
  68. "Game Pass x" + "" + data.booster.gamePassNum
  69. );
  70. this.FindNode("i_up_game_pass")
  71. .getChildByName("value")
  72. .getComponent(Label).string = data.booster.gamePassAddition + "%";
  73. // this.SetSprite(
  74. // "icon_my_grade",
  75. // "texture/common/grade" + UserM.ins.getGrade() + ""
  76. // );
  77. this.setText(
  78. "lbl_tip_how_earn_pog",
  79. Utils.setI18nLabel("Wallet.HowToEarnPOGTitle")
  80. );
  81. this.setText(
  82. "lbl_how_earn_pog_1",
  83. Utils.setI18nLabel("Wallet.HowToEarnPOG1")
  84. );
  85. this.setText(
  86. "lbl_how_earn_pog_2",
  87. Utils.setI18nLabel("Wallet.HowToEarnPOG2")
  88. );
  89. this.setText(
  90. "lbl_how_earn_pog_3",
  91. Utils.setI18nLabel("Wallet.HowToEarnPOG3")
  92. );
  93. this.setText(
  94. "lbl_how_earn_pog_4",
  95. Utils.setI18nLabel("Wallet.HowToEarnPOG4")
  96. );
  97. }
  98. protected async simpleOnBtnClick(name: string) {
  99. switch (name) {
  100. case "btn_history":
  101. Tips.show("POG History Coming Soon");
  102. break;
  103. case "btn_utility":
  104. let data = TipsLayer.build(Utils.setI18nLabel("Wallet.POGUtilityDesc"));
  105. data.title = "";
  106. data.forceConfirm = true;
  107. data.show();
  108. break;
  109. case "btn_go_1":
  110. await Hall.ins.switchPage(Hall.PagePlay);
  111. break;
  112. case "btn_go_2":
  113. this.jumpToPogShop();
  114. break;
  115. case "btn_go_3":
  116. Tips.show("Coming Soon");
  117. break;
  118. case "btn_go_4":
  119. this.jumpToPogShop();
  120. break;
  121. }
  122. }
  123. async jumpToPogShop() {
  124. let shopPageNode = await Hall.ins.switchPage(Hall.PageShop);
  125. let shop = shopPageNode.getComponent(PageShop);
  126. if (
  127. shop.getComponentInChildren(CommonTabsTitle).selectIndex ==
  128. PageShop.TAB_POG_BOX.index
  129. ) {
  130. return;
  131. }
  132. setTimeout(() => {
  133. shopPageNode.getComponent(PageShop).switchTab(PageShop.TAB_POG_BOX);
  134. }, 300);
  135. }
  136. }