Browse Source

feat.liao.7.0

19136808282 3 months ago
parent
commit
bdbc3ea1da

+ 142 - 0
.history/soul-app/src/app/tab1/tab1.page_20241228132832.ts

@@ -0,0 +1,142 @@
+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()
+  }
+}

+ 28 - 2
soul-app/src/app/tab1/tab1.page.ts

@@ -47,10 +47,36 @@ export class Tab1Page {
     }
   ];
   
-  goPsysurvey() {
+  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'])
   }
-  goDriftbottle() {
+  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'])
   }