LoginView.ts 904 B

12345678910111213141516171819202122232425262728
  1. import { _decorator, Button, Node } from 'cc';
  2. import { UIView } from '@scripts/framework/ui/UIView';
  3. import { AppKernel } from '@scripts/app/AppKernel';
  4. import { LoginType } from '@scripts/define/Define';
  5. import { UIViewID } from '@scripts/define/UIDefine';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('LoginView')
  8. export class LoginView extends UIView {
  9. readonly viewId = UIViewID.LoginView;
  10. @property(Button)
  11. btnGuest: Button;
  12. protected onCreate(): void | Promise<void> {
  13. this.btnGuest.node.on(Node.EventType.TOUCH_END, this.onBtnGuestClick, this);
  14. }
  15. private async onBtnGuestClick() {
  16. AppKernel.ui.loading(true);
  17. const loggedIn = await AppKernel.stores.mainStore.reqLogin({ type: LoginType.GUEST });
  18. if (!loggedIn) return;
  19. await AppKernel.services.lobbyService.onLoginSuccess();
  20. AppKernel.ui.loading(false);
  21. }
  22. }