File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Component , OnInit } from '@angular/core' ;
2
+ import { AlertController , NavController , NavParams } from 'ionic-angular' ;
3
+ import { PhoneService } from '../../services/phone' ;
4
+
5
+ @Component ( {
6
+ selector : 'verification' ,
7
+ templateUrl : 'verification.html'
8
+ } )
9
+ export class VerificationPage implements OnInit {
10
+ private code : string = '' ;
11
+ private phone : string ;
12
+
13
+ constructor (
14
+ private alertCtrl : AlertController ,
15
+ private navCtrl : NavController ,
16
+ private navParams : NavParams ,
17
+ private phoneService : PhoneService
18
+ ) { }
19
+
20
+ ngOnInit ( ) {
21
+ this . phone = this . navParams . get ( 'phone' ) ;
22
+ }
23
+
24
+ onInputKeypress ( { keyCode} : KeyboardEvent ) : void {
25
+ if ( keyCode === 13 ) {
26
+ this . verify ( ) ;
27
+ }
28
+ }
29
+
30
+ verify ( ) : void {
31
+ this . phoneService . login ( this . phone , this . code )
32
+ . catch ( ( e ) => {
33
+ this . handleError ( e ) ;
34
+ } ) ;
35
+ }
36
+
37
+ handleError ( e : Error ) : void {
38
+ console . error ( e ) ;
39
+
40
+ const alert = this . alertCtrl . create ( {
41
+ title : 'Oops!' ,
42
+ message : e . message ,
43
+ buttons : [ 'OK' ]
44
+ } ) ;
45
+
46
+ alert . present ( ) ;
47
+ }
48
+ }
You can’t perform that action at this time.
0 commit comments