import { Component,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { IonHeader, IonToolbar, IonTitle, IonContent, IonAvatar, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonLabel, IonList, IonItem,IonIcon,IonInput,IonSearchbar} from '@ionic/angular/standalone'; import { ExploreContainerComponent } from '../explore-container/explore-container.component'; import { CommonModule } from '@angular/common'; import { TopicDetailComponent } from '../topic-detail/topic-detail.component'; import { Router } from '@angular/router'; import { TopicDetail2Component } from '../topic-detail2/topic-detail2.component'; import { TopicDetail3Component } from '../topic-detail3/topic-detail3.component'; @Component({ selector: 'app-tab1', templateUrl: 'tab1.page.html', styleUrls: ['tab1.page.scss'], standalone: true, imports: [IonHeader,IonToolbar,IonTitle,IonContent,ExploreContainerComponent, IonButtons,IonButton,IonIcon, IonCard,IonCardContent,IonCardHeader, IonLabel,IonList,IonItem,IonAvatar, IonInput,IonSearchbar, CommonModule, TopicDetailComponent,TopicDetail2Component,TopicDetail3Component ], schemas: [CUSTOM_ELEMENTS_SCHEMA], }) export class Tab1Page { onSearch(event: any) { const searchTerm = event.target.value; // 获取用户输入的搜索内容 console.log('搜索内容:', searchTerm); // 在这里添加搜索逻辑,例如过滤列表或导航到搜索结果页面 } consultants = [ { name: '智能心理咨询师', avatar: '/assets/img/2.png', fields: ['焦虑', '抑郁','压力','...'] } ]; topics = [ { id: 1, title: '如何管理焦虑情绪', description: '了解焦虑的来源及应对策略', detailRoute: 'topic-detail', }, { id: 2, title: '克服抑郁的有效方法', description: '探索抑郁症的应对技巧', detailRoute: 'topic-detail2' }, { id: 3, title: '提升自信心的技巧', description: '学习如何建立自信', detailRoute: 'topic-detail2' } ]; reviews = [ { avatar: '/assets/img/4.png', content: '这款APP真的帮助了我,感谢陪聊师!', rating: 4 }, { avatar: '/assets/img/5.png', content: '非常实用的心理咨询平台!', rating: 5 }, { avatar: '/assets/img/6.png', content: '我喜欢这里的热门话题!', rating: 4 } ]; constructor(private router: Router) { // 其他构造函数代码 } clickToConsult() { // 点击咨询 this.router.navigate(['tabs/page-consult']) } viewDetails(topicId: number): void { let route: string; switch (topicId) { case 1: route = 'topic-detail'; break; case 2: route = 'topic-detail2'; break; case 3: route = 'topic-detail3'; break; default: route = 'topic-detail'; // 默认路由 } // 导航到指定的路由,并可以传递参数(如果需要) this.router.navigate([`tabs/${route}`, { id: topicId }]); } evaluate() { // 处理点击评价的逻辑 console.log('用户点击了“进入评价”按钮'); // 您可以导航到一个新的页面来让用户填写评价,或者显示一个模态框等。 } review: any = { rating: 5 }; // 示例数据 // 创建一个方法,用于生成填充了 null 的数组 createFilledArray(length: number): any[] { return Array(length).fill(null); } ngOnInit() {} }