0225172 hace 2 meses
padre
commit
5c2051acb3

+ 14 - 0
src/app/app-routing.module.ts

@@ -30,6 +30,20 @@ const routes: Routes = [
       }
     ]
   },
+  {
+    path: 'user',
+    loadChildren: () => import('../modules/user/user.module').then(m => m.UserModule)
+  }
+  // {
+  //   path: 'tab3',
+  //   children: [
+  //     {
+  //       path: 'login',
+  //       loadChildren: () => import('../modules/user/edit-info/edit-info.module').then(m => m.EditInfoPageModule)
+  //     }
+  //   ]
+  // },
+
   
 
 ];

+ 4 - 0
src/app/app.component.ts

@@ -1,4 +1,8 @@
 import { Component } from '@angular/core';
+// 引用Parse JS SDK
+import Parse from "parse";
+Parse.initialize("dev"); // 设置applicationId
+Parse.serverURL = "http://web2023.fmode.cn:9999/parse"; // 设置serverURL
 
 @Component({
   selector: 'app-root',

+ 3 - 3
src/app/tab3/tab3.page.html

@@ -27,10 +27,10 @@
           </ion-avatar>
           <input type="file" #fileInput (change)="onFileSelected($event)" style="display: none">
 
-        </ion-col>
+        </ion-col> 
         <ion-col size="auto" class="info-col">
-          <ion-label><h1>用户名:示例用户</h1></ion-label>
-          <ion-label>ID: 23284787</ion-label>
+          <ion-label><h1>用户名:{{user?.get('username') || '未登录'}}</h1></ion-label>
+          <ion-label>ID: {{user?.id || '-'}}</ion-label>
           &nbsp;
           <ion-label>IP属地: 南昌</ion-label>
         </ion-col> 

+ 16 - 4
src/app/tab3/tab3.page.ts

@@ -1,12 +1,12 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
-
+import Parse from "parse";
 @Component({
   selector: 'app-tab3',
   templateUrl: 'tab3.page.html',
   styleUrls: ['tab3.page.scss']
 })
-export class Tab3Page {
+export class Tab3Page implements OnInit{
 
   cards = [
     { title: '我的订单', content: '查看全部', icon: 'document-text-outline' },
@@ -33,9 +33,21 @@ export class Tab3Page {
 
   }
 
+  // 由于Parse.User.current()是随着localStorage变化的属性
+  // 为了避免首次复制后用户状态变化,页面不同步,通过get方法实现实时获取
+  user:Parse.User|undefined
+  async ngOnInit() {
+      this.user = await Parse.User.current()
+      setInterval(async ()=>{
+      this.user = await Parse.User.current()
+    },1000)
+  }
+  logout(){
+    Parse.User.logOut();
+  }
   constructor(private router: Router) {}
   GoToLoginPage(){
-    this.router.navigate(['./tab3/login'])
+    this.router.navigate(['/user/login'])
   }
 
 }

+ 1 - 0
tsconfig.json

@@ -3,6 +3,7 @@
   "compileOnSave": false,
   "compilerOptions": {
     "baseUrl": "./",
+    "allowSyntheticDefaultImports":true,
     "outDir": "./dist/out-tsc",
     "forceConsistentCasingInFileNames": true,
     "strict": true,