import { Component } from '@angular/core' ; import { NavController , ModalController } from '@ionic/angular' ; import { UserService } from 'src/app/core/services/user.service' ; import { ViewService } from 'src/app/core/services/view.service' ; import { AuthService } from 'src/app/core/services/auth.service' ; import { CONFIG } from 'src/app/configs/app.config' ; import { DocPage } from 'src/app/core/pages/doc/doc.page' ; import { NoticeService } from 'src/app/core/services/notice.service' ; @ Component ( { selector : 'page-login' , templateUrl : 'login.html' , styleUrls : [ 'login.scss' ] , } ) export class LoginPage { LOGO = CONFIG . LOGIN_LOGO ; username : string = "" ; password : string = "" ; pwshow = false ; showPoweredBy = true ; USER_AGREEMENT = CONFIG . USER_AGREEMENT ; PRIVACY_POLICY = CONFIG . PRIVACY_POLICY ; constructor ( private authService , private userService , private noticeService , private navCtrl , private viewService , private modalCtrl ) { } ngOnInit ( ) { this . viewService . setDarkStatusBar ( ) ; } async login ( ) { await this . noticeService . showLoading ( 'login' ) ; if ( this . username . length <= 0 ) { this . noticeService . showToast ( 'needPhoneNumberOrUserName' ) ; return ; } if ( this . password . length < 8 ) { this . noticeService . showToast ( 'needPassword' ) ; return ; } if ( await this . authService . login ( this . username , this . password ) ) { await this . userService . getAllInfo ( ) ; await this . noticeService . hideLoading ( ) ; this . navCtrl . navigateRoot ( '/' ) ; } } showPassword ( ) { this . pwshow = ! this . pwshow ; } onFocus ( ) { this . showPoweredBy = false ; } onBlur ( ) { this . showPoweredBy = true ; } async openUrl ( url , title ) { const modal = await this . modalCtrl . create ( { component : DocPage , backdropDismiss : false , componentProps : { 'docTitle' : title , 'docUrl' : url , } } ) ; modal . present ( ) ; } }