panxingxin 5 rokov pred
rodič
commit
13de856d23

+ 2 - 1
src/app/app-routing.module.ts

@@ -23,7 +23,8 @@ const routes: Routes = [
   { path: 'store-qc-scanning/:sscId/:pId', loadChildren: './store-qc-scanning/store-qc-scanning.module#StoreQCScanningPageModule' },
   { path: 'store-qc-scanning', loadChildren: './store-qc-scanning/store-qc-scanning.module#StoreQCScanningPageModule' },
   { path: 'store-sample-pending', loadChildren: './store-sample-pending/store-sample-pending.module#StoreSamplePendingPageModule' },
-  { path: 'warehouse-manage-pending', loadChildren: './warehouse-manage-pending/warehouse-manage-pending.module#WarehouseManagePendingPageModule' }
+  { path: 'warehouse-manage-pending', loadChildren: './warehouse-manage-pending/warehouse-manage-pending.module#WarehouseManagePendingPageModule' },
+  { path: 'home', loadChildren: './home/home.module#HomePageModule' }
   // { path: 'scanning', loadChildren: './scanning/scanning.module#ScanningPageModule', canActivate: [LoginGuardGuard] }
 ];
 @NgModule({

+ 26 - 0
src/app/home/home.module.ts

@@ -0,0 +1,26 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import { Routes, RouterModule } from '@angular/router';
+
+import { IonicModule } from '@ionic/angular';
+
+import { HomePage } from './home.page';
+
+const routes: Routes = [
+  {
+    path: '',
+    component: HomePage
+  }
+];
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    RouterModule.forChild(routes)
+  ],
+  declarations: [HomePage]
+})
+export class HomePageModule {}

+ 15 - 0
src/app/home/home.page.html

@@ -0,0 +1,15 @@
+<ion-header>
+  <ion-toolbar>
+    <ion-buttons slot="start">
+      <ion-menu-button></ion-menu-button>
+    </ion-buttons>
+    <ion-title>主页</ion-title>
+  </ion-toolbar>
+</ion-header>
+
+<ion-content>
+  <ion-item lines="none">
+    <ion-label>欢迎用户{{username}}!</ion-label>
+  </ion-item>
+  
+</ion-content>

+ 0 - 0
src/app/home/home.page.scss


+ 27 - 0
src/app/home/home.page.spec.ts

@@ -0,0 +1,27 @@
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { HomePage } from './home.page';
+
+describe('HomePage', () => {
+  let component: HomePage;
+  let fixture: ComponentFixture<HomePage>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ HomePage ],
+      schemas: [CUSTOM_ELEMENTS_SCHEMA],
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(HomePage);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 21 - 0
src/app/home/home.page.ts

@@ -0,0 +1,21 @@
+import { Component, OnInit } from '@angular/core';
+import { UserData } from '../../providers/user-data';
+import { Storage } from '@ionic/storage'
+
+@Component({
+  selector: 'app-home',
+  templateUrl: './home.page.html',
+  styleUrls: ['./home.page.scss'],
+})
+export class HomePage implements OnInit {
+
+  public username: string
+  constructor(public userData: UserData,private storage: Storage,) { }
+
+  ngOnInit() {
+    this.storage.get('username').then((val) => {
+      this.username = val
+    });
+  }
+
+}

+ 2 - 1
src/providers/user-data.ts

@@ -70,9 +70,10 @@ export class UserData {
             await toast.present();
           } else {
             this.storage.set('access_token', JSON.parse(data.data).access_token);
+            this.storage.set('username', JSON.parse(data.data).username);
             this.storage.set('user_id', JSON.parse(data.data).user_id);
             this.storage.set(this.HAS_LOGGED_IN, true);
-            this.router.navigateByUrl('/sample');
+            this.router.navigateByUrl('/home');
             return this.events.publish('user:login');
           }
         }, async err => {