tab4.page.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { Component, OnInit } from '@angular/core';
  2. import { NavController } from '@ionic/angular';
  3. import { Router } from '@angular/router';
  4. @Component({
  5. selector: 'app-tab4',
  6. templateUrl: './tab4.page.html',
  7. styleUrls: ['./tab4.page.scss'],
  8. })
  9. export class Tab4Page implements OnInit {
  10. constructor(private navCtrl: NavController,private router: Router) {}//this.selectedContent = '发布';
  11. selectedContent: string = '发布';
  12. publishedWorks: any[] = [
  13. {description: '这是发布作品1的描述' },
  14. {description: '这是发布作品2的描述' },
  15. // 其他发布作品信息
  16. ];
  17. collectedWorks: any[] = [
  18. {description: '这是收藏作品1的描述' },
  19. {description: '这是收藏作品2的描述' },
  20. // 其他收藏作品信息
  21. ];
  22. likedWorks: any[] = [
  23. {description: '这是点赞作品1的描述' },
  24. {description: '这是点赞作品2的描述' },
  25. // 其他点赞作品信息
  26. ];
  27. viewedWorks: any[] = [
  28. {description: '这是浏览作品1的描述' },
  29. {description: '这是浏览作品2的描述' },
  30. // 其他浏览作品信息
  31. ];
  32. selectedWorks: any[] = [];
  33. showContent(content: string) {
  34. this.selectedContent = content;
  35. switch(content) {
  36. case '发布':
  37. this.selectedWorks = this.publishedWorks;
  38. break;
  39. case '收藏':
  40. this.selectedWorks = this.collectedWorks;
  41. break;
  42. case '点赞':
  43. this.selectedWorks = this.likedWorks;
  44. break;
  45. case '浏览':
  46. this.selectedWorks = this.viewedWorks;
  47. break;
  48. default:
  49. this.selectedWorks = [];
  50. }
  51. }
  52. openFeedbackPage() {
  53. // 打开反馈页面
  54. this.navCtrl.navigateForward('/feedback');
  55. }
  56. openSettingsPage() {
  57. // 打开设置页面
  58. this.router.navigate(['/settings']);
  59. }
  60. openLoginPage() {
  61. //打开登录页面
  62. this.navCtrl.navigateForward('../../modules/user/login/login.module');
  63. }
  64. openFollowingPage(){
  65. //打开关注页面
  66. this.router.navigate(['/following']);
  67. }
  68. openFollowerPage(){
  69. //打开粉丝页面
  70. this.router.navigate(['/follower']);
  71. }
  72. // 由于Parse.User.current()是随着localStorage变化的属性
  73. // 为了避免首次复制后用户状态变化,页面不同步,通过get方法实现实时获取
  74. // user:Parse.User|undefined
  75. // async ngOnInit() {
  76. // this.user = await Parse.User.current()
  77. // setInterval(async ()=>{
  78. // this.user = await Parse.User.current()
  79. // },1000)
  80. // }
  81. // logout(){
  82. // Parse.User.logOut();
  83. // }
  84. user={
  85. followers: 3,
  86. following: 2,
  87. likes: 0
  88. }
  89. ngOnInit() {
  90. this.showContent(this.selectedContent);
  91. }
  92. }