UIFirstPack.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { AppKernel } from '@scripts/app/AppKernel';
  2. import { UIPopup } from '@scripts/framework/ui/UIPopup';
  3. import { IFirstPack } from '@scripts/store/payStore/data';
  4. import { formatGCNum, formatSCNum } from '@scripts/utils/Helper';
  5. import { addBtnClick } from '@scripts/utils/UIHelper';
  6. import { formatVip } from '@scripts/utils/VipHelper';
  7. import { _decorator, Button, Component, Label, Node } from 'cc';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('UIFirstPack')
  10. export class UIFirstPack extends UIPopup {
  11. @property(Label)
  12. lblGC: Label;
  13. @property(Label)
  14. lblSC: Label;
  15. @property(Label)
  16. lblVIP: Label;
  17. @property(Label)
  18. lblButton: Label;
  19. @property(Button)
  20. btnClose: Button;
  21. @property(Button)
  22. btnPay: Button;
  23. private _packInfo: IFirstPack;
  24. protected onCreate(): void | Promise<void> {
  25. addBtnClick(this.btnClose, this.closeSelf, this);
  26. addBtnClick(this.btnPay, this.onBtnPayClick, this);
  27. }
  28. protected async onBeforeOpen(_params: unknown) {
  29. const payStore = AppKernel.stores.payStore;
  30. const pack = await payStore.reqFirstPackInfo();
  31. this._packInfo = pack;
  32. return !!pack;
  33. }
  34. private onBtnPayClick() {
  35. }
  36. protected onOpen(_params: unknown): void | Promise<void> {
  37. if (!this._packInfo) {
  38. this.lblGC.string = "";
  39. this.lblSC.string = "";
  40. this.lblVIP.string = "";
  41. return;
  42. }
  43. const next_sequence = this._packInfo.next_sequence;
  44. const current = next_sequence - 1;
  45. const data = this._packInfo.list[current];
  46. this.lblGC.string = formatGCNum(data.gc);
  47. this.lblSC.string = formatSCNum(data.sc);
  48. this.lblVIP.string = data.cp.toString();
  49. this.lblButton.string = AppKernel.i18n.t("store.buynow", Number(data.money));
  50. }
  51. }