UIPayoutConfrim.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { AppKernel } from '@scripts/app/AppKernel';
  2. import { CURRENCY_TYPE } from '@scripts/define/Define';
  3. import { PayoutType } from '@scripts/define/PayDefine';
  4. import { UIViewID } from '@scripts/define/UIDefine';
  5. import { UIPopup } from '@scripts/framework/ui/UIPopup';
  6. import { formatCurrency, formatGoodsNum } from '@scripts/utils/Helper';
  7. import { addBtnClick } from '@scripts/utils/UIHelper';
  8. import { _decorator, Component, Label, Node } from 'cc';
  9. const { ccclass, property } = _decorator;
  10. export interface UIPayoutData {
  11. amount: number;
  12. reallAmount?: number;
  13. feeAmount?: number;
  14. feePercent: number;
  15. method: string;
  16. account: string;
  17. payoutType?: PayoutType;
  18. }
  19. @ccclass('UIPayoutConfrim')
  20. export class UIPayoutConfrim extends UIPopup<UIPayoutData> {
  21. readonly viewId: UIViewID = UIViewID.UIPayoutConfrim;
  22. @property(Node)
  23. btnClose: Node;
  24. @property(Label)
  25. lblCount: Label;
  26. @property(Label)
  27. lblAmount: Label;
  28. @property(Label)
  29. lblFeePercent: Label;
  30. @property(Label)
  31. lblFee: Label;
  32. @property(Label)
  33. lblExchange: Label;
  34. @property(Label)
  35. lblMethod: Label;
  36. @property(Label)
  37. lblAccount: Label;
  38. @property(Node)
  39. btnConfirm: Node;
  40. private m_data: UIPayoutData;
  41. private m_payouting = false;
  42. protected onCreate() {
  43. addBtnClick(this.btnClose, this.closeSelf, this);
  44. addBtnClick(this.btnConfirm, this.onBtnConfirmClick, this);
  45. }
  46. private async onBtnConfirmClick() {
  47. if (this.m_payouting) return;
  48. this.m_payouting = true;
  49. AppKernel.ui.loading(true);
  50. const amount = this.m_data.amount;
  51. const withdraw = AppKernel.stores.withdrawStore;
  52. if (await withdraw.reqWithdrawPayout(amount)) {
  53. this.closeSelf();
  54. AppKernel.ui.open(UIViewID.UIPayoutResult, {
  55. success: true,
  56. msg: "payout.submitted"
  57. })
  58. }
  59. this.m_payouting = false;
  60. AppKernel.ui.loading(false);
  61. }
  62. protected onOpen(data: UIPayoutData) {
  63. this.m_data = data;
  64. this.lblCount.string = "$" + formatCurrency(data.reallAmount, 2);
  65. this.lblAmount.string = formatCurrency(data.amount, 2) + " " + CURRENCY_TYPE.SC;
  66. this.lblFeePercent.string = AppKernel.i18n.t("redeem.service_fee", data.feePercent);
  67. this.lblFee.string = formatCurrency(data.feeAmount, 2) + " " + CURRENCY_TYPE.SC;
  68. this.lblMethod.string = data.method;
  69. this.lblAccount.string = data.account;
  70. this.lblExchange.string = AppKernel.i18n.t("redeem.conversion");
  71. }
  72. }