ResetPsd.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { _decorator, Button, Color, EditBox, instantiate, Label, Node, RichText, Sprite, SpriteFrame, UITransform } from 'cc';
  2. import { UIViewID } from '@scripts/define/UIDefine';
  3. import { UICloseReason } from '@scripts/framework/ui/UILayer';
  4. import { addBtnClick } from '@scripts/utils/UIHelper';
  5. import { AppKernel } from '@scripts/app/AppKernel';
  6. import { UIPopup } from '@scripts/framework/ui/UIPopup';
  7. import { checkIsEmail } from '@scripts/utils/Helper';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('ResetPsd')
  10. export class ResetPsd extends UIPopup {
  11. readonly viewId = UIViewID.ResetPsd;
  12. @property(Node)
  13. private btnClose: Node = null;
  14. @property(Node)
  15. private btnReset: Node = null;
  16. @property(EditBox)
  17. account: EditBox;
  18. @property(EditBox)
  19. code: EditBox;
  20. @property(EditBox)
  21. psd: EditBox;
  22. protected onCreate(): void | Promise<void> {
  23. addBtnClick(this.btnClose, this.onBtnCloseClick, this);
  24. addBtnClick(this.btnReset, this.onBtnResetClick, this);
  25. }
  26. private onBtnCloseClick() {
  27. AppKernel.ui.close(UIViewID.ResetPsd);
  28. // const loginView = AppKernel.ui.get(UIViewID.LoginView) as any;
  29. // if (loginView && loginView?.enabled) {
  30. // loginView?._googleWebBtn?.setActive(true);
  31. // }
  32. }
  33. private async onBtnResetClick() {
  34. const account = this.account.string;
  35. const code = this.code.string;
  36. const password = this.psd.string;
  37. if (account && code && password) {
  38. const res = checkIsEmail(account)
  39. ? await AppKernel.stores.mailStore.reqResetPsd({
  40. account,
  41. code,
  42. newpassword: password
  43. })
  44. : await AppKernel.stores.mainStore.reqForgetPass({
  45. phone: account,
  46. code,
  47. newpassword: password,
  48. });
  49. if (res) {
  50. await AppKernel.services.loginService.loginAccount(account, password);
  51. await AppKernel.ui.close(UIViewID.ResetPsd);
  52. await AppKernel.ui.open(UIViewID.LoginSuccess);
  53. }
  54. }
  55. }
  56. }