Advertisement
Guest User

Untitled

a guest
May 20th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
  3. import { RegisterPage } from '../register/register';
  4. import { Storage } from '@ionic/storage';
  5. import { HomePage } from '../home/home';
  6. import { TabsPage } from '../tabs/tabs';
  7.  
  8.  
  9. /* Generated class for the LoginPage page.
  10. *
  11. * See https://ionicframework.com/docs/components/#navigation for more info on
  12. * Ionic pages and navigation.
  13. */
  14.  
  15. @IonicPage()
  16. @Component({
  17. selector: 'page-login',
  18. templateUrl: 'login.html',
  19. })
  20. export class LoginPage {
  21. username:string='';
  22. password:string='';
  23. usernamep:any='';
  24. passwordp:any='';
  25. constructor(public navCtrl: NavController, public navParams: NavParams, public alertCtrl: AlertController, public storage: Storage) {
  26. }
  27.  
  28. ionViewDidLoad() {
  29. console.log('ionViewDidLoad LoginPage');
  30. }
  31.  
  32. aut(){
  33. this.storage.get('username').then(
  34. (val)=>{
  35. this.usernamep = val;
  36. console.log('Username is Storage', val);
  37. });
  38. this.storage.get('password').then(
  39. (val)=>{
  40. this.passwordp = val;
  41. console.log('Password is Storage', val);
  42. });
  43. if(this.username == this.usernamep && this.password == this.passwordp)
  44. this.gotoHome();
  45. else
  46. this.showAlertfailed();
  47.  
  48.  
  49.  
  50.  
  51. }
  52. /*aut(){
  53. let data = {
  54. username: btoa(this.username),
  55. password: btoa(this.password)
  56. };
  57. if(data.status == 'true')
  58. {
  59. this.navCtrl.setRoot(HomePage);
  60. console.log('login berhasil');
  61. }
  62. else
  63. {
  64. this.showAlertsuccess('Login Gagal, username atau password anda salah');
  65. console.log('login gagal')
  66. }
  67. }*/
  68.  
  69. showAlertsuccess(title) {
  70. let alert = this.alertCtrl.create({
  71. title: 'Confirmation!',
  72. subTitle: title,
  73. buttons: ['OK']
  74. });
  75. alert.present();
  76. }
  77.  
  78. showAlertfailed() {
  79. let alert = this.alertCtrl.create({
  80. title: 'Confirmation!',
  81. subTitle: 'Login Failed!!!',
  82. buttons: ['OK']
  83. });
  84. alert.present();
  85. }
  86.  
  87. gotoRegis(){
  88. this.navCtrl.push(RegisterPage);
  89. }
  90.  
  91. gotoHome(){
  92. this.navCtrl.push(TabsPage);
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement