UIPayoutEditor.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { AppKernel } from '@scripts/app/AppKernel';
  2. import { IPayoutGear, PayoutGears, PayoutType } from '@scripts/define/PayDefine';
  3. import { UIViewID } from '@scripts/define/UIDefine';
  4. import { UIPopup } from '@scripts/framework/ui/UIPopup';
  5. import { addBtnClick } from '@scripts/utils/UIHelper';
  6. import { _decorator, Component, EditBox, Label, Node } from 'cc';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('UIPayoutEditor')
  9. export class UIPayoutEditor extends UIPopup<PayoutType> {
  10. readonly viewId: UIViewID = UIViewID.UIPayoutEditor;
  11. @property(Node)
  12. btnClose: Node;
  13. @property(Node)
  14. btnConfirm: Node;
  15. @property(Label)
  16. lblName: Label;
  17. @property(EditBox)
  18. inputAccount: EditBox;
  19. @property(EditBox)
  20. inputConfirm: EditBox;
  21. private m_gear: IPayoutGear;
  22. protected onCreate() {
  23. addBtnClick(this.btnClose, this.closeSelf, this);
  24. addBtnClick(this.btnConfirm, this.onBtnConfirmClick, this);
  25. }
  26. private async onBtnConfirmClick() {
  27. const account = this.inputAccount.string;
  28. const reAccount = this.inputConfirm.string;
  29. if (!account || account.length === 0) {
  30. AppKernel.ui.toast("payout.edit.account_empty", true);
  31. return;
  32. }
  33. if (reAccount !== account) {
  34. AppKernel.ui.toast("payout.edit.account_nosame", true);
  35. return;
  36. }
  37. let params: any = { pixType: 0 };
  38. params.pixType = this.m_gear.pixType;
  39. switch (this.m_gear.type) {
  40. case PayoutType.CashApp:
  41. params.cashTag = account;
  42. break;
  43. case PayoutType.Paypal:
  44. params.paypal = account;
  45. break;
  46. }
  47. AppKernel.ui.loading(true);
  48. const withdraw = AppKernel.stores.withdrawStore;
  49. await withdraw.reqWithdrawSetInfo(params)
  50. AppKernel.ui.loading(false);
  51. }
  52. protected onOpen(type: PayoutType) {
  53. const gear = PayoutGears.find(gear => gear.type === type);
  54. if (!gear) return;
  55. this.m_gear = gear;
  56. this.lblName.string = gear.name;
  57. }
  58. }