| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import { _decorator, Button, Color, EditBox, instantiate, Label, Node, RichText, Sprite, SpriteFrame, UITransform } from 'cc';
- import { UIViewID } from '@scripts/define/UIDefine';
- import { UICloseReason } from '@scripts/framework/ui/UILayer';
- import { addBtnClick } from '@scripts/utils/UIHelper';
- import { AppKernel } from '@scripts/app/AppKernel';
- import { UIPopup } from '@scripts/framework/ui/UIPopup';
- import { checkIsEmail } from '@scripts/utils/Helper';
- const { ccclass, property } = _decorator;
- @ccclass('ResetPsd')
- export class ResetPsd extends UIPopup {
- readonly viewId = UIViewID.ResetPsd;
- @property(Node)
- private btnClose: Node = null;
- @property(Node)
- private btnReset: Node = null;
- @property(EditBox)
- account: EditBox;
- @property(EditBox)
- code: EditBox;
- @property(EditBox)
- psd: EditBox;
- protected onCreate(): void | Promise<void> {
- addBtnClick(this.btnClose, this.onBtnCloseClick, this);
- addBtnClick(this.btnReset, this.onBtnResetClick, this);
- }
- private onBtnCloseClick() {
- AppKernel.ui.close(UIViewID.ResetPsd);
- const loginView = AppKernel.ui.get(UIViewID.LoginView) as any;
- if (loginView && loginView?.enabled) {
- loginView?._googleWebBtn?.setActive(true);
- }
- }
- private async onBtnResetClick() {
- const account = this.account.string;
- const code = this.code.string;
- const password = this.psd.string;
- if (account && code && password) {
- const res = checkIsEmail(account)
- ? await AppKernel.stores.mailStore.reqResetPsd({
- account,
- code,
- newpassword: password
- })
- : await AppKernel.stores.mainStore.reqForgetPass({
- phone: account,
- code,
- newpassword: password,
- });
- if (res) {
- await AppKernel.services.loginService.loginAccount(account, password);
- await AppKernel.ui.close(UIViewID.ResetPsd);
- await AppKernel.ui.open(UIViewID.LoginSuccess);
- }
- }
- }
- }
|