|
@@ -4,7 +4,7 @@ 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, IonButtons } 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';
|
|
@@ -14,6 +14,9 @@ import { Image3PopupComponent } from '../image-popup/image3-popup/image3-popup.c
|
|
|
import { Image4PopupComponent } from '../image-popup/image4-popup/image4-popup.component';
|
|
|
import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-login.component';
|
|
|
import { CloudUser } from 'src/lib/ncloud';
|
|
|
+import { MealService } from '../meal/meal.service';
|
|
|
+import { MealSearchComponent } from '../meal-search/meal-search/meal-search.component';
|
|
|
+
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-tab1',
|
|
@@ -23,17 +26,21 @@ import { CloudUser } from 'src/lib/ncloud';
|
|
|
imports: [
|
|
|
CommonModule, IonContent, IonHeader, IonTitle, IonToolbar,
|
|
|
IonButton, IonTextarea, IonInput, IonCard, IonCardContent, IonGrid, IonRow, IonCol, IonIcon,
|
|
|
- IonCardHeader, IonCardTitle, IonSearchbar,
|
|
|
+ IonCardHeader, IonCardTitle, IonSearchbar,IonButtons
|
|
|
],
|
|
|
})
|
|
|
export class Tab1Page implements OnInit {
|
|
|
private cloudSeUser: CloudSeUser; // 引入 CloudSeUser 实例
|
|
|
-
|
|
|
+ searchQuery: string = '';
|
|
|
userInfo: any = null; // 用户信息
|
|
|
responseMsg: string = ""; // 用于存储 AI 生成的饮食建议
|
|
|
recipeMsg: string = ""; // 用于存储 AI 生成的推荐食谱
|
|
|
+<<<<<<< HEAD
|
|
|
+ isLoading: boolean = false;
|
|
|
+=======
|
|
|
dishName:string="";//用于存储菜品名
|
|
|
dishPhoto:string="";
|
|
|
+>>>>>>> 30e3263ceeaa56c2a539c16f61e5f80180fab44a
|
|
|
|
|
|
// 存储图片的数组
|
|
|
images = [
|
|
@@ -54,12 +61,38 @@ export class Tab1Page implements OnInit {
|
|
|
currentSlide: number = 0;
|
|
|
currentUser:CloudUser|undefined
|
|
|
|
|
|
- constructor(private router: Router, private modalCtrl: ModalController,) {
|
|
|
+ constructor(private router: Router, private modalCtrl: ModalController, private mealService: MealService,) {
|
|
|
addIcons({ scanOutline, documentOutline, storefrontOutline, albumsOutline, leafOutline });
|
|
|
this.cloudSeUser = new CloudSeUser();
|
|
|
this.currentUser=new CloudUser()
|
|
|
}
|
|
|
|
|
|
+ //搜索框功能实现
|
|
|
+ // 当输入发生变化时触发
|
|
|
+ setSearchQuery(query: string) {
|
|
|
+ this.searchQuery = query;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击搜索按钮时触发的搜索方法
|
|
|
+ async search() {
|
|
|
+ if (this.searchQuery.trim()) {
|
|
|
+ await this.openMealSearchModal();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 打开弹窗并展示搜索结果
|
|
|
+ async openMealSearchModal() {
|
|
|
+ const modal = await this.modalCtrl.create({
|
|
|
+ component: MealSearchComponent,
|
|
|
+ componentProps: {
|
|
|
+ searchQuery: this.searchQuery,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ await modal.present();
|
|
|
+ }
|
|
|
+//搜索框功能实现
|
|
|
+
|
|
|
async ngOnInit(): Promise<void> {
|
|
|
await this.loadUserData(); // 页面初始化时加载用户数据
|
|
|
if (this.currentUser?.id) {
|