Register.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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('Register')
  10. export class Register extends UIPopup {
  11. readonly viewId = UIViewID.Register;
  12. @property(Node)
  13. private btnClose: Node = null;
  14. @property(Node)
  15. private btnSignUp: Node = null;
  16. @property(EditBox)
  17. account: EditBox;
  18. @property(EditBox)
  19. code: EditBox;
  20. @property(EditBox)
  21. psd: EditBox;
  22. @property(EditBox)
  23. inviteCode: EditBox;
  24. protected onCreate(): void | Promise<void> {
  25. addBtnClick(this.btnClose, this.onBtnCloseClick, this);
  26. addBtnClick(this.btnSignUp, this.onBtnSignUpClick, this);
  27. }
  28. private onBtnCloseClick() {
  29. AppKernel.ui.close(UIViewID.Register);
  30. // const loginView = AppKernel.ui.get(UIViewID.LoginView) as any;
  31. // if (loginView && loginView?.enabled) {
  32. // loginView?._googleWebBtn?.setActive(true);
  33. // }
  34. }
  35. private async onBtnSignUpClick() {
  36. const account = this.account.string;
  37. const code = this.code.string;
  38. const password = this.psd.string;
  39. const act = this.inviteCode.string;
  40. if (account && code && password) {
  41. const res = checkIsEmail(account)
  42. ? await AppKernel.stores.mailStore.reqRegister({ account, code, password, act })
  43. : await AppKernel.services.loginService.register({ account, code, password, act });
  44. if (res) {
  45. await AppKernel.services.loginService.loginAccount(account, password);
  46. await AppKernel.ui.close(UIViewID.Register);
  47. await AppKernel.ui.open(UIViewID.LoginSuccess);
  48. }
  49. }
  50. }
  51. }