tab1.page.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { Component, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
  2. import {
  3. IonList, IonImg, IonContent, IonHeader, IonToolbar, IonTitle, IonCard, IonCardHeader, IonCardTitle,
  4. IonCardContent, IonAvatar, IonLabel, IonItem, IonButton, IonGrid, IonRow, IonCol, IonIcon, IonFooter, IonButtons
  5. } from '@ionic/angular/standalone';
  6. import { addIcons } from 'ionicons';
  7. import { analyticsOutline, personCircleOutline, chatbubblesOutline, barbellOutline, ellipse, square } from 'ionicons/icons';
  8. import Swiper from 'swiper';
  9. import { Router } from '@angular/router';
  10. import { CommonModule } from '@angular/common';
  11. import { DiscountBannerComponent } from '../discount-banner/discount-banner.component';
  12. @Component({
  13. selector: 'app-tab1',
  14. templateUrl: 'tab1.page.html',
  15. styleUrls: ['tab1.page.scss'],
  16. standalone: true,
  17. imports: [
  18. CommonModule,
  19. IonImg,
  20. IonContent,
  21. IonHeader,
  22. IonToolbar,
  23. IonTitle,
  24. IonCard,
  25. IonCardHeader,
  26. IonCardTitle,
  27. IonCardContent,
  28. IonAvatar,
  29. IonLabel,
  30. IonItem,
  31. IonButton,
  32. IonGrid,
  33. IonRow,
  34. IonCol,
  35. IonIcon,
  36. IonFooter,
  37. IonButtons,
  38. IonList,
  39. DiscountBannerComponent,
  40. ],
  41. })
  42. export class Tab1Page implements OnInit, AfterViewInit, OnDestroy {
  43. users = [
  44. {
  45. avatarUrl: '../assets/beautiful.jpg',
  46. name: '小敏',
  47. recommendation: '作为上班族,以前没时间去健身房,WisefitnessApp让我在家就能轻松锻炼,还能获取个性化饮食建议,健康生活触手可及!'
  48. },
  49. // 可以添加更多用户数据
  50. ];
  51. countdown: string = ''; // 倒计时字符串
  52. private countdownInterval: any; // 保存计时器引用
  53. constructor(private router: Router) { }
  54. ngOnInit() {
  55. // 添加图标
  56. addIcons({
  57. analyticsOutline,
  58. personCircleOutline,
  59. chatbubblesOutline,
  60. barbellOutline,
  61. ellipse,
  62. square
  63. });
  64. }
  65. ngAfterViewInit() {
  66. // 初始化 Swiper
  67. new Swiper('.swiper-container', {
  68. loop: true, // 开启循环
  69. pagination: {
  70. el: '.swiper-pagination', // 分页器
  71. clickable: true
  72. },
  73. autoplay: {
  74. delay: 5000 // 自动切换时间间隔
  75. }
  76. });
  77. }
  78. ngOnDestroy() {
  79. // 清除计时器
  80. if (this.countdownInterval) {
  81. clearInterval(this.countdownInterval);
  82. }
  83. }
  84. // 页面导航功能
  85. goToTestPage() {
  86. this.router.navigate(['tabs/test-page']); // 跳转到 Test 页面
  87. }
  88. goToLogin() {
  89. this.router.navigate(['/login']);
  90. }
  91. goToReviews() {
  92. this.router.navigate(['/user-reviews']);
  93. }
  94. openPrivacyPolicy() {
  95. this.router.navigate(['/privacy-policy']);
  96. }
  97. openTermsOfService() {
  98. this.router.navigate(['/terms-of-service']);
  99. }
  100. }