Kaynağa Gözat

Merge branch 'master' of http://git.fmode.cn:3000/15879006906/s202226701040

刘嘉轩 7 ay önce
ebeveyn
işleme
6c791a1e59
23 değiştirilmiş dosya ile 542 ekleme ve 96 silme
  1. 3 1
      smarteat-app/deploy.ps1
  2. 13 0
      smarteat-app/src/app/image-popup/image-popup.component.html
  3. 0 0
      smarteat-app/src/app/image-popup/image-popup.component.scss
  4. 22 0
      smarteat-app/src/app/image-popup/image-popup.component.spec.ts
  5. 24 0
      smarteat-app/src/app/image-popup/image-popup.component.ts
  6. 13 0
      smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.html
  7. 0 0
      smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.scss
  8. 22 0
      smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.spec.ts
  9. 22 0
      smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.ts
  10. 14 0
      smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.html
  11. 0 0
      smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.scss
  12. 22 0
      smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.spec.ts
  13. 22 0
      smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.ts
  14. 14 0
      smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.html
  15. 0 0
      smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.scss
  16. 22 0
      smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.spec.ts
  17. 22 0
      smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.ts
  18. 14 0
      smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.html
  19. 0 0
      smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.scss
  20. 22 0
      smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.spec.ts
  21. 22 0
      smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.ts
  22. 67 71
      smarteat-app/src/app/tab1/tab1.page.html
  23. 182 24
      smarteat-app/src/app/tab1/tab1.page.ts

+ 3 - 1
smarteat-app/deploy.ps1

@@ -1,7 +1,7 @@
 # 打包项目,携带应用前缀(index.html中相对路径将自动修复为/dev/jxnu/202226701038前缀)
 # /dev/ 项目测试版上传路径
 # /dev/jxnu/202226701038 nova-crm项目预留路径
-set NODE_OPTIONS=–max_old_space_size=16000
+set NODE_OPTIONS –max_old_space_size=16000
 node ./node_modules/@angular/cli/bin/ng build --base-href="/dev/jxnu/202226701038/"
 
 # 清空旧文件目录
@@ -18,3 +18,5 @@ obsutil chattri obs://nova-cloud/dev/jxnu/202226701038 -r -f -i=XSUWJSVMZNHLWFAI
 # 列举对象
 obsutil ls obs://nova-cloud/dev/jxnu/202226701038  -i=XSUWJSVMZNHLWFAINRZ1 -k=P4TyfwfDovVNqz08tI1IXoLWXyEOSTKJRVlsGcV6 -e="obs.cn-south-1.myhuaweicloud.com"
 
+obsutil cp ssbt2022.jpg obs://nova-cloud/dev/jxnu/202226701038/ -f -i XSUWJSVMZNHLWFAINRZ1 -k P4TyfwfDovVNqz08tI1IXoLWXyEOSTKJRVlsGcV6 -e obs.cn-south-1.myhuaweicloud.com
+obsutil ls obs://nova-cloud/dev/jxnu/202226701038 -i XSUWJSVMZNHLWFAINRZ1 -k P4TyfwfDovVNqz08tI1IXoLWXyEOSTKJRVlsGcV6 -e obs.cn-south-1.myhuaweicloud.com

+ 13 - 0
smarteat-app/src/app/image-popup/image-popup.component.html

@@ -0,0 +1,13 @@
+<ion-content>
+  <ion-header>
+    <ion-toolbar>
+      <ion-title>图片详情</ion-title>
+      <ion-buttons slot="end">
+        <ion-button (click)="close()">关闭</ion-button>
+      </ion-buttons>
+    </ion-toolbar>
+  </ion-header>
+
+  <!-- 动态加载传递的组件 -->
+  <ng-container *ngComponentOutlet="component"></ng-container>
+</ion-content>

+ 0 - 0
smarteat-app/src/app/image-popup/image-popup.component.scss


+ 22 - 0
smarteat-app/src/app/image-popup/image-popup.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { ImagePopupComponent } from './image-popup.component';
+
+describe('ImagePopupComponent', () => {
+  let component: ImagePopupComponent;
+  let fixture: ComponentFixture<ImagePopupComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [ImagePopupComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(ImagePopupComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 24 - 0
smarteat-app/src/app/image-popup/image-popup.component.ts

@@ -0,0 +1,24 @@
+import { Component, Input, Type } from '@angular/core';
+import { ModalController } from '@ionic/angular';
+import { IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonTitle, IonToolbar } from '@ionic/angular/standalone';
+
+@Component({
+  selector: 'app-image-popup',
+  templateUrl: './image-popup.component.html',
+  styleUrls: ['./image-popup.component.scss'],
+  standalone: true,
+  imports: [
+    IonContent, IonHeader, IonButton, IonButtons, IonToolbar, IonTitle, IonIcon
+  ]
+})
+export class ImagePopupComponent {
+  @Input() imageUrl: string = '';  // 图片URL
+  @Input() description: string = '';  // 图片描述
+  @Input() component: Type<any> | null = null;  // 动态加载的组件
+
+  constructor(private modalController: ModalController) {}
+
+  close() {
+    this.modalController.dismiss();
+  }
+}

+ 13 - 0
smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.html

@@ -0,0 +1,13 @@
+<ion-content>
+  <ion-header>
+    <ion-toolbar>
+      <ion-title>1图片详情</ion-title>
+      <ion-buttons slot="end">
+        <ion-button (click)="close()">关闭</ion-button>
+      </ion-buttons>
+    </ion-toolbar>
+  </ion-header>
+
+  <!-- 动态加载传递的组件 -->
+  <ng-container *ngComponentOutlet="component"></ng-container>
+</ion-content>

+ 0 - 0
smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.scss


+ 22 - 0
smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { Image1PopupComponent } from './image1-popup.component';
+
+describe('Image1PopupComponent', () => {
+  let component: Image1PopupComponent;
+  let fixture: ComponentFixture<Image1PopupComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [Image1PopupComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(Image1PopupComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 22 - 0
smarteat-app/src/app/image-popup/image1-popup/image1-popup.component.ts

@@ -0,0 +1,22 @@
+import { Component, Input } from '@angular/core';
+import { IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonTitle, IonToolbar, ModalController } from '@ionic/angular/standalone';
+
+@Component({
+  selector: 'app-image1-popup',
+  templateUrl: './image1-popup.component.html',
+  styleUrls: ['./image1-popup.component.scss'],
+  standalone: true,
+  imports: [IonContent, IonHeader, IonButton, IonButtons, IonToolbar, IonTitle, IonIcon]
+})
+export class Image1PopupComponent {
+  @Input() imageUrl: string = '';
+  @Input() description: string = '';
+
+  constructor(private modalController: ModalController) {}
+  ngOnInit() {console.log(this.description)}
+  
+
+  close() {
+    this.modalController.dismiss();
+  }
+}

+ 14 - 0
smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.html

@@ -0,0 +1,14 @@
+<ion-content>
+  <ion-header>
+    <ion-toolbar>
+      <ion-title>2图片详情</ion-title>
+      <ion-buttons slot="end">
+        <ion-button (click)="close()">关闭</ion-button>
+      </ion-buttons>
+    </ion-toolbar>
+  </ion-header>
+
+  <!-- 显示图片和描述 -->
+  <img [src]="imageUrl" alt="图片" style="width: 100%; height: auto;">
+  <div [innerHTML]="description"></div>
+</ion-content>

+ 0 - 0
smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.scss


+ 22 - 0
smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { Image2PopupComponent } from './image2-popup.component';
+
+describe('Image2PopupComponent', () => {
+  let component: Image2PopupComponent;
+  let fixture: ComponentFixture<Image2PopupComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [Image2PopupComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(Image2PopupComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 22 - 0
smarteat-app/src/app/image-popup/image2-popup/image2-popup.component.ts

@@ -0,0 +1,22 @@
+import { Component, Input } from '@angular/core';
+import { IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonTitle, IonToolbar, ModalController } from '@ionic/angular/standalone';
+
+@Component({
+  selector: 'app-image2-popup',
+  templateUrl: './image2-popup.component.html',
+  styleUrls: ['./image2-popup.component.scss'],
+  standalone: true,
+  imports: [IonContent, IonHeader, IonButton, IonButtons, IonToolbar, IonTitle, IonIcon]
+})
+export class Image2PopupComponent {
+  @Input() imageUrl: string = '';
+  @Input() description: string = '';
+
+  constructor(private modalController: ModalController) {}
+
+  ngOnInit() {}
+
+  close() {
+    this.modalController.dismiss();
+  }
+}

+ 14 - 0
smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.html

@@ -0,0 +1,14 @@
+<ion-content>
+  <ion-header>
+    <ion-toolbar>
+      <ion-title>3图片详情</ion-title>
+      <ion-buttons slot="end">
+        <ion-button (click)="close()">关闭</ion-button>
+      </ion-buttons>
+    </ion-toolbar>
+  </ion-header>
+
+  <!-- 显示图片和描述 -->
+  <img [src]="imageUrl" alt="图片" style="width: 100%; height: auto;">
+  <div [innerHTML]="description"></div>
+</ion-content>

+ 0 - 0
smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.scss


+ 22 - 0
smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { Image3PopupComponent } from './image3-popup.component';
+
+describe('Image3PopupComponent', () => {
+  let component: Image3PopupComponent;
+  let fixture: ComponentFixture<Image3PopupComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [Image3PopupComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(Image3PopupComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 22 - 0
smarteat-app/src/app/image-popup/image3-popup/image3-popup.component.ts

@@ -0,0 +1,22 @@
+import { Component, Input } from '@angular/core';
+import { IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonTitle, IonToolbar, ModalController } from '@ionic/angular/standalone';
+
+@Component({
+  selector: 'app-image3-popup',
+  templateUrl: './image3-popup.component.html',
+  styleUrls: ['./image3-popup.component.scss'],
+  standalone: true,
+  imports: [IonContent, IonHeader, IonButton, IonButtons, IonToolbar, IonTitle, IonIcon]
+})
+export class Image3PopupComponent {
+  @Input() imageUrl: string = '';
+  @Input() description: string = '';
+
+  constructor(private modalController: ModalController) {}
+
+  ngOnInit() {}
+
+  close() {
+    this.modalController.dismiss();
+  }
+}

+ 14 - 0
smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.html

@@ -0,0 +1,14 @@
+<ion-content>
+  <ion-header>
+    <ion-toolbar>
+      <ion-title>4图片详情</ion-title>
+      <ion-buttons slot="end">
+        <ion-button (click)="close()">关闭</ion-button>
+      </ion-buttons>
+    </ion-toolbar>
+  </ion-header>
+
+  <!-- 显示图片和描述 -->
+  <img [src]="imageUrl" alt="图片" style="width: 100%; height: auto;">
+  <div [innerHTML]="description"></div>
+</ion-content>

+ 0 - 0
smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.scss


+ 22 - 0
smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.spec.ts

@@ -0,0 +1,22 @@
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+
+import { Image4PopupComponent } from './image4-popup.component';
+
+describe('Image4PopupComponent', () => {
+  let component: Image4PopupComponent;
+  let fixture: ComponentFixture<Image4PopupComponent>;
+
+  beforeEach(waitForAsync(() => {
+    TestBed.configureTestingModule({
+      imports: [Image4PopupComponent],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(Image4PopupComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  }));
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 22 - 0
smarteat-app/src/app/image-popup/image4-popup/image4-popup.component.ts

@@ -0,0 +1,22 @@
+import { Component, Input } from '@angular/core';
+import { IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonTitle, IonToolbar, ModalController } from '@ionic/angular/standalone';
+
+@Component({
+  selector: 'app-image4-popup',
+  templateUrl: './image4-popup.component.html',
+  styleUrls: ['./image4-popup.component.scss'],
+  standalone: true,
+  imports: [IonContent, IonHeader, IonButton, IonButtons, IonToolbar, IonTitle, IonIcon]
+})
+export class Image4PopupComponent {
+    // 使用 @Input() 来接收来自父组件传递的数据
+    @Input() imageUrl: string = '';
+    @Input() description: string = '';
+  
+    constructor(private modalController: ModalController) {}
+  ngOnInit() {}
+
+  close() {
+    this.modalController.dismiss();
+  }
+}

+ 67 - 71
smarteat-app/src/app/tab1/tab1.page.html

@@ -1,79 +1,75 @@
-
-  <ion-toolbar >
-    <ion-searchbar class="custom-searchbar" placeholder="搜索食物、食谱、餐厅" show-clear-button="focus"></ion-searchbar>
-  </ion-toolbar>
+<ion-toolbar>
+  <ion-searchbar class="custom-searchbar" placeholder="搜索食物、食谱、餐厅" show-clear-button="focus"></ion-searchbar>
+</ion-toolbar>
 
 <ion-content [fullscreen]="true">
-   <!-- 轮播图区域 -->
-   <div class="carousel-container" style="border-radius: 25px; margin: 5px auto;">
-    <div class="carousel" [style.transform]="'translateX(-' + currentSlide * 100 + '%)'">
-      <div class="slide" *ngFor="let image of images">
-        <img [src]="image" alt="轮播图">
-      </div>
-    </div>
-  
-    <button class="prev" (click)="prevSlide()">&#10094;</button>
-    <button class="next" (click)="nextSlide()">&#10095;</button>
-  
-    <div class="dots">
-      <span class="dot" *ngFor="let image of images; let i = index" 
-            [class.active]="i === currentSlide" 
-            (click)="goToSlide(i)"></span>
+  <!-- 轮播图区域 -->
+<div class="carousel-container" style="border-radius: 25px; margin: 5px auto;">
+  <div class="carousel" [style.transform]="'translateX(-' + currentSlide * 100 + '%)'">
+    <div class="slide" *ngFor="let image of images; let i = index"> <!-- 添加 let i = index -->
+      <img [src]="image" (click)="openImagePopup(image, descriptions[i])" style="width: 100%; height: auto;" />
     </div>
   </div>
 
-<!-- 推荐健康建议 -->
-<ion-card>
-<ion-card-header>
-  
-  <ion-card-title>
-    <ion-icon  slot="start" name="leaf-outline"></ion-icon>
-    健康建议
-  </ion-card-title>
-</ion-card-header>
-<ion-card-content>
-  <ion-button (click)="goHealthTips()" >
-    <!-- <ion-icon  slot="start" name="leaf-outline"></ion-icon> -->
-    今日饮食建议
-  </ion-button>
-  <p>关注每日健康饮食,提供实时饮食建议。</p>
-</ion-card-content>
-</ion-card>
+  <button class="prev" (click)="prevSlide()">&#10094;</button>
+  <button class="next" (click)="nextSlide()">&#10095;</button>
+
+  <div class="dots">
+    <span class="dot" *ngFor="let image of images; let i = index" 
+          [class.active]="i === currentSlide" 
+          (click)="goToSlide(i)"></span>
+  </div>
+</div>
+
+  <!-- 推荐健康建议 -->
+  <ion-card>
+    <ion-card-header>
+      <ion-card-title>
+        <ion-icon slot="start" name="leaf-outline"></ion-icon>
+        健康建议
+      </ion-card-title>
+    </ion-card-header>
+    <ion-card-content>
+      <ion-button (click)="goHealthTips()">
+        今日饮食建议
+      </ion-button>
+      <p>{{ responseMsg }}</p> <!-- 显示 AI 生成的饮食建议 -->
+    </ion-card-content>
+  </ion-card>
 
-<!-- 快速入口 -->
-<ion-grid>
-<ion-row>
-  <ion-col size="12">
-    <ion-button  >
-      <ion-icon slot="start" name="document-outline"></ion-icon>
-      健康目标管理
-    </ion-button>
-  </ion-col>
-</ion-row>
-<ion-row>
-  <ion-col size="12">
-    <ion-button  >
-      <ion-icon slot="start" name="storefront-outline"></ion-icon>
-      外卖推荐
-    </ion-button>
-  </ion-col>
-</ion-row>
-</ion-grid>
+  <!-- 快速入口 -->
+  <ion-grid>
+    <ion-row>
+      <ion-col size="12">
+        <ion-button>
+          <ion-icon slot="start" name="document-outline"></ion-icon>
+          健康目标管理
+        </ion-button>
+      </ion-col>
+    </ion-row>
+    <ion-row>
+      <ion-col size="12">
+        <ion-button>
+          <ion-icon slot="start" name="storefront-outline"></ion-icon>
+          外卖推荐
+        </ion-button>
+      </ion-col>
+    </ion-row>
+  </ion-grid>
 
-<!-- 推荐食谱 -->
-<ion-card>
-<ion-card-header>
-  <ion-card-title>
-    <ion-icon slot="start" name="albums-outline"></ion-icon>
-    今日推荐食谱
-  </ion-card-title>
-</ion-card-header>
-<ion-card-content>
-  <ion-button  >
-    <!-- <ion-icon slot="start" name="albums-outline"></ion-icon> -->
-    查看推荐食谱
-  </ion-button>
-  <p>根据你的饮食偏好,智能推荐今日食谱。</p>
-</ion-card-content>
-</ion-card>
+  <!-- 推荐食谱 -->
+  <ion-card>
+    <ion-card-header>
+      <ion-card-title>
+        <ion-icon slot="start" name="albums-outline"></ion-icon>
+        今日推荐食谱
+      </ion-card-title>
+    </ion-card-header>
+    <ion-card-content>
+      <ion-button (click)="viewRecommendedRecipes()">
+        查看推荐食谱
+      </ion-button>
+      <p>{{ recipeMsg }}</p> <!-- 显示 AI 生成的推荐食谱 -->
+    </ion-card-content>
+  </ion-card>
 </ion-content>

+ 182 - 24
smarteat-app/src/app/tab1/tab1.page.ts

@@ -1,40 +1,196 @@
-import { Component, 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, IonGrid, IonHeader, IonIcon, IonInput, IonRow, IonTextarea, IonTitle, IonToolbar } from '@ionic/angular/standalone';
-import { Router } from '@angular/router';
-import { CommonModule } from '@angular/common';  // 导入 CommonModule
-
+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 { 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',
   styleUrls: ['tab1.page.scss'],
-  standalone: true, // 使用 standalone 组件
-  imports: [ 
-    CommonModule,IonContent, IonHeader, IonTitle, IonToolbar, 
-    IonButton,IonTextarea,IonInput,IonCard,IonCardContent,IonGrid,IonRow,IonCol,IonIcon,
-    IonCardHeader,
-  ],  // 通过 IonicModule 导入所有 Ionic 组件
-  schemas: [CUSTOM_ELEMENTS_SCHEMA], 
+  standalone: true,  // 使用 standalone 组件
+  imports: [
+    CommonModule, IonContent, IonHeader, IonTitle, IonToolbar, 
+    IonButton, IonTextarea, IonInput, IonCard, IonCardContent, IonGrid, IonRow, IonCol, IonIcon,
+    IonCardHeader, IonCardTitle, IonSearchbar,
+  ],
 })
-export class Tab1Page {
+export class Tab1Page implements OnInit {
+  private cloudSeUser: CloudSeUser; // 引入 CloudSeUser 实例
+
+  userInfo: any = null; // 用户信息
+  responseMsg: string = ""; // 用于存储 AI 生成的饮食建议
+  recipeMsg: string = ""; // 用于存储 AI 生成的推荐食谱
 
-  constructor(private router: Router) {
-    addIcons({scanOutline, documentOutline, storefrontOutline,albumsOutline,leafOutline});
-  }
-  
   // 存储图片的数组
   images = [
-    'https://example.com/image1.jpg',
-    'https://example.com/image2.jpg',
-    'https://example.com/image3.jpg',
-    'https://example.com/image4.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;
 
+  constructor(private router: Router, private modalCtrl: ModalController) {
+    addIcons({ scanOutline, documentOutline, storefrontOutline, albumsOutline, leafOutline });
+    this.cloudSeUser = new CloudSeUser();
+  }
+
+  ngOnInit(): void {
+    this.loadUserData(); // 页面初始化时加载用户数据
+  }
+
+  // 从 seUser 表加载当前用户数据
+  async loadUserData() {
+    try {
+        const userData = await this.cloudSeUser.getCurrentUserInfo();
+        if (userData) {
+            // 使用 get 方法逐个提取字段
+            this.userInfo = {
+                name: userData.get('name') || '',
+                email: userData.get('email') || '',
+                phone: userData.get('phone') || '',
+                age: userData.get('age') || null,
+                gender: userData.get('gender') || '',
+                height: userData.get('height') || null,
+                weight: userData.get('weight') || null,
+                activityLevel: userData.get('activityLevel') || '',
+                dietPreference: userData.get('dietPreference') || '',
+                dietGroup: userData.get('dietGroup') || '',
+                avatar: userData.get('avatar') || null,
+                allergies: userData.get('allergies') || '',
+            };
+        }
+    } catch (error) {
+        console.error('加载用户数据失败', error);
+    }
+  }
+
+  // 获取健康建议
+  async goHealthTips() {
+    if (!this.userInfo) return;
+
+    const { height, weight, activityLevel, dietPreference, dietGroup } = this.userInfo;
+    const newPrompt = `
+      你是一名专业的饮食营养规划师。根据以下用户信息,请提供今日的饮食建议:
+      身高:${height} cm
+      体重:${weight} kg
+      活动水平:${activityLevel}
+      饮食偏好:${dietPreference}
+      饮食类型:${dietGroup}
+    `;
+
+    const completion = new FmodeChatCompletion([
+      { role: "system", content: "" },
+      { role: "user", content: newPrompt }
+    ]);
+
+    completion.sendCompletion().subscribe((message: any) => {
+      console.log(message.content);
+      this.responseMsg = message.content; // 更新健康建议
+    });
+  }
+
+  // 查看推荐食谱
+  async viewRecommendedRecipes() {
+    if (!this.userInfo) return;
+
+    const { height, weight, activityLevel, dietPreference, dietGroup } = this.userInfo;
+    const newPrompt = `
+      你是一名专业的饮食营养规划师。根据以下用户信息,请推荐今日的食谱:
+      身高:${height} cm
+      体重:${weight} kg
+      活动水平:${activityLevel}
+      饮食偏好:${dietPreference}
+      饮食类型:${dietGroup}
+    `;
+
+    const completion = new FmodeChatCompletion([
+      { role: "system", content: "" },
+      { role: "user", content: newPrompt }
+    ]);
+
+    completion.sendCompletion().subscribe((message: any) => {
+      console.log(message.content);
+      this.recipeMsg = message.content; // 更新推荐食谱
+    });
+  }
+
+  // 打开弹窗
+  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></p>',
+      '<p><strong>第二张图片</strong></p>',
+      '<p><strong>第三张图片</strong></p>',
+      '<p><strong>第四张图片</strong></p>'
+    ];
+
+    // 打开弹窗并传递描述
+    await this.openImagePopup(this.images[index], descriptions[index]);
+  }
+
   // 前一个幻灯片
   prevSlide() {
     if (this.currentSlide > 0) {
@@ -58,7 +214,9 @@ export class Tab1Page {
     this.currentSlide = index;
   }
 
-  goHealthTips(){
-    this.router.navigate([`/tabs/tips`])
+    // 跳转到饮食建议页面
+    goHealthTipsPage() {
+      this.router.navigate([`/tabs/tips`]);
+    }
   }
-}
+