Guest User

Untitled

a guest
Jan 29th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. initializeApp()
  2. {
  3. this.platform.ready().then(() => {
  4.  
  5. if(this.platform.is('android') || this.platform.is('ios'))
  6. {
  7. ScreenOrientation.lockOrientation('portrait-primary');
  8. }
  9. StatusBar.styleDefault();
  10. SplashScreen.hide();
  11. });
  12. }
  13.  
  14. if(this.platform.is('android') || this.platform.is('ios'))
  15. {
  16. ScreenOrientation.lockOrientation('portrait-primary');
  17. }
  18.  
  19. import { Component, ViewChild } from '@angular/core';
  20. import { Nav, Platform } from 'ionic-angular';
  21. import { StatusBar } from '@ionic-native/status-bar';
  22. import { Http } from '@angular/http';
  23. import { SplashScreen } from '@ionic-native/splash-screen';
  24. import { Md5 } from 'ts-md5/dist/md5';
  25. import { ScreenOrientation } from '@ionic-native/screen-orientation';
  26.  
  27. import { LoginPage } from '../pages/login/login';
  28. import { OrderPage } from '../pages/order/order';
  29. import { HistoryPage } from '../pages/history/history';
  30. import { LoginService } from '../pages/login/login.service';
  31.  
  32.  
  33. import { AuthProvider } from '../providers/auth/auth';
  34. import { LoadingController } from 'ionic-angular';
  35.  
  36.  
  37. @Component({
  38. templateUrl: 'app.html'
  39. })
  40. export class MyApp {
  41. @ViewChild(Nav) nav: Nav;
  42. rootPage: any = OrderPage;
  43. activePage: any;
  44.  
  45. pages: Array<{title: string, component: any}>;
  46.  
  47. constructor(public platform: Platform) {
  48. this.initializeApp();
  49.  
  50. this.pages = [
  51. {title: 'Orders', component: OrderPage},
  52. {title: 'History', component: HistoryPage}
  53. ];
  54.  
  55. this.activePage = this.pages[0];
  56. }
  57. initializeApp()
  58. {
  59. this.platform.ready().then(() => {
  60.  
  61. if(this.platform.is('android') || this.platform.is('ios'))
  62. {
  63. ScreenOrientation.lockOrientation(this.getOrientation());
  64. }
  65. StatusBar.styleDefault();
  66. SplashScreen.hide();
  67. });
  68. }
  69.  
  70. openPage(page)
  71. {
  72. this.nav.setRoot(page.component);
  73. this.activePage = page;
  74. }
  75. }
  76.  
  77. import { NgModule, ErrorHandler } from '@angular/core';
  78. import { BrowserModule } from '@angular/platform-browser';
  79. import { HttpModule } from '@angular/http';
  80. import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
  81. import { MyApp } from './app.component';
  82. import { Md5 } from 'ts-md5/dist/md5';
  83.  
  84. import { LoginService } from '../pages/login/login.service';
  85. import { LoginPage } from '../pages/login/login';
  86. import { OrderPage } from '../pages/order/order';
  87. import { HistoryPage } from '../pages/history/history';
  88.  
  89. import { AuthProvider } from '../providers/auth/auth';
  90.  
  91. import { ScreenOrientation } from '@ionic-native/screen-orientation';
  92. import { StatusBar } from '@ionic-native/status-bar';
  93. import { SplashScreen } from '@ionic-native/splash-screen';
  94.  
  95.  
  96. @NgModule({
  97. declarations: [
  98. MyApp,
  99. LoginPage,
  100. OrderPage,
  101. HistoryPage
  102. ],
  103. imports: [
  104. HttpModule,
  105. BrowserModule,
  106. IonicModule.forRoot(MyApp)
  107. ],
  108. bootstrap: [IonicApp],
  109. entryComponents: [
  110. MyApp,
  111. LoginPage,
  112. OrderPage,
  113. HistoryPage
  114. ],
  115. providers: [
  116. StatusBar,
  117. SplashScreen,
  118. ScreenOrientation,
  119. {provide: ErrorHandler, useClass: IonicErrorHandler},
  120. AuthProvider,
  121. LoginService,
  122. Md5
  123. ]
  124. })
  125.  
  126. <ion-menu [content]="content">
  127.  
  128. <ion-header>
  129. <ion-toolbar>
  130. <ion-title>Menu</ion-title>
  131. </ion-toolbar>
  132. </ion-header>
  133.  
  134. <ion-content>
  135. <ion-list>
  136. <button ion-item menuClose *ngFor="let p of pages" (click)="openPage(p)">
  137. {{ p.title }}
  138. </button>
  139. </ion-list>
  140. </ion-content>
  141. </ion-menu>
  142.  
  143. <ion-nav [root]="OrderPage" #content swipeBackEnabled="false"></ion-nav>
  144.  
  145. <ion-header>
  146. <ion-navbar>
  147. <ion-title>
  148. Log-in
  149. </ion-title>
  150. </ion-navbar>
  151. </ion-header>
  152.  
  153. <ion-content padding style= "background-color: #0847ad">
  154.  
  155. <ion-list style="padding-top: 110px">
  156. <div>
  157. <img alt="cangs" height="90" src="assets/imgs/cangs.png" >
  158. <h4 text-center style="color: white">Cang's Inc.</h4>
  159. </div>
  160.  
  161. <ion-label text-center style="font-size: 12px; color: white">Authentication</ion-label>
  162.  
  163. <ion-item id="user">
  164. <ion-input placeholder="Username" type="text" name="user" [(ngModel)]="user"></ion-input>
  165. </ion-item>
  166.  
  167. <ion-item id="pw">
  168. <ion-input placeholder="Password" type="password" name="pass" [(ngModel)]="pass"></ion-input>
  169. </ion-item>
  170. </ion-list>
  171. <div text-center>
  172. <button ion-button outline round style="color: white; background- color:#0847ad" (click)="login($event)">Log-in</button>
  173. </div>
  174.  
  175.  
  176. </ion-content>
  177.  
  178. import { Component } from '@angular/core';
  179. import { NavController } from 'ionic-angular';
  180. import { Md5 } from 'ts-md5/dist/md5';
  181.  
  182. import { LoginService } from './login.service';
  183. import { OrderPage } from '../../pages/order/order';
  184.  
  185. @Component({
  186. selector: 'page-login',
  187. templateUrl: 'login.html'
  188. })
  189. export class LoginPage {
  190.  
  191. user: any;
  192. pass: any;
  193.  
  194. MoveToOrder(){
  195. //10016
  196. //ed9d07d5
  197. console.log("move page");
  198. this.navCtrl.push(OrderPage, {
  199. data1: this.user,
  200. data2: this.pass
  201. });
  202. }
  203.  
  204. hash:string = '';
  205. public cus: any=[];
  206. public error: string ="";
  207. logindetails: boolean=false;
  208. public inputuser: string = '';
  209. public inputpass: string ='';
  210. public inputusername: string ='';
  211.  
  212. constructor(private _md5: Md5, private log: LoginService, public navCtrl: NavController){
  213. this.log.getCustomer().then(res =>{
  214. this.cus=res;
  215. });
  216. }
  217.  
  218. login(event : any)
  219. {
  220. console.log(this.user);
  221. console.log(Md5.hashStr(this.pass));
  222. for(let data of this.cus)
  223. {
  224.  
  225. if(this.user == data.customerID)
  226. {
  227. this.error="Incorrect Password";
  228. console.log("matchuser");
  229. if(Md5.hashStr(this.pass) == data.cusPassword)
  230. {
  231. console.log(data);
  232. this.inputuser=data.customerID;
  233. this.inputpass=data.cusPassword;
  234.  
  235. this.inputusername= data.cusFirstName + " " + data.cusMiddleName + ". " + data.cusLastName;
  236. this.logindetails=true;
  237. this.error=""
  238. console.log("matchpass");
  239.  
  240. this.MoveToOrder();
  241. console.log("yeye");
  242. }
  243. }
  244. console.log(data.cusPassword);
  245. }
  246. }
  247.  
  248. }
Add Comment
Please, Sign In to add comment