tab1.page.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { Component,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
  2. import { IonHeader, IonToolbar, IonTitle, IonContent, IonAvatar, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonLabel, IonList,
  3. IonItem,IonIcon,IonInput,IonSearchbar} from '@ionic/angular/standalone';
  4. import { ExploreContainerComponent } from '../explore-container/explore-container.component';
  5. import { CommonModule } from '@angular/common';
  6. import { TopicDetailComponent } from '../topic-detail/topic-detail.component';
  7. import { Router } from '@angular/router';
  8. import { TopicDetail2Component } from '../topic-detail2/topic-detail2.component';
  9. import { TopicDetail3Component } from '../topic-detail3/topic-detail3.component';
  10. @Component({
  11. selector: 'app-tab1',
  12. templateUrl: 'tab1.page.html',
  13. styleUrls: ['tab1.page.scss'],
  14. standalone: true,
  15. imports: [IonHeader,IonToolbar,IonTitle,IonContent,ExploreContainerComponent,
  16. IonButtons,IonButton,IonIcon,
  17. IonCard,IonCardContent,IonCardHeader,
  18. IonLabel,IonList,IonItem,IonAvatar,
  19. IonInput,IonSearchbar,
  20. CommonModule,
  21. TopicDetailComponent,TopicDetail2Component,TopicDetail3Component
  22. ],
  23. schemas: [CUSTOM_ELEMENTS_SCHEMA],
  24. })
  25. export class Tab1Page {
  26. onSearch(event: any) {
  27. const searchTerm = event.target.value; // 获取用户输入的搜索内容
  28. console.log('搜索内容:', searchTerm);
  29. // 在这里添加搜索逻辑,例如过滤列表或导航到搜索结果页面
  30. }
  31. consultants = [
  32. {
  33. name: '智能心理咨询师',
  34. avatar: '/assets/img/2.png',
  35. fields: ['焦虑', '抑郁','压力','...']
  36. }
  37. ];
  38. topics = [
  39. {
  40. id: 1,
  41. title: '如何管理焦虑情绪',
  42. description: '了解焦虑的来源及应对策略',
  43. detailRoute: 'topic-detail',
  44. },
  45. {
  46. id: 2,
  47. title: '克服抑郁的有效方法',
  48. description: '探索抑郁症的应对技巧',
  49. detailRoute: 'topic-detail2'
  50. },
  51. {
  52. id: 3,
  53. title: '提升自信心的技巧',
  54. description: '学习如何建立自信',
  55. detailRoute: 'topic-detail2'
  56. }
  57. ];
  58. reviews = [
  59. {
  60. avatar: '/assets/img/4.png',
  61. content: '这款APP真的帮助了我,感谢陪聊师!',
  62. rating: 4
  63. },
  64. {
  65. avatar: '/assets/img/5.png',
  66. content: '非常实用的心理咨询平台!',
  67. rating: 5
  68. },
  69. {
  70. avatar: '/assets/img/6.png',
  71. content: '我喜欢这里的热门话题!',
  72. rating: 4
  73. }
  74. ];
  75. constructor(private router: Router) {
  76. // 其他构造函数代码
  77. }
  78. goPsysurvey() {
  79. this.router.navigate(['tabs/page-psysurvey'])
  80. }
  81. viewDetails(topicId: number): void {
  82. let route: string;
  83. switch (topicId) {
  84. case 1:
  85. route = 'topic-detail';
  86. break;
  87. case 2:
  88. route = 'topic-detail2';
  89. break;
  90. case 3:
  91. route = 'topic-detail3';
  92. break;
  93. default:
  94. route = 'topic-detail'; // 默认路由
  95. }
  96. // 导航到指定的路由,并可以传递参数(如果需要)
  97. this.router.navigate([`tabs/${route}`, { id: topicId }]);
  98. }
  99. evaluate() {
  100. // 处理点击评价的逻辑
  101. console.log('用户点击了“进入评价”按钮');
  102. // 您可以导航到一个新的页面来让用户填写评价,或者显示一个模态框等。
  103. }
  104. review: any = { rating: 5 }; // 示例数据
  105. // 创建一个方法,用于生成填充了 null 的数组
  106. createFilledArray(length: number): any[] {
  107. return Array(length).fill(null);
  108. }
  109. ngOnInit() {}
  110. }