tab1.page.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // import { Component } from '@angular/core';
  2. // import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
  3. // import { ExploreContainerComponent } from '../explore-container/explore-container.component';
  4. // @Component({
  5. // selector: 'app-tab1',
  6. // templateUrl: 'tab1.page.html',
  7. // styleUrls: ['tab1.page.scss'],
  8. // imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent],
  9. // })
  10. // export class Tab1Page {
  11. // constructor() {}
  12. // }
  13. import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
  14. import {
  15. IonHeader, IonToolbar, IonSegment, IonSegmentButton, IonLabel,
  16. IonIcon, IonBadge, IonButtons, IonButton, IonSearchbar,
  17. IonContent, IonCard, IonCardContent, IonCardHeader,
  18. IonCardTitle, IonCardSubtitle, IonProgressBar, IonList,
  19. IonItem, IonThumbnail
  20. } from '@ionic/angular/standalone';
  21. import { CommonModule } from '@angular/common';
  22. import { FormsModule } from '@angular/forms';
  23. import { register } from 'swiper/element/bundle';
  24. // 注册 Swiper 组件
  25. register();
  26. @Component({
  27. selector: 'app-tab1',
  28. templateUrl: 'tab1.page.html',
  29. styleUrls: ['tab1.page.scss'],
  30. standalone: true,
  31. schemas: [CUSTOM_ELEMENTS_SCHEMA], // 添加这行以支持 Web Components
  32. imports: [
  33. CommonModule,
  34. FormsModule,
  35. IonHeader, IonToolbar, IonSegment, IonSegmentButton, IonLabel,
  36. IonIcon, IonBadge, IonButtons, IonButton, IonSearchbar,
  37. IonContent, IonCard, IonCardContent, IonCardHeader,
  38. IonCardTitle, IonCardSubtitle, IonProgressBar, IonList,
  39. IonItem, IonThumbnail
  40. ]
  41. })
  42. export class Tab1Page {
  43. selectedTab = 'recommend';
  44. isVip = false;
  45. hasCampActivity = true;
  46. unreadNotifications = true;
  47. searchQuery = '';
  48. searchHints = ['5日突击燃脂', '晨间瑜伽', 'HIIT训练', '零基础拉伸'];
  49. currentSearchHint = this.searchHints[0];
  50. // Swiper 配置
  51. swiperConfig = JSON.stringify({
  52. slidesPerView: 'auto',
  53. spaceBetween: 8,
  54. freeMode: true
  55. });
  56. // 快速入口分类
  57. quickAccessItems = [
  58. { name: '跑步', icon: 'walk-outline' },
  59. { name: '瑜伽', icon: 'body-outline' },
  60. { name: '行走', icon: 'footsteps-outline' },
  61. { name: '燃脂', icon: 'flame-outline' },
  62. { name: '直播课', icon: 'videocam-outline' },
  63. { name: '活动挑战', icon: 'trophy-outline' },
  64. { name: '数据统计', icon: 'stats-chart-outline' },
  65. { name: '商城', icon: 'cart-outline' }
  66. ];
  67. // 最近练习
  68. recentCourses = [
  69. {
  70. title: '活力燃脂走',
  71. image: 'assets/images/work-1.jpg',
  72. duration: '20分钟',
  73. level: 'K1 零基础',
  74. calories: 220,
  75. progress: 0.6
  76. },
  77. {
  78. title: '晨间唤醒瑜伽',
  79. image: 'assets/images/yoga1.jpg',
  80. duration: '15分钟',
  81. level: 'K1 零基础',
  82. calories: 180,
  83. progress: 0.3
  84. }
  85. ];
  86. // 热门课程
  87. popularCourses = [
  88. {
  89. title: '马甲线养成',
  90. image: 'assets/images/abs1.jpg',
  91. duration: '30分钟',
  92. level: 'K2 初级',
  93. calories: 280,
  94. participants: '10万+'
  95. },
  96. {
  97. title: '全身燃脂训练',
  98. image: 'assets/images/workout2.jpg',
  99. duration: '25分钟',
  100. level: 'K2 初级',
  101. calories: 320,
  102. participants: '8.2万+'
  103. }
  104. ];
  105. // 为你推荐
  106. recommendedCourses = [
  107. {
  108. title: '20分钟站立燃脂',
  109. image: 'assets/images/work-2.jpg',
  110. duration: '20分钟',
  111. level: 'K1 零基础',
  112. calories: 240,
  113. matchRate: 92,
  114. description: '无需器械,站立完成的高效燃脂训练'
  115. },
  116. {
  117. title: '深度睡眠冥想',
  118. image: 'assets/images/work-3.jpg',
  119. duration: '15分钟',
  120. level: 'K1 零基础',
  121. calories: 80,
  122. matchRate: 88,
  123. description: '帮助你快速入睡,提高睡眠质量'
  124. }
  125. ];
  126. // 解锁徽章
  127. unlockedBadges = [
  128. { name: '坚持之星', icon: 'star-outline' },
  129. { name: '燃脂达人', icon: 'flame-outline' },
  130. { name: '早起鸟', icon: 'alarm-outline' }
  131. ];
  132. constructor() {
  133. // 模拟搜索提示轮播
  134. setInterval(() => {
  135. const currentIndex = this.searchHints.indexOf(this.currentSearchHint);
  136. const nextIndex = (currentIndex + 1) % this.searchHints.length;
  137. this.currentSearchHint = this.searchHints[nextIndex];
  138. }, 3000);
  139. }
  140. openSearchModal() {
  141. console.log('打开搜索模态框');
  142. }
  143. openNotifications() {
  144. console.log('打开通知页面');
  145. }
  146. viewReport() {
  147. console.log('查看年度报告');
  148. }
  149. }