|
@@ -1,10 +1,10 @@
|
|
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
|
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { Router } from '@angular/router';
|
|
import { addIcons } from 'ionicons';
|
|
import { addIcons } from 'ionicons';
|
|
-import { checkmarkCircle, calendar, helpCircle } from 'ionicons/icons';
|
|
|
|
|
|
+import { checkmarkCircle, trash, calendar, helpCircle, create } from 'ionicons/icons';
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { FormsModule } from '@angular/forms';
|
|
-import { IonButtons, IonItem, IonList, IonHeader, IonIcon, IonToolbar, IonContent, IonSegment, IonSegmentButton, IonGrid, IonRow, IonCol, IonButton, IonLabel, IonBadge, IonInput, ModalController } from '@ionic/angular/standalone';
|
|
|
|
|
|
+import { IonThumbnail, IonCardSubtitle, IonImg, IonCard, IonButtons, IonItem, IonList, IonHeader, IonIcon, IonToolbar, IonContent, IonSegment, IonSegmentButton, IonGrid, IonRow, IonCol, IonButton, IonLabel, IonBadge, IonInput, ModalController, IonCardTitle, IonCardContent, IonCardHeader } from '@ionic/angular/standalone';
|
|
import { FmodeChatCompletion, ImagineWork, DalleOptions, ChatPanelOptions, FmodeChat, FmodeChatMessage, openChatPanelModal } from "fmode-ng";
|
|
import { FmodeChatCompletion, ImagineWork, DalleOptions, ChatPanelOptions, FmodeChat, FmodeChatMessage, openChatPanelModal } from "fmode-ng";
|
|
import { AgentTaskStep } from './agent/agent.task';
|
|
import { AgentTaskStep } from './agent/agent.task';
|
|
import { TaskPoemPictureDesc } from './agent/tasks/poem/poem-desc';
|
|
import { TaskPoemPictureDesc } from './agent/tasks/poem/poem-desc';
|
|
@@ -13,12 +13,21 @@ import { startTask } from './agent/agent.start';
|
|
import { TaskInqueryUserStory } from './agent/tasks/poem/inquiry/1.inquiry-user-story';
|
|
import { TaskInqueryUserStory } from './agent/tasks/poem/inquiry/1.inquiry-user-story';
|
|
import { TaskInqueryDoctorQuestion } from './agent/tasks/poem/inquiry/2.inquiry-doctor-question';
|
|
import { TaskInqueryDoctorQuestion } from './agent/tasks/poem/inquiry/2.inquiry-doctor-question';
|
|
import { TaskInqueryUserAnswer } from './agent/tasks/poem/inquiry/3.inquiry-user-answer';
|
|
import { TaskInqueryUserAnswer } from './agent/tasks/poem/inquiry/3.inquiry-user-answer';
|
|
|
|
+import { CloudObject, CloudQuery } from 'src/lib/ncloud';
|
|
|
|
+import { EditPlanModalComponent } from './edit-plan-modal/edit-plan-modal.component';
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-tab2',
|
|
selector: 'app-tab2',
|
|
templateUrl: 'tab2.page.html',
|
|
templateUrl: 'tab2.page.html',
|
|
styleUrls: ['tab2.page.scss'],
|
|
styleUrls: ['tab2.page.scss'],
|
|
standalone: true,
|
|
standalone: true,
|
|
imports: [
|
|
imports: [
|
|
|
|
+ IonThumbnail,
|
|
|
|
+ IonCardSubtitle,
|
|
|
|
+ IonImg,
|
|
|
|
+ IonCard,
|
|
|
|
+ IonCardTitle,
|
|
|
|
+ IonCardHeader,
|
|
|
|
+ IonCardContent,
|
|
IonButtons,
|
|
IonButtons,
|
|
IonItem,
|
|
IonItem,
|
|
IonList,
|
|
IonList,
|
|
@@ -41,34 +50,58 @@ import { TaskInqueryUserAnswer } from './agent/tasks/poem/inquiry/3.inquiry-user
|
|
})
|
|
})
|
|
export class Tab2Page implements OnInit {
|
|
export class Tab2Page implements OnInit {
|
|
selectedTab: string = 'checkin'; // 默认选中的tab
|
|
selectedTab: string = 'checkin'; // 默认选中的tab
|
|
- weekPlan: any[] = [
|
|
|
|
- { date: '周一', bodyPart: '胸部', tasks: ['卧推', '哑铃飞鸟', '俯卧撑', '仰卧起坐'], completed: false },
|
|
|
|
- { date: '周二', bodyPart: '背部', tasks: ['引体向上', '划船', '拉力器背肌'], completed: false },
|
|
|
|
- { date: '周三', bodyPart: '腿部', tasks: ['深蹲', '腿推', '腿弯举'], completed: false },
|
|
|
|
- { date: '周四', bodyPart: '肩部', tasks: ['肩推', '侧平举', '前平举'], completed: false },
|
|
|
|
- { date: '周五', bodyPart: '腹部', tasks: ['仰卧起坐', '卷腹', 'Russian twist'], completed: false }
|
|
|
|
|
|
+ planList: any[] = [
|
|
|
|
+ ];
|
|
|
|
+ coachList: any[] = [
|
|
];
|
|
];
|
|
|
|
|
|
constructor(private router: Router, private modalCtrl: ModalController, private cdr: ChangeDetectorRef) {
|
|
constructor(private router: Router, private modalCtrl: ModalController, private cdr: ChangeDetectorRef) {
|
|
- addIcons({ checkmarkCircle, calendar, helpCircle });
|
|
|
|
|
|
+ addIcons({ checkmarkCircle, calendar, helpCircle, trash, create });
|
|
|
|
+ }
|
|
|
|
+ async loadPlanList() {
|
|
|
|
+ let query = new CloudQuery("fitPlan");
|
|
|
|
+ this.planList = await query.find();
|
|
|
|
+ console.log(this.planList);
|
|
|
|
+ }
|
|
|
|
+ async loadCoachList() {
|
|
|
|
+ let query = new CloudQuery("Coach");
|
|
|
|
+ this.coachList = await query.find();
|
|
|
|
+ console.log(this.planList);
|
|
}
|
|
}
|
|
-
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
// 初始时不需要强制触发视图更新
|
|
// 初始时不需要强制触发视图更新
|
|
|
|
+ this.loadPlanList()
|
|
|
|
+ this.loadCoachList()
|
|
}
|
|
}
|
|
editPlan(day: any) {
|
|
editPlan(day: any) {
|
|
console.log('编辑计划:', day);
|
|
console.log('编辑计划:', day);
|
|
- // 这里可以打开一个编辑页面或者弹窗,修改该计划
|
|
|
|
- // 示例:打开编辑页面
|
|
|
|
- // this.navCtrl.navigateForward('/edit-plan', { queryParams: { plan: day } });
|
|
|
|
|
|
+
|
|
|
|
+ // 创建一个弹出框
|
|
|
|
+ this.modalCtrl.create({
|
|
|
|
+ component: EditPlanModalComponent, // 这里你需要定义一个编辑计划的 modal 组件
|
|
|
|
+ componentProps: { plan: day } // 将计划内容传递给弹出框
|
|
|
|
+ }).then(modal => {
|
|
|
|
+ modal.present();
|
|
|
|
+
|
|
|
|
+ modal.onDidDismiss().then((result) => {
|
|
|
|
+ // 如果返回的数据包含修改后的计划,就更新计划列表
|
|
|
|
+ if (result.data) {
|
|
|
|
+ const updatedPlan = result.data;
|
|
|
|
+ const index = this.planList.findIndex(item => item.id === updatedPlan.id);
|
|
|
|
+ if (index !== -1) {
|
|
|
|
+ this.planList[index] = updatedPlan;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
// 删除计划
|
|
// 删除计划
|
|
deletePlan(day: any) {
|
|
deletePlan(day: any) {
|
|
console.log('删除计划:', day);
|
|
console.log('删除计划:', day);
|
|
- const index = this.weekPlan.indexOf(day);
|
|
|
|
|
|
+ const index = this.planList.indexOf(day);
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
- this.weekPlan.splice(index, 1);
|
|
|
|
|
|
+ this.planList.splice(index, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//问诊区域
|
|
//问诊区域
|
|
@@ -109,46 +142,61 @@ export class Tab2Page implements OnInit {
|
|
startTask(InquireServiceTaskList)
|
|
startTask(InquireServiceTaskList)
|
|
}
|
|
}
|
|
// 聊天页面
|
|
// 聊天页面
|
|
- openInquiry() {
|
|
|
|
|
|
+ openInquiry(coach: CloudObject) {
|
|
localStorage.setItem("company", "E4KpGvTEto")
|
|
localStorage.setItem("company", "E4KpGvTEto")
|
|
|
|
+ let consult = new CloudObject("fitConsultation")
|
|
|
|
+ let now = new Date();
|
|
|
|
+ let dateStr = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`
|
|
|
|
+ consult.set({
|
|
|
|
+ title: `交流记录${dateStr}-${coach?.get("name")}`,
|
|
|
|
+ coach: coach.toPointer(),
|
|
|
|
+ depart: {
|
|
|
|
+ __type: "Pointer",
|
|
|
|
+ className: "Coach",
|
|
|
|
+ objectId: coach.get("depart")?.objectId
|
|
|
|
+ },
|
|
|
|
+ })
|
|
let options: ChatPanelOptions = {
|
|
let options: ChatPanelOptions = {
|
|
roleId: "2DXJkRsjXK",
|
|
roleId: "2DXJkRsjXK",
|
|
onChatInit: (chat: FmodeChat) => {
|
|
onChatInit: (chat: FmodeChat) => {
|
|
console.log("onChatInit");
|
|
console.log("onChatInit");
|
|
console.log("预设角色", chat.role);
|
|
console.log("预设角色", chat.role);
|
|
- chat.role.set("name", "晓晓");
|
|
|
|
- chat.role.set("title", "全科医生");
|
|
|
|
- chat.role.set("desc", "一名亲切和蔼的门诊全科主任医生,晓晓,年龄36岁");
|
|
|
|
- chat.role.set("tags", ["全科", "门诊"]);
|
|
|
|
- chat.role.set("avatar", "https://nova-cloud.obs.cn-south-1.myhuaweicloud.com/storage/aigc/imagine/Q4Zif7fTbK-0.png")
|
|
|
|
|
|
+ chat.role.set("name", coach?.get("name"));
|
|
|
|
+ chat.role.set("title", "职业教练");
|
|
|
|
+ chat.role.set("tags", coach?.get("specialize"));
|
|
|
|
+ chat.role.set("avatar", "../../assets/images/coach2.jpg")
|
|
chat.role.set("prompt", `
|
|
chat.role.set("prompt", `
|
|
# 角色设定
|
|
# 角色设定
|
|
-您是一名亲切和蔼的专业的全科医生,晓晓,年龄36岁,需要完成一次完整的门诊服务。
|
|
|
|
|
|
+您是${coach?.get("name")},年龄${coach?.get("age")},特长为${coach?.get("specialize")},要完成一次教练与学员之间的锻炼部位交流。
|
|
|
|
|
|
# 对话环节
|
|
# 对话环节
|
|
-0.导诊(根据用户基本情况,引导挂号合适的科室)
|
|
|
|
-1.预设的问询方式(感冒问呼吸、肚子疼叩诊)
|
|
|
|
-- 打招呼,以用户自述为主
|
|
|
|
-- 当信息充足时候,确认用户症状对应的科室,并进入下一个环节
|
|
|
|
-2.拓展的问询细节
|
|
|
|
-例如:用户反映呼吸不畅,拓展出:是否咳嗽;是否感觉痛或者痒等其他需要的问题。
|
|
|
|
-- 当问询细节补充完成后进入下一个环节
|
|
|
|
-3.初步的诊断结果,并且同时列出检查检验项目
|
|
|
|
-初步诊断:确定需要有哪些进一步检查
|
|
|
|
-检查检验:获取医学客观数据
|
|
|
|
-- 等待用户提交客观数据,进入下一阶段
|
|
|
|
-4.给出诊断方案并给出处方
|
|
|
|
-- 完成处方时,请在消息结尾附带: [完成]
|
|
|
|
|
|
+0.导诊(根据用户基本情况,引导选择合适的训练计划)
|
|
|
|
+1.预设的问询方式(根据学员自述情况进行引导)
|
|
|
|
|
|
|
|
+- 打招呼,以学员自述为主
|
|
|
|
+- 当信息充足时,确认学员的目标与需求,并进入下一个环节
|
|
|
|
+2.拓展的问询细节
|
|
|
|
+例如:学员反映想要锻炼腹肌,拓展出:目前的锻炼频率;饮食习惯;是否有受伤历史等其他需要的问题。
|
|
|
|
+- 当问询细节补充完成后进入下一个环节
|
|
|
|
+3.初步的训练方案,并且同时列出需要的器械与注意事项 初步方案:确定需要的训练动作与频率 器械与注意事项:获取训练所需的器械信息
|
|
|
|
+- 等待学员确认并准备器械,进入下一阶段
|
|
|
|
+4.给出详细的训练计划并提供指导
|
|
|
|
+- 完成训练计划时,请在消息结尾附带: [交流完成]
|
|
# 开始话语
|
|
# 开始话语
|
|
-当您准备好了,可以以一个医生的身份,向来访的用户打招呼。`);
|
|
|
|
|
|
+当您准备好了,可以以一个健身教练的身份,向来访的学员打招呼。
|
|
|
|
+
|
|
|
|
+${coach?.get("name")}:你好!欢迎来到健身房,我是${coach?.get("name")}教练。今天你想要专注锻炼哪个部位呢?或者有什么具体的健身目标吗?`);
|
|
},
|
|
},
|
|
onMessage: (chat: FmodeChat, message: FmodeChatMessage) => {
|
|
onMessage: (chat: FmodeChat, message: FmodeChatMessage) => {
|
|
console.log("onMessage", message)
|
|
console.log("onMessage", message)
|
|
let content: any = message?.content
|
|
let content: any = message?.content
|
|
if (typeof content == "string") {
|
|
if (typeof content == "string") {
|
|
- if (content?.indexOf("[完成]") > -1) {
|
|
|
|
|
|
+ if (content?.indexOf("[交流完成]") > -1) {
|
|
console.log("门诊已完成")
|
|
console.log("门诊已完成")
|
|
|
|
+ consult.set({
|
|
|
|
+ content: content // 处方内容
|
|
|
|
+ })
|
|
|
|
+ consult.save();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|