|
@@ -1,13 +1,18 @@
|
|
|
-import { Component, OnInit,CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
import { Router } from '@angular/router';
|
|
|
import { CloudSeUser } from 'src/lib/cloudSeuser'; // 引入 CloudSeUser 类
|
|
|
import { FmodeChatCompletion } from 'fmode-ng'; // 引入 FmodeChatCompletion
|
|
|
import { addIcons } from 'ionicons';
|
|
|
import { albumsOutline, documentOutline, leafOutline, scanOutline, storefrontOutline } from 'ionicons/icons';
|
|
|
-import { IonButton, IonCard, IonCardContent, IonCardHeader, IonCol, IonContent, IonHeader, IonIcon, IonInput, IonRow, IonTextarea, IonTitle, IonToolbar, IonGrid, IonCardTitle, IonSearchbar,} from '@ionic/angular/standalone'; // 导入 Ionic 组件
|
|
|
+import { IonButton, IonCard, IonCardContent, IonCardHeader, IonCol, IonContent, IonHeader, IonIcon, IonInput, IonRow, IonTextarea, IonTitle, IonToolbar, IonGrid, IonCardTitle, IonSearchbar } from '@ionic/angular/standalone'; // 导入 Ionic 组件
|
|
|
import { CommonModule } from '@angular/common'; // 导入 CommonModule
|
|
|
import { ImagePopupComponent } from '../image-popup/image-popup.component'; // 导入弹窗组件
|
|
|
-import { ModalController,NavController} from '@ionic/angular/standalone';
|
|
|
+import { ModalController, NavController } from '@ionic/angular/standalone';
|
|
|
+import { Image1PopupComponent } from '../image-popup/image1-popup/image1-popup.component';
|
|
|
+import { Image2PopupComponent } from '../image-popup/image2-popup/image2-popup.component';
|
|
|
+import { Image3PopupComponent } from '../image-popup/image3-popup/image3-popup.component';
|
|
|
+import { Image4PopupComponent } from '../image-popup/image4-popup/image4-popup.component';
|
|
|
+
|
|
|
@Component({
|
|
|
selector: 'app-tab1',
|
|
|
templateUrl: 'tab1.page.html',
|
|
@@ -16,7 +21,7 @@ import { ModalController,NavController} from '@ionic/angular/standalone';
|
|
|
imports: [
|
|
|
CommonModule, IonContent, IonHeader, IonTitle, IonToolbar,
|
|
|
IonButton, IonTextarea, IonInput, IonCard, IonCardContent, IonGrid, IonRow, IonCol, IonIcon,
|
|
|
- IonCardHeader,IonCardTitle,IonSearchbar,
|
|
|
+ IonCardHeader, IonCardTitle, IonSearchbar,
|
|
|
],
|
|
|
})
|
|
|
export class Tab1Page implements OnInit {
|
|
@@ -29,11 +34,18 @@ export class Tab1Page implements OnInit {
|
|
|
// 存储图片的数组
|
|
|
images = [
|
|
|
'https://app.fmode.cn/dev/jxnu/202226701038/ssbt2022.jpg',
|
|
|
- 'https://app.fmode.cn/dev/jxnu/202226701038/ssbt2022.jpg',
|
|
|
- 'https://app.fmode.cn/dev/jxnu/202226701038/ssbt2022.jpg',
|
|
|
- 'https://app.fmode.cn/dev/jxnu/202226701038/ssbt2022.jpg'
|
|
|
+ 'https://app.fmode.cn/dev/jxnu/202226701038/ssbt2021.jpg',
|
|
|
+ '',
|
|
|
+ ''
|
|
|
];
|
|
|
|
|
|
+// 每张图片的描述
|
|
|
+ descriptions = [
|
|
|
+ '<p><strong>第一张图片</strong></p>',
|
|
|
+ '<p><strong>第二张图片</strong></p>',
|
|
|
+ '<p><strong>第三张图片</strong></p>',
|
|
|
+ '<p><strong>第四张图片</strong></p>'
|
|
|
+ ];
|
|
|
// 当前显示的幻灯片索引
|
|
|
currentSlide: number = 0;
|
|
|
|
|
@@ -70,7 +82,7 @@ export class Tab1Page implements OnInit {
|
|
|
} catch (error) {
|
|
|
console.error('加载用户数据失败', error);
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
// 获取健康建议
|
|
|
async goHealthTips() {
|
|
@@ -122,34 +134,62 @@ export class Tab1Page implements OnInit {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- // 打开弹窗
|
|
|
-async openImagePopup(imageUrl: string, description: string) {
|
|
|
- try {
|
|
|
- const modal = await this.modalCtrl.create({
|
|
|
- component: ImagePopupComponent,
|
|
|
- componentProps: { imageUrl, description }
|
|
|
- });
|
|
|
- await modal.present();
|
|
|
- } catch (error) {
|
|
|
- console.error('打开弹窗时出错', error); // 捕获并输出错误
|
|
|
- }
|
|
|
-}
|
|
|
+ // 打开弹窗
|
|
|
+ async openImagePopup(imageUrl: string, description: string) {
|
|
|
+ let modal;
|
|
|
+
|
|
|
+ // 根据图片的 URL 或其他参数动态加载弹窗组件
|
|
|
+ if (imageUrl === this.images[0]) {
|
|
|
+ modal = await this.modalCtrl.create({
|
|
|
+ component: Image1PopupComponent,
|
|
|
+ componentProps: {
|
|
|
+ imageUrl: imageUrl,
|
|
|
+ description: description
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (imageUrl === this.images[1]) {
|
|
|
+ modal = await this.modalCtrl.create({
|
|
|
+ component: Image2PopupComponent,
|
|
|
+ componentProps: {
|
|
|
+ imageUrl: imageUrl,
|
|
|
+ description: description
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (imageUrl === this.images[2]) {
|
|
|
+ modal = await this.modalCtrl.create({
|
|
|
+ component: Image3PopupComponent,
|
|
|
+ componentProps: {
|
|
|
+ imageUrl: imageUrl,
|
|
|
+ description: description
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (imageUrl === this.images[3]) {
|
|
|
+ modal = await this.modalCtrl.create({
|
|
|
+ component: Image4PopupComponent,
|
|
|
+ componentProps: {
|
|
|
+ imageUrl: imageUrl,
|
|
|
+ description: description
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ if (modal) {
|
|
|
+ await modal.present();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 点击轮播图
|
|
|
-async onImageClick(index: number) {
|
|
|
-const descriptions = [
|
|
|
- '<p><strong>第一张图片</strong>的描述内容。<br>这里有更多的文字,还可以使用 <em>斜体</em> 和 <u>下划线</u>。</p>',
|
|
|
- '<p><strong>第二张图片</strong>的描述内容。<br>此描述支持更复杂的布局和<strong>加粗文本</strong>。</p>',
|
|
|
- '<p><strong>第三张图片</strong>的描述内容。<br>您可以在这里插入更多的 <a href="#">链接</a> 或者其他 HTML 元素。</p>',
|
|
|
- '<p><strong>第四张图片</strong>的描述内容。<br>支持多行内容和 <em>各种格式</em>。</p>'
|
|
|
-];
|
|
|
-
|
|
|
-
|
|
|
- // 打开弹窗并传递描述
|
|
|
- await this.openImagePopup(this.images[index], descriptions[index]);
|
|
|
-}
|
|
|
-
|
|
|
+ async onImageClick(index: number) {
|
|
|
+ const descriptions = [
|
|
|
+ '<p><strong>第一张图片</strong></p>',
|
|
|
+ '<p><strong>第二张图片</strong></p>',
|
|
|
+ '<p><strong>第三张图片</strong></p>',
|
|
|
+ '<p><strong>第四张图片</strong></p>'
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 打开弹窗并传递描述
|
|
|
+ await this.openImagePopup(this.images[index], descriptions[index]);
|
|
|
+ }
|
|
|
|
|
|
// 前一个幻灯片
|
|
|
prevSlide() {
|
|
@@ -174,8 +214,9 @@ const descriptions = [
|
|
|
this.currentSlide = index;
|
|
|
}
|
|
|
|
|
|
- // 跳转到饮食建议页面
|
|
|
- goHealthTipsPage() {
|
|
|
- this.router.navigate([`/tabs/tips`]);
|
|
|
+ // 跳转到饮食建议页面
|
|
|
+ goHealthTipsPage() {
|
|
|
+ this.router.navigate([`/tabs/tips`]);
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+
|