UIPayoutResult.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { AppKernel } from '@scripts/app/AppKernel';
  2. import { UIViewID } from '@scripts/define/UIDefine';
  3. import { UIPopup } from '@scripts/framework/ui/UIPopup';
  4. import { formatCurrency, formatGoodsNum } from '@scripts/utils/Helper';
  5. import { addBtnClick } from '@scripts/utils/UIHelper';
  6. import { _decorator, Component, Label, Node } from 'cc';
  7. const { ccclass, property } = _decorator;
  8. export interface UIPayoutResultData {
  9. success?: boolean;
  10. amount?: string;
  11. msg?: string;
  12. }
  13. @ccclass('UIPayoutResult')
  14. export class UIPayoutResult extends UIPopup<UIPayoutResultData> {
  15. readonly viewId: UIViewID = UIViewID.UIPayoutResult;
  16. @property(Node)
  17. btnClose: Node;
  18. @property(Node)
  19. btnConfirm: Node;
  20. @property(Node)
  21. iconSuccess: Node;
  22. @property(Node)
  23. iconFail: Node;
  24. @property(Label)
  25. lblMsg: Label;
  26. protected onCreate() {
  27. addBtnClick(this.btnClose, this.closeSelf, this);
  28. addBtnClick(this.btnConfirm, this.closeSelf, this);
  29. }
  30. protected onOpen(data: UIPayoutResultData) {
  31. this.updateView(data.success, data.amount, data.msg);
  32. const success = data.success;
  33. const amount = data.amount;
  34. const msg = data.msg;
  35. let key = msg;
  36. if (!msg) key = success ? "payout.result_success" : "payout.result_fail";
  37. this.lblMsg.string = AppKernel.i18n.t(key, amount);
  38. this.iconSuccess.active = success;
  39. this.iconFail.active = !success;
  40. }
  41. private updateView(success: boolean, amount: string, msg: string) {
  42. const key = success ? "payout.result_success" : "payout.result_fail";
  43. this.lblMsg.string = AppKernel.i18n.t(key, amount);
  44. this.iconSuccess.active = success;
  45. this.iconFail.active = !success;
  46. }
  47. }