| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- import { _decorator, Button, EditBox, Node, Sprite, SpriteFrame } from 'cc';
- import { UIView } from '@scripts/framework/ui/UIView';
- import { AppKernel } from '@scripts/app/AppKernel';
- import { UIViewID } from '@scripts/define/UIDefine';
- import { UICloseReason } from '@scripts/framework/ui/UILayer';
- import { formatCurrency } from '@scripts/utils/Helper';
- import { addBtnClick } from '@scripts/utils/UIHelper';
- const { ccclass, property } = _decorator;
- @ccclass('LoginView')
- export class LoginView extends UIView {
- readonly viewId = UIViewID.LoginView;
- @property(Button)
- btnGuest: Button;
- @property(Button)
- btnFacebook: Button;
- @property(Button)
- btnGoogle: Button;
- @property(Button)
- btnLogOut: Button;
- @property(Node)
- registerNode: Node;
- @property(Node)
- loginNode: Node;
- @property(Node)
- forgetNode: Node;
- @property(Node)
- btnForgetOpen: Node;
- @property(Node)
- btnForget: Node;
- @property(EditBox)
- forgetAccount: EditBox;
- @property(EditBox)
- forgetPassword: EditBox;
- @property(EditBox)
- forgetCode: EditBox;
- @property(Node)
- btnRegisterNode: Node;
- @property(Node)
- btnLoginNode: Node;
- @property(EditBox)
- loginAccount: EditBox;
- @property(EditBox)
- loginPassword: EditBox;
- @property(EditBox)
- registerAccount: EditBox;
- @property(EditBox)
- registerCode: EditBox;
- @property(EditBox)
- registerPw: EditBox;
- @property(Node)
- btnRegister: Node;
- @property(Node)
- btnLogin: Node;
- private _googleWebBtn;
- protected onCreate(): void | Promise<void> {
- addBtnClick(this.btnGuest.node, this.onBtnGuestClick, this);
- addBtnClick(this.btnFacebook.node, this.onBtnFBClick, this);
- addBtnClick(this.btnGoogle.node, this.onBtnGoogleClick, this);
- addBtnClick(this.btnLogOut.node, this.onBtnLogOutClick, this);
- this._googleWebBtn = AppKernel.google.createLoginBtn(
- this.btnGoogle.node,
- res => this.onGoogleWebLogin(res),
- );
- ///////////////// Test
- addBtnClick(this.btnLoginNode, this.onShowLoginNode, this);
- addBtnClick(this.btnRegisterNode, this.onShowRegisterNode, this);
- addBtnClick(this.btnLogin, this.onBtnLoginClick, this);
- addBtnClick(this.btnRegister, this.onBtnRegisterClick, this);
- addBtnClick(this.btnForget, this.onBtnForgetClick, this);
- addBtnClick(this.btnForgetOpen, this.onShowForgetNode, this);
- console.log(">>>>>>>>>", formatCurrency(12345678.9), formatCurrency(12345678.9, 2))
- }
- protected onOpen(_params: unknown): void | Promise<void> {
- /// 播放完打开动画后 再显示h5 google login btn dom
- this._googleWebBtn?.setActive(true);
- }
- protected onClose(_reason: UICloseReason): void | Promise<void> {
- this._googleWebBtn?.setActive(false);
- }
- protected onDestroy(): void {
- this._googleWebBtn?.clear();
- }
- private async onBtnGuestClick() {
- AppKernel.ui.loading(true);
- await AppKernel.services.loginService.guestLogin();
- AppKernel.ui.loading(false);
- }
- private async onBtnFBClick() {
- AppKernel.ui.loading(true);
- await AppKernel.services.loginService.fbLogin();
- AppKernel.ui.loading(false);
- }
- private async onBtnLogOutClick() {
- // AppKernel.ui.loading(true);
- // const res = await AppKernel.fb.logOut();
- // console.log('facebook logout res: ', res);
- // AppKernel.ui.loading(false);
- }
- private async onGoogleWebLogin(res) {
- AppKernel.ui.loading(true);
- await AppKernel.services.loginService.googleLogin(res);
- AppKernel.ui.loading(false);
- }
- private async onBtnGoogleClick() {
- AppKernel.ui.loading(true);
- await AppKernel.services.loginService.googleLogin();
- AppKernel.ui.loading(false);
- }
- ///////////////// Test
- private onShowLoginNode() {
- this.loginNode.active = !this.loginNode.active;
- }
- private onShowRegisterNode() {
- this.registerNode.active = !this.registerNode.active;
- }
- private onBtnLoginClick() {
- const account = this.loginAccount.string;
- const password = this.loginPassword.string;
- AppKernel.services.loginService.loginAccount(account, password);
- }
- private onBtnRegisterClick() {
- const account = this.registerAccount.string;
- const code = this.registerCode.string;
- const password = this.registerPw.string;
- AppKernel.services.loginService.register({ account, code, password });
- }
- private onShowForgetNode() {
- this.forgetNode.active = !this.forgetNode.active;
- }
- private onBtnForgetClick() {
- const account = this.forgetAccount.string;
- const password = this.forgetPassword.string;
- const code = this.forgetCode.string;
- AppKernel.stores.mainStore.reqForgetPass({
- phone: account,
- code,
- newpassword: password,
- })
- const sp = new Sprite();
- }
- }
|