tab1.page.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import { Component } from '@angular/core';
  2. import { CommonModule } from '@angular/common'; // 导入 CommonModule
  3. import { IonHeader, IonToolbar, IonTitle, IonContent, IonSearchbar, IonCard, IonCardHeader, IonCardTitle, IonCardSubtitle, IonCardContent, IonItem, IonLabel, IonList, IonFooter, AlertController } from '@ionic/angular/standalone';
  4. import { ExploreContainerComponent } from '../explore-container/explore-container.component';
  5. import { EditRatingStarComponent } from '../edit-rating-star/edit-rating-star.component';
  6. import { Router } from '@angular/router';
  7. import { IonButton } from '@ionic/angular/standalone';
  8. import { IonIcon } from '@ionic/angular/standalone';
  9. import { addIcons } from 'ionicons';
  10. import { bagAddOutline, ellipsisHorizontalOutline, imagesOutline } from 'ionicons/icons';
  11. import { CloudObject, CloudQuery } from 'src/lib/ncloud';
  12. import { IonThumbnail } from '@ionic/angular/standalone';
  13. addIcons({ bagAddOutline, imagesOutline, ellipsisHorizontalOutline})
  14. @Component({
  15. selector: 'app-tab1',
  16. templateUrl: 'tab1.page.html',
  17. styleUrls: ['tab1.page.scss'],
  18. standalone: true,
  19. imports: [
  20. CommonModule, // 在 imports 中加入 CommonModule
  21. IonHeader, IonToolbar, IonTitle, IonContent, IonSearchbar,
  22. IonCard, IonCardHeader, IonCardTitle, IonCardSubtitle, IonCardContent,
  23. IonItem, IonLabel, IonList, IonFooter, ExploreContainerComponent ,
  24. EditRatingStarComponent, IonButton, IonIcon,
  25. IonThumbnail
  26. ],
  27. })
  28. export class Tab1Page {
  29. constructor(private router: Router, private alertController: AlertController) {}
  30. /**
  31. * 轮播图
  32. */
  33. images = [
  34. 'https://s2.loli.net/2024/12/22/lE4XKeWr6v8jTqa.png',
  35. 'https://s2.loli.net/2024/12/22/9v1bO8A4sESxWV6.png',
  36. 'https://s2.loli.net/2024/12/22/I28ScHtd5jnULyo.png',
  37. ];
  38. currentSlide = 0;
  39. intervalId: any;
  40. setSlidePosition() {
  41. // 这里不需要额外的逻辑,因为在 HTML 中已经通过绑定实现
  42. }
  43. nextSlide() {
  44. this.currentSlide = (this.currentSlide + 1) % this.images.length;
  45. }
  46. prevSlide() {
  47. this.currentSlide = (this.currentSlide - 1 + this.images.length) % this.images.length;
  48. }
  49. goToSlide(index: number) {
  50. this.currentSlide = index;
  51. }
  52. startAutoSlide() {
  53. this.intervalId = setInterval(() => this.nextSlide(), 3000);
  54. }
  55. ngOnDestroy() {
  56. if (this.intervalId) {
  57. clearInterval(this.intervalId);
  58. }
  59. }
  60. goToPage1(){
  61. this.router.navigate(['/tabs/picture'])
  62. }
  63. goToPage2(){
  64. this.router.navigate(['/tabs/inquiry'])
  65. }
  66. goToKnowledge(knowledge: CloudObject){
  67. const objectId = knowledge.get('title'); // 假设你的主键字段为 'title'
  68. this.router.navigate(['/tabs/knowledge-page', { id: objectId }]);
  69. }
  70. goToKnowledgeTotal(){
  71. this.router.navigate(['/tabs/knowledge-total'])
  72. }
  73. // currentScore: number = 0; // 初始分值
  74. // handleScoreChange(newScore: number) {
  75. // this.currentScore = newScore;
  76. // console.log('新分值:', newScore); // 处理分值变化
  77. // }
  78. // items = [
  79. // {
  80. // title: '医疗技术',
  81. // description: '我们提供最新的医疗设备和技术,帮助提高医护质量和效率。',
  82. // image: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.NHe6NqhU0qZ_qLO0DQ08pAHaFj?rs=1&pid=ImgDetMain'
  83. // },
  84. // {
  85. // title: '健康管理',
  86. // description: '专业的健康管理方案,确保您的身体健康得到最佳维护。',
  87. // image: ''
  88. // },
  89. // {
  90. // title: '护理服务',
  91. // description: '我们提供全面的护理服务,为患者提供贴心的照顾。',
  92. // image: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.N6uSj6zCe2pDw7vA4fcYuAHaE7?w=214&h=180&c=7&r=0&o=5&dpr=1.5&pid=1.7'
  93. // }
  94. // ];
  95. ngOnInit() {
  96. // 生命周期:页面加载后,运行医生列表加载函数
  97. this.loadKnowledgeList()
  98. }
  99. // 创建用于数据列表存储的属性
  100. knowledgeList:Array<CloudObject> = []
  101. // 查询并加载医生列表的函数
  102. async loadKnowledgeList(){
  103. let query = new CloudQuery("Knowledge");
  104. const allKnowledge = await query.find();
  105. this.knowledgeList = allKnowledge.slice(0, 4);
  106. }
  107. async presentAlert() {
  108. const alert = await this.alertController.create({
  109. message: '敬请期待!',
  110. buttons: ['确定'],
  111. });
  112. await alert.present();
  113. }
  114. search(event: CustomEvent) {
  115. const searchTerm = event.detail.value;
  116. console.log('搜索内容:', searchTerm);
  117. // 在这里可以添加搜索逻辑,如过滤 items 数组
  118. }
  119. }