|  | @@ -2,7 +2,8 @@ import { CommonModule } from '@angular/common';
 | 
	
		
			
				|  |  |  import { Component } from '@angular/core';
 | 
	
		
			
				|  |  |  import { IonTextarea } from '@ionic/angular/standalone';
 | 
	
		
			
				|  |  |  import { 
 | 
	
		
			
				|  |  | -  IonHeader, IonToolbar, IonTitle, IonButtons, IonButton, IonIcon,
 | 
	
		
			
				|  |  | +  ModalController,
 | 
	
		
			
				|  |  | +  IonHeader,IonNote,IonChip, IonToolbar, IonTitle, IonButtons, IonButton, IonIcon,
 | 
	
		
			
				|  |  |    IonContent, IonCard, IonCardHeader, IonCardTitle, IonCardSubtitle,
 | 
	
		
			
				|  |  |    IonCardContent, IonProgressBar, IonGrid, IonRow, IonCol, IonListHeader,
 | 
	
		
			
				|  |  |    IonLabel, IonList, IonItem, IonAvatar, IonBadge, IonFab, IonFabButton
 | 
	
	
		
			
				|  | @@ -14,6 +15,9 @@ import {
 | 
	
		
			
				|  |  |    flame, bicycle, trophy
 | 
	
		
			
				|  |  |  } from 'ionicons/icons';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +// 引用fmode-ng智能体组件
 | 
	
		
			
				|  |  | +import { ChatPanelOptions, FmChatModalInput, FmodeChat, FmodeChatMessage, openChatPanelModal } from 'fmode-ng';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  @Component({
 | 
	
		
			
				|  |  |    selector: 'app-tab2',
 | 
	
		
			
				|  |  |    templateUrl: 'tab2.page.html',
 | 
	
	
		
			
				|  | @@ -21,7 +25,8 @@ import {
 | 
	
		
			
				|  |  |    standalone: true,
 | 
	
		
			
				|  |  |    imports: [
 | 
	
		
			
				|  |  |      CommonModule,
 | 
	
		
			
				|  |  | -    IonTextarea,
 | 
	
		
			
				|  |  | +    // IonTextarea,
 | 
	
		
			
				|  |  | +    IonNote,IonChip,
 | 
	
		
			
				|  |  |      IonHeader, IonToolbar, IonTitle, IonButtons, IonButton, IonIcon,
 | 
	
		
			
				|  |  |      IonContent, IonCard, IonCardHeader, IonCardTitle, IonCardSubtitle,
 | 
	
		
			
				|  |  |      IonCardContent, IonProgressBar, IonGrid, IonRow, IonCol, IonListHeader,
 | 
	
	
		
			
				|  | @@ -29,6 +34,161 @@ import {
 | 
	
		
			
				|  |  |    ]
 | 
	
		
			
				|  |  |  })
 | 
	
		
			
				|  |  |  export class Tab2Page {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  openConsult(chatId?:string){
 | 
	
		
			
				|  |  | +    localStorage.setItem("company","E4KpGvTEto")
 | 
	
		
			
				|  |  | +    let options:ChatPanelOptions = {
 | 
	
		
			
				|  |  | +      roleId:"2DXJkRsjXK", // 预设,无需更改
 | 
	
		
			
				|  |  | +      // chatId:chatId, // 若存在,则恢复会话。若不存在,则开启新会话
 | 
	
		
			
				|  |  | +      onChatInit:(chat:FmodeChat)=>{
 | 
	
		
			
				|  |  | +        console.log("onChatInit");
 | 
	
		
			
				|  |  | +        console.log("Chat类",chat);
 | 
	
		
			
				|  |  | +        console.log("预设角色",chat.role);
 | 
	
		
			
				|  |  | +        // 角色名称
 | 
	
		
			
				|  |  | +        chat.role.set("name","宋珀尔");
 | 
	
		
			
				|  |  | +        // 角色称号
 | 
	
		
			
				|  |  | +        chat.role.set("title","专业教练");
 | 
	
		
			
				|  |  | +        // 角色描述
 | 
	
		
			
				|  |  | +        chat.role.set("desc","一名亲切和蔼的健身教练,宋珀尔,年龄26岁");
 | 
	
		
			
				|  |  | +        // 角色标签
 | 
	
		
			
				|  |  | +        chat.role.set("tags",['跑步', '动感单车']);
 | 
	
		
			
				|  |  | +        // 角色头像
 | 
	
		
			
				|  |  | +        chat.role.set("avatar","/assets/avatars/jiaolian1.jpg")
 | 
	
		
			
				|  |  | +        // 角色提示词
 | 
	
		
			
				|  |  | +        chat.role.set("prompt",`
 | 
	
		
			
				|  |  | +# 角色设定
 | 
	
		
			
				|  |  | +您是一名亲切和蔼的健身教练,宋珀尔,年龄26岁,需要您解答用户健身方面的专业问题。
 | 
	
		
			
				|  |  | +`);
 | 
	
		
			
				|  |  | +        // 对话灵感分类
 | 
	
		
			
				|  |  | +        let promptCates = [
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            "img": "/assets/icon/yy.jpg",
 | 
	
		
			
				|  |  | +            "name": "有氧"
 | 
	
		
			
				|  |  | +          },
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            "img": "/assets/icon/jz.jpg",
 | 
	
		
			
				|  |  | +            "name": "减脂"
 | 
	
		
			
				|  |  | +          },
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            "img": "/assets/icon/zj.jpg",
 | 
	
		
			
				|  |  | +            "name": "增肌"
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        ]
 | 
	
		
			
				|  |  | +        setTimeout(() => {
 | 
	
		
			
				|  |  | +          chat.role.set("promptCates",promptCates)
 | 
	
		
			
				|  |  | +        }, 500);
 | 
	
		
			
				|  |  | +        // 对话灵感列表
 | 
	
		
			
				|  |  | +        let promptList = [
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            cate:"有氧",img:"/assets/icon/yy.jpg",
 | 
	
		
			
				|  |  | +            messageList:[
 | 
	
		
			
				|  |  | +            "有氧运动多久才能有效减脂?",  
 | 
	
		
			
				|  |  | +            "跑步和游泳哪个减肥效果更好?",  
 | 
	
		
			
				|  |  | +            "空腹有氧真的更燃脂吗?",  
 | 
	
		
			
				|  |  | +            "有氧运动会不会掉肌肉?",  
 | 
	
		
			
				|  |  | +            "心率控制在多少才能高效燃脂?",  
 | 
	
		
			
				|  |  | +            "每天做有氧运动会不会过度疲劳?",  
 | 
	
		
			
				|  |  | +            "有氧运动前要不要吃东西?",  
 | 
	
		
			
				|  |  | +            "椭圆机和跑步机哪个更适合新手?",  
 | 
	
		
			
				|  |  | +            "跳绳会不会伤膝盖?",  
 | 
	
		
			
				|  |  | +            "有氧运动后怎么补充能量?"  
 | 
	
		
			
				|  |  | +          ]
 | 
	
		
			
				|  |  | +          },
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            cate:"减脂",img:"/assets/icon/jz.jpg",
 | 
	
		
			
				|  |  | +            messageList:[
 | 
	
		
			
				|  |  | +              "减脂一定要做有氧吗?",  
 | 
	
		
			
				|  |  | +              "为什么体重没变但看起来瘦了?",  
 | 
	
		
			
				|  |  | +              "局部减脂(如瘦肚子)真的存在吗?",  
 | 
	
		
			
				|  |  | +              "减脂期每天应该吃多少热量?",  
 | 
	
		
			
				|  |  | +              "低碳饮食和低脂饮食哪个更适合减脂?",  
 | 
	
		
			
				|  |  | +              "为什么运动后体重反而增加了?",  
 | 
	
		
			
				|  |  | +              "减脂期可以吃零食吗?",  
 | 
	
		
			
				|  |  | +              "平台期怎么突破?",  
 | 
	
		
			
				|  |  | +              "晚上吃东西会不会更容易长胖?",  
 | 
	
		
			
				|  |  | +              "减脂期要不要计算蛋白质摄入?"  
 | 
	
		
			
				|  |  | +            ]
 | 
	
		
			
				|  |  | +          },
 | 
	
		
			
				|  |  | +          {
 | 
	
		
			
				|  |  | +            cate:"增肌",img:"/assets/icon/zj.jpg",
 | 
	
		
			
				|  |  | +            messageList: [
 | 
	
		
			
				|  |  | +            "增肌一定要喝蛋白粉吗?",  
 | 
	
		
			
				|  |  | +            "为什么练了很久肌肉不长?",  
 | 
	
		
			
				|  |  | +            "增肌期可以同时减脂吗?",  
 | 
	
		
			
				|  |  | +            "训练后多久补充蛋白质最有效?",  
 | 
	
		
			
				|  |  | +            "增肌需要每天练同一个部位吗?",  
 | 
	
		
			
				|  |  | +            "徒手训练(如俯卧撑)能有效增肌吗?",  
 | 
	
		
			
				|  |  | +            "增肌期体重不增长是怎么回事?",  
 | 
	
		
			
				|  |  | +            "肌肉酸痛还能继续练吗?",  
 | 
	
		
			
				|  |  | +            "增肌训练每组做多少次最合适?",  
 | 
	
		
			
				|  |  | +            "睡眠对增肌的影响有多大?"  
 | 
	
		
			
				|  |  | +          ]
 | 
	
		
			
				|  |  | +          },
 | 
	
		
			
				|  |  | +        ]
 | 
	
		
			
				|  |  | +        let ChatPrompt = Parse.Object.extend("ChatPrompt");
 | 
	
		
			
				|  |  | +        setTimeout(() => {
 | 
	
		
			
				|  |  | +          chat.promptList = promptList.map(item=>{
 | 
	
		
			
				|  |  | +            let prompt = new ChatPrompt();
 | 
	
		
			
				|  |  | +            prompt.set(item);
 | 
	
		
			
				|  |  | +            prompt.img = item.img;
 | 
	
		
			
				|  |  | +            return prompt;
 | 
	
		
			
				|  |  | +          })
 | 
	
		
			
				|  |  | +        }, 500);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 功能按钮区域预设
 | 
	
		
			
				|  |  | +        chat.leftButtons = [
 | 
	
		
			
				|  |  | +          { // 提示 当角色配置预设提示词时 显示
 | 
	
		
			
				|  |  | +           title:"话题灵感", // 按钮标题
 | 
	
		
			
				|  |  | +           showTitle:true, // 是否显示标题文字
 | 
	
		
			
				|  |  | +           icon:"color-wand-outline", // 标题icon图标
 | 
	
		
			
				|  |  | +           onClick:()=>{ // 按钮点击事件
 | 
	
		
			
				|  |  | +               chat.isPromptModalOpen = true
 | 
	
		
			
				|  |  | +           },
 | 
	
		
			
				|  |  | +           show:()=>{ // 按钮显示条件
 | 
	
		
			
				|  |  | +             return chat?.promptList?.length // 存在话题提示词时显示
 | 
	
		
			
				|  |  | +           }
 | 
	
		
			
				|  |  | +         },
 | 
	
		
			
				|  |  | +      ]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      onMessage:(chat:FmodeChat,message:FmodeChatMessage)=>{
 | 
	
		
			
				|  |  | +        console.log("onMessage",message)
 | 
	
		
			
				|  |  | +        let content:any = message?.content
 | 
	
		
			
				|  |  | +        if(typeof content == "string"){
 | 
	
		
			
				|  |  | +          // 根据阶段标记判断下一步处理过程
 | 
	
		
			
				|  |  | +          if (content.includes('[导诊完成]')) {
 | 
	
		
			
				|  |  | +            // 进入问诊环节
 | 
	
		
			
				|  |  | +            console.log('进入问诊环节');
 | 
	
		
			
				|  |  | +          } else if (content.includes('[问诊完成]')) {
 | 
	
		
			
				|  |  | +            // 进入检查环节
 | 
	
		
			
				|  |  | +            console.log('进入检查环节');
 | 
	
		
			
				|  |  | +          } else if (content.includes('[检查完成]')) {
 | 
	
		
			
				|  |  | +            // 进入诊断与处方环节
 | 
	
		
			
				|  |  | +            console.log('进入诊断与处方环节');
 | 
	
		
			
				|  |  | +          } else if (content.includes('[处方完成]')) {
 | 
	
		
			
				|  |  | +            // 结束会话或其他逻辑
 | 
	
		
			
				|  |  | +            console.log('结束会话');
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      onChatSaved:(chat:FmodeChat)=>{
 | 
	
		
			
				|  |  | +        // chat?.chatSession?.id 本次会话的 chatId
 | 
	
		
			
				|  |  | +        console.log("onChatSaved",chat,chat?.chatSession,chat?.chatSession?.id)
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    openChatPanelModal(this.modalCtrl,options)
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    constructor(
 | 
	
		
			
				|  |  | +    private modalCtrl:ModalController,
 | 
	
		
			
				|  |  | +  ) {
 | 
	
		
			
				|  |  | +    addIcons({ 
 | 
	
		
			
				|  |  | +      notificationsOutline, calendarNumber, checkmarkCircle, ellipseOutline,
 | 
	
		
			
				|  |  | +      timeOutline, barbell, body, walk, add, refresh, fitness,
 | 
	
		
			
				|  |  | +      flame, bicycle,  trophy
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    // 周训练数据
 | 
	
		
			
				|  |  |    weekDays = [
 | 
	
		
			
				|  |  |      { shortName: '周一', name: 'Monday', trained: true, active: false },
 | 
	
	
		
			
				|  | @@ -103,13 +263,6 @@ export class Tab2Page {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    ];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  constructor() {
 | 
	
		
			
				|  |  | -    addIcons({ 
 | 
	
		
			
				|  |  | -      notificationsOutline, calendarNumber, checkmarkCircle, ellipseOutline,
 | 
	
		
			
				|  |  | -      timeOutline, barbell, body, walk, add, refresh, fitness,
 | 
	
		
			
				|  |  | -      flame, bicycle,  trophy
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    refreshPlans() {
 | 
	
		
			
				|  |  |      console.log('刷新计划数据');
 |