Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- initializeApp()
- {
- this.platform.ready().then(() => {
- if(this.platform.is('android') || this.platform.is('ios'))
- {
- ScreenOrientation.lockOrientation('portrait-primary');
- }
- StatusBar.styleDefault();
- SplashScreen.hide();
- });
- }
- if(this.platform.is('android') || this.platform.is('ios'))
- {
- ScreenOrientation.lockOrientation('portrait-primary');
- }
- import { Component, ViewChild } from '@angular/core';
- import { Nav, Platform } from 'ionic-angular';
- import { StatusBar } from '@ionic-native/status-bar';
- import { Http } from '@angular/http';
- import { SplashScreen } from '@ionic-native/splash-screen';
- import { Md5 } from 'ts-md5/dist/md5';
- import { ScreenOrientation } from '@ionic-native/screen-orientation';
- import { LoginPage } from '../pages/login/login';
- import { OrderPage } from '../pages/order/order';
- import { HistoryPage } from '../pages/history/history';
- import { LoginService } from '../pages/login/login.service';
- import { AuthProvider } from '../providers/auth/auth';
- import { LoadingController } from 'ionic-angular';
- @Component({
- templateUrl: 'app.html'
- })
- export class MyApp {
- @ViewChild(Nav) nav: Nav;
- rootPage: any = OrderPage;
- activePage: any;
- pages: Array<{title: string, component: any}>;
- constructor(public platform: Platform) {
- this.initializeApp();
- this.pages = [
- {title: 'Orders', component: OrderPage},
- {title: 'History', component: HistoryPage}
- ];
- this.activePage = this.pages[0];
- }
- initializeApp()
- {
- this.platform.ready().then(() => {
- if(this.platform.is('android') || this.platform.is('ios'))
- {
- ScreenOrientation.lockOrientation(this.getOrientation());
- }
- StatusBar.styleDefault();
- SplashScreen.hide();
- });
- }
- openPage(page)
- {
- this.nav.setRoot(page.component);
- this.activePage = page;
- }
- }
- import { NgModule, ErrorHandler } from '@angular/core';
- import { BrowserModule } from '@angular/platform-browser';
- import { HttpModule } from '@angular/http';
- import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
- import { MyApp } from './app.component';
- import { Md5 } from 'ts-md5/dist/md5';
- import { LoginService } from '../pages/login/login.service';
- import { LoginPage } from '../pages/login/login';
- import { OrderPage } from '../pages/order/order';
- import { HistoryPage } from '../pages/history/history';
- import { AuthProvider } from '../providers/auth/auth';
- import { ScreenOrientation } from '@ionic-native/screen-orientation';
- import { StatusBar } from '@ionic-native/status-bar';
- import { SplashScreen } from '@ionic-native/splash-screen';
- @NgModule({
- declarations: [
- MyApp,
- LoginPage,
- OrderPage,
- HistoryPage
- ],
- imports: [
- HttpModule,
- BrowserModule,
- IonicModule.forRoot(MyApp)
- ],
- bootstrap: [IonicApp],
- entryComponents: [
- MyApp,
- LoginPage,
- OrderPage,
- HistoryPage
- ],
- providers: [
- StatusBar,
- SplashScreen,
- ScreenOrientation,
- {provide: ErrorHandler, useClass: IonicErrorHandler},
- AuthProvider,
- LoginService,
- Md5
- ]
- })
- <ion-menu [content]="content">
- <ion-header>
- <ion-toolbar>
- <ion-title>Menu</ion-title>
- </ion-toolbar>
- </ion-header>
- <ion-content>
- <ion-list>
- <button ion-item menuClose *ngFor="let p of pages" (click)="openPage(p)">
- {{ p.title }}
- </button>
- </ion-list>
- </ion-content>
- </ion-menu>
- <ion-nav [root]="OrderPage" #content swipeBackEnabled="false"></ion-nav>
- <ion-header>
- <ion-navbar>
- <ion-title>
- Log-in
- </ion-title>
- </ion-navbar>
- </ion-header>
- <ion-content padding style= "background-color: #0847ad">
- <ion-list style="padding-top: 110px">
- <div>
- <img alt="cangs" height="90" src="assets/imgs/cangs.png" >
- <h4 text-center style="color: white">Cang's Inc.</h4>
- </div>
- <ion-label text-center style="font-size: 12px; color: white">Authentication</ion-label>
- <ion-item id="user">
- <ion-input placeholder="Username" type="text" name="user" [(ngModel)]="user"></ion-input>
- </ion-item>
- <ion-item id="pw">
- <ion-input placeholder="Password" type="password" name="pass" [(ngModel)]="pass"></ion-input>
- </ion-item>
- </ion-list>
- <div text-center>
- <button ion-button outline round style="color: white; background- color:#0847ad" (click)="login($event)">Log-in</button>
- </div>
- </ion-content>
- import { Component } from '@angular/core';
- import { NavController } from 'ionic-angular';
- import { Md5 } from 'ts-md5/dist/md5';
- import { LoginService } from './login.service';
- import { OrderPage } from '../../pages/order/order';
- @Component({
- selector: 'page-login',
- templateUrl: 'login.html'
- })
- export class LoginPage {
- user: any;
- pass: any;
- MoveToOrder(){
- //10016
- //ed9d07d5
- console.log("move page");
- this.navCtrl.push(OrderPage, {
- data1: this.user,
- data2: this.pass
- });
- }
- hash:string = '';
- public cus: any=[];
- public error: string ="";
- logindetails: boolean=false;
- public inputuser: string = '';
- public inputpass: string ='';
- public inputusername: string ='';
- constructor(private _md5: Md5, private log: LoginService, public navCtrl: NavController){
- this.log.getCustomer().then(res =>{
- this.cus=res;
- });
- }
- login(event : any)
- {
- console.log(this.user);
- console.log(Md5.hashStr(this.pass));
- for(let data of this.cus)
- {
- if(this.user == data.customerID)
- {
- this.error="Incorrect Password";
- console.log("matchuser");
- if(Md5.hashStr(this.pass) == data.cusPassword)
- {
- console.log(data);
- this.inputuser=data.customerID;
- this.inputpass=data.cusPassword;
- this.inputusername= data.cusFirstName + " " + data.cusMiddleName + ". " + data.cusLastName;
- this.logindetails=true;
- this.error=""
- console.log("matchpass");
- this.MoveToOrder();
- console.log("yeye");
- }
- }
- console.log(data.cusPassword);
- }
- }
- }
Add Comment
Please, Sign In to add comment