|  | @@ -1,14 +1,130 @@
 | 
	
		
			
				|  |  |  import { Component } from '@angular/core';
 | 
	
		
			
				|  |  | -import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
 | 
	
		
			
				|  |  | +import { IonHeader, IonToolbar, IonTitle, IonContent, IonItem, IonList, IonSelect, IonSelectOption, IonLabel, IonButton, IonTextarea, AlertController } from '@ionic/angular/standalone';
 | 
	
		
			
				|  |  |  import { ExploreContainerComponent } from '../explore-container/explore-container.component';
 | 
	
		
			
				|  |  | +import { CommonModule } from '@angular/common';
 | 
	
		
			
				|  |  | +import { FormsModule } from '@angular/forms'; // 导入 FormsModule
 | 
	
		
			
				|  |  | +/** 引用:从fmode-ng库引用FmodeChatCompletion类 */
 | 
	
		
			
				|  |  | +import { FmodeChatCompletion, MarkdownPreviewModule } from 'fmode-ng';
 | 
	
		
			
				|  |  | +import { Router } from '@angular/router'; // 导入 Router
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Component({
 | 
	
		
			
				|  |  |    selector: 'app-tab3',
 | 
	
		
			
				|  |  |    templateUrl: 'tab3.page.html',
 | 
	
		
			
				|  |  |    styleUrls: ['tab3.page.scss'],
 | 
	
		
			
				|  |  |    standalone: true,
 | 
	
		
			
				|  |  | -  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent],
 | 
	
		
			
				|  |  | +  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonItem,IonList,IonSelect,IonSelectOption,IonButton,CommonModule,IonTextarea,FormsModule,
 | 
	
		
			
				|  |  | +    MarkdownPreviewModule,],
 | 
	
		
			
				|  |  |  })
 | 
	
		
			
				|  |  |  export class Tab3Page {
 | 
	
		
			
				|  |  | -  constructor() {}
 | 
	
		
			
				|  |  | +  constructor(private alertController: AlertController, private router: Router) {}
 | 
	
		
			
				|  |  | +  colors: string[] = [
 | 
	
		
			
				|  |  | +    '#FF5733', '#33FF57', '#3357FF', '#F1C40F', '#8E44AD', 
 | 
	
		
			
				|  |  | +    '#E74C3C', '#3498DB', '#1ABC9C', '#2ECC71', '#9B59B6',
 | 
	
		
			
				|  |  | +    '#34495E', '#E67E22', '#F39C12', '#D35400', '#C0392B',
 | 
	
		
			
				|  |  | +    '#7F8C8D', '#BDC3C7', '#95A5A6', '#FFB6C1', '#FF4500',
 | 
	
		
			
				|  |  | +    '#FFD700', '#ADFF2F', '#00CED1', '#FF69B4', '#8A2BE2',
 | 
	
		
			
				|  |  | +    '#A52A2A', '#DEB887', '#5F9EA0', '#4682B4', '#D3D3D3',
 | 
	
		
			
				|  |  | +    '#FF1493', '#7FFF00', '#FF6347', '#B22222', '#FF8C00',
 | 
	
		
			
				|  |  | +    '#20B2AA', '#C71585', '#FFDAB9', '#F0E68C', '#FFFACD',
 | 
	
		
			
				|  |  | +    '#FFE4E1', '#FFF0F5', '#FFF5EE', '#F5F5F5', '#DCDCDC',
 | 
	
		
			
				|  |  | +    '#708090', '#778899',
 | 
	
		
			
				|  |  | +  ];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  selectedColorFavorite: string = ''; // 第一个颜色选择器的选中颜色
 | 
	
		
			
				|  |  | +  selectedColorSecondary: string = ''; // 第二个颜色选择器的选中颜色
 | 
	
		
			
				|  |  | +  showColorPickerFavorite: boolean = false; // 控制第一个颜色选择器的显示
 | 
	
		
			
				|  |  | +  showColorPickerSecondary: boolean = false; // 控制第二个颜色选择器的显示
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  selectedSeason: string = ''; // 存储用户选择的季节
 | 
	
		
			
				|  |  | +  selectedGender: string = ''; // 存储用户选择的性别
 | 
	
		
			
				|  |  | +  selectedBodyType: string = ''; // 存储用户选择的体型
 | 
	
		
			
				|  |  | +  selectedSkinTone: string = ''; // 存储用户选择的皮肤色调
 | 
	
		
			
				|  |  | +  styleDescription: string = ''; // 存储用户的风格描述
 | 
	
		
			
				|  |  | +  isComplete:boolean = false; // 定义完成状态属性,用来标记是否补全完成
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  toggleColorPicker(type: string) {
 | 
	
		
			
				|  |  | +    if (type === 'favorite') {
 | 
	
		
			
				|  |  | +      this.showColorPickerFavorite = !this.showColorPickerFavorite; // 切换第一个颜色选择器的显示状态
 | 
	
		
			
				|  |  | +      this.showColorPickerSecondary = false; // 关闭第二个颜色选择器
 | 
	
		
			
				|  |  | +    } else if (type === 'secondary') {
 | 
	
		
			
				|  |  | +      this.showColorPickerSecondary = !this.showColorPickerSecondary; // 切换第二个颜色选择器的显示状态
 | 
	
		
			
				|  |  | +      this.showColorPickerFavorite = false; // 关闭第一个颜色选择器
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  selectColor(color: string, type: string) {
 | 
	
		
			
				|  |  | +    if (type === 'favorite') {
 | 
	
		
			
				|  |  | +      this.selectedColorFavorite = color; // 更新第一个颜色选择器的选中颜色
 | 
	
		
			
				|  |  | +    } else if (type === 'secondary') {
 | 
	
		
			
				|  |  | +      this.selectedColorSecondary = color; // 更新第二个颜色选择器的选中颜色
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    this.showColorPickerFavorite = false; // 选择颜色后关闭第一个颜色选择器
 | 
	
		
			
				|  |  | +    this.showColorPickerSecondary = false; // 选择颜色后关闭第二个颜色选择器
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // 用户输入提示词
 | 
	
		
			
				|  |  | +  //userPrompt:string = '当前的季节是'+this.selectedSeason+',该用户性别是'+this.selectedGender+',体型是'+this.selectedBodyType+',皮肤色调是'+this.selectedSkinTone+',最喜欢的颜色是'+this.selectedColorFavorite+',次喜欢的颜色是'+this.selectedColorSecondary+',该用户的风格描述是'+this.styleDescription+',请你作为一名专业的服装穿搭大师,为该用户给出适合的服装搭配建议。'
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // 属性:组件内用于展示消息内容的变量
 | 
	
		
			
				|  |  | +  responseMsg:any = ""
 | 
	
		
			
				|  |  | +  // 方法:实例化completion对象,传入消息数组,并订阅生成的可观察对象。
 | 
	
		
			
				|  |  | +  // 用户输入提示词
 | 
	
		
			
				|  |  | +  userPrompt:string = ''
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  //评价弹出框
 | 
	
		
			
				|  |  | +  async presentAlert() {
 | 
	
		
			
				|  |  | +    const alert = await this.alertController.create({
 | 
	
		
			
				|  |  | +        header: '希望你对本次AI进行评价',
 | 
	
		
			
				|  |  | +        buttons: [
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                text: '不了',
 | 
	
		
			
				|  |  | +                role: 'cancel',
 | 
	
		
			
				|  |  | +                handler: () => {
 | 
	
		
			
				|  |  | +                    console.log('用户选择留在本页面');
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                text: '去评价',
 | 
	
		
			
				|  |  | +                handler: () => {
 | 
	
		
			
				|  |  | +                    // 假设评价页面的路由是'/评价'
 | 
	
		
			
				|  |  | +                    // 您可以根据实际的路由路径进行调整
 | 
	
		
			
				|  |  | +                   
 | 
	
		
			
				|  |  | +                    this.router.navigate(['/tabs/evaluate']);
 | 
	
		
			
				|  |  | +                   
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        ]
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    await alert.present();
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +  sendMessage(){
 | 
	
		
			
				|  |  | +    // 每次点击按钮时清空之前的内容
 | 
	
		
			
				|  |  | +    this.responseMsg = ""; // 清空之前的消息
 | 
	
		
			
				|  |  | +    this.isComplete = false; // 重置完成状态
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    this.userPrompt = '当前的季节是' + this.selectedSeason + ',该用户性别是' + this.selectedGender + ',体型是' + this.selectedBodyType + ',皮肤色调是' + this.selectedSkinTone + ',最喜欢的颜色是' + this.selectedColorFavorite + ',次喜欢的颜色是' + this.selectedColorSecondary + ',该用户的风格描述是' + this.styleDescription + ',请你作为一名专业的服装穿搭大师,为该用户给出适合的服装搭配建议。';
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    console.log("开始生成");
 | 
	
		
			
				|  |  | +    let completion = new FmodeChatCompletion([
 | 
	
		
			
				|  |  | +        { role: "system", content: "" },
 | 
	
		
			
				|  |  | +        { role: "user", content: this.userPrompt }
 | 
	
		
			
				|  |  | +    ]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    completion.sendCompletion().subscribe((message: any) => {
 | 
	
		
			
				|  |  | +        // 打印消息体
 | 
	
		
			
				|  |  | +        console.log(message.content);
 | 
	
		
			
				|  |  | +        // 赋值消息内容给组件内属性
 | 
	
		
			
				|  |  | +        this.responseMsg = message.content;
 | 
	
		
			
				|  |  | +        if (message?.complete) { // 判断message为完成状态,则设置isComplete为完成
 | 
	
		
			
				|  |  | +            this.isComplete = true;
 | 
	
		
			
				|  |  | +            this.presentAlert(); // 调用弹出框
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  goTestPage(){
 | 
	
		
			
				|  |  | +    this.router.navigate(['/tabs/test']);}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  
 |