|
@@ -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'])
|
|
|
}
|
|
|
|
|
|
}
|