123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import { Component,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
- import { IonHeader, IonToolbar,IonContent, IonAvatar, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonLabel, IonList,
- IonItem,IonIcon,IonSearchbar} from '@ionic/angular/standalone';
- import { CommonModule } from '@angular/common';
- import { Router } from '@angular/router';
- import { CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud';
- import { ModalController } from '@ionic/angular/standalone';
- import { openUserEvaModal } from '../user-evaluate/user-evaluate.component';
- import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-login.component';
- @Component({
- selector: 'app-tab1',
- templateUrl: 'tab1.page.html',
- styleUrls: ['tab1.page.scss'],
- standalone: true,
- imports: [IonHeader,IonToolbar,IonContent,
- IonButtons,IonButton,IonIcon,
- IonCard,IonCardContent,IonCardHeader,
- IonLabel,IonList,IonItem,IonAvatar,IonSearchbar,
- CommonModule,
- ],
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
- })
- export class Tab1Page {
- onSearch(event: any) {
- const searchTerm = event.target.value; // 获取用户输入的搜索内容
- console.log('搜索内容:', searchTerm);
- // 在这里添加搜索逻辑,例如过滤列表或导航到搜索结果页面
- }
- topics = [
- {
- id: 1,
- title: '如何管理焦虑情绪',
- description: '了解焦虑的来源及应对策略',
- detailRoute: 'topic-detail',
- },
- {
- id: 2,
- title: '克服抑郁的有效方法',
- description: '探索抑郁症的应对技巧',
- detailRoute: 'topic-detail2'
- },
- {
- id: 3,
- title: '提升自信心的技巧',
- description: '学习如何建立自信',
- detailRoute: 'topic-detail2'
- }
- ];
-
- async goPsysurvey() {
- // 验证用户登录
- let currentUser = new CloudUser();
- if(!currentUser?.id){
- console.log("用户未登录,请登录后重试")
- let user = await openUserLoginModal(this.modalCtrl)
- if(!user?.id){
- console.log("用户登录失败");
- return
- }
- else {
- console.log("当前用户ID:", currentUser.id);
- }
- }
- this.router.navigate(['tabs/page-psysurvey'])
- }
- async goDriftbottle() {
- // 验证用户登录
- let currentUser = new CloudUser();
- if(!currentUser?.id){
- console.log("用户未登录,请登录后重试")
- let user = await openUserLoginModal(this.modalCtrl)
- if(!user?.id){
- console.log("用户登录失败");
- return
- }
- else {
- console.log("当前用户ID:", currentUser.id);
- }
- }
- this.router.navigate(['tabs/drift-bottle'])
- }
-
- 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 }]);
- }
- constructor(private router: Router,private modalCtrl: ModalController) {
- // 其他构造函数代码
- }
- matchedCounselor: { content: string; rating: number } | null = null;
- review: any = { rating: 5 }; // 示例数据
- // 创建一个方法,用于生成填充了 null 的数组
- createFilledArray(length: number): any[] {
- // 确保返回的数组长度不超过5
- const maxStars = 5;
- return Array(Math.min(length, maxStars)).fill(null);
- }
- async evaluate() {
- // 验证用户登录
- let currentUser = new CloudUser();
- if(!currentUser?.id){
- console.log("用户未登录,请登录后重试")
- let user = await openUserLoginModal(this.modalCtrl)
- if(!user?.id){
- console.log("用户登录失败");
- return
- }
- else {
- console.log("当前用户ID:", currentUser.id);
- }
- }
- // 打开评价模态框
- const evaluationResult = await openUserEvaModal(this.modalCtrl);
- // 如果评价成功,重新加载评价列表
- if (evaluationResult) {
- await this.loadChatEvaluateList(); // 重新加载评价列表
- }
- }
- ngOnInit() {
- this.loadChatEvaluateList()
- }
- chatevaluateList:Array<CloudObject>=[]
- async loadChatEvaluateList(){
- let query = new CloudQuery("ChatEvaluate");
- this.chatevaluateList = await query.find()
- }
- navigateToUpdatingPage() {
- this.router.navigate(['tabs/page-updating']);
- }
- }
|