|
@@ -4,7 +4,7 @@ import { addIcons } from 'ionicons';
|
|
|
import { checkmarkCircle, trash, calendar, helpCircle, create } from 'ionicons/icons';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
-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 { IonSelect, IonThumbnail, IonCardSubtitle, IonImg, IonCard, IonButtons, IonItem, IonList, IonHeader, IonIcon, IonToolbar, IonContent, IonSegment, IonSegmentButton, IonGrid, IonRow, IonCol, IonButton, IonLabel, IonBadge, IonInput, ModalController, IonCardTitle, IonCardContent, IonCardHeader, IonSelectOption } from '@ionic/angular/standalone';
|
|
|
import { FmodeChatCompletion, ImagineWork, DalleOptions, ChatPanelOptions, FmodeChat, FmodeChatMessage, openChatPanelModal } from "fmode-ng";
|
|
|
import { AgentTaskStep } from './agent/agent.task';
|
|
|
import { TaskPoemPictureDesc } from './agent/tasks/poem/poem-desc';
|
|
@@ -13,14 +13,19 @@ import { startTask } from './agent/agent.start';
|
|
|
import { TaskInqueryUserStory } from './agent/tasks/poem/inquiry/1.inquiry-user-story';
|
|
|
import { TaskInqueryDoctorQuestion } from './agent/tasks/poem/inquiry/2.inquiry-doctor-question';
|
|
|
import { TaskInqueryUserAnswer } from './agent/tasks/poem/inquiry/3.inquiry-user-answer';
|
|
|
-import { CloudObject, CloudQuery } from 'src/lib/ncloud';
|
|
|
+import { CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud';
|
|
|
import { EditPlanModalComponent } from './edit-plan-modal/edit-plan-modal.component';
|
|
|
+import { AlertController } from '@ionic/angular';
|
|
|
+import { openUserEditModal } from 'src/lib/user/modal-user-edit/modal-user-edit.component';
|
|
|
+import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-login.component';
|
|
|
@Component({
|
|
|
selector: 'app-tab2',
|
|
|
templateUrl: 'tab2.page.html',
|
|
|
styleUrls: ['tab2.page.scss'],
|
|
|
standalone: true,
|
|
|
imports: [
|
|
|
+ IonSelectOption,
|
|
|
+ IonSelect,
|
|
|
IonThumbnail,
|
|
|
IonCardSubtitle,
|
|
|
IonImg,
|
|
@@ -54,37 +59,60 @@ export class Tab2Page implements OnInit {
|
|
|
];
|
|
|
coachList: any[] = [
|
|
|
];
|
|
|
-
|
|
|
- constructor(private router: Router, private modalCtrl: ModalController, private cdr: ChangeDetectorRef) {
|
|
|
+ currentUser: CloudUser | undefined
|
|
|
+ constructor(private router: Router, private modalCtrl: ModalController, private cdr: ChangeDetectorRef, private alertController: AlertController) {
|
|
|
addIcons({ checkmarkCircle, calendar, helpCircle, trash, create });
|
|
|
+ this.currentUser = new CloudUser();
|
|
|
}
|
|
|
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() {
|
|
|
// 初始时不需要强制触发视图更新
|
|
|
this.loadPlanList()
|
|
|
this.loadCoachList()
|
|
|
}
|
|
|
+ //打卡页面
|
|
|
+ async login() {
|
|
|
+ // 弹出登录窗口
|
|
|
+ let user = await openUserLoginModal(this.modalCtrl);
|
|
|
+ if (user?.id) {
|
|
|
+ this.currentUser = user
|
|
|
+ }
|
|
|
+ }
|
|
|
+ async signup() {
|
|
|
+ // 弹出注册窗口
|
|
|
+ let user = await openUserLoginModal(this.modalCtrl, "signup");
|
|
|
+ if (user?.id) {
|
|
|
+ this.currentUser = user
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logout() {
|
|
|
+ this.currentUser?.logout();
|
|
|
+ }
|
|
|
+
|
|
|
+ editUser() {
|
|
|
+ openUserEditModal(this.modalCtrl)
|
|
|
+ }
|
|
|
+
|
|
|
+ //plan页面
|
|
|
editPlan(day: any) {
|
|
|
console.log('编辑计划:', day);
|
|
|
|
|
|
// 创建一个弹出框
|
|
|
this.modalCtrl.create({
|
|
|
- component: EditPlanModalComponent, // 这里你需要定义一个编辑计划的 modal 组件
|
|
|
- componentProps: { plan: day } // 将计划内容传递给弹出框
|
|
|
+ component: EditPlanModalComponent,
|
|
|
+ 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);
|
|
@@ -95,17 +123,39 @@ export class Tab2Page implements OnInit {
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+ async deletePlan(day: any) {
|
|
|
+ const alert = await this.alertController.create({
|
|
|
+ header: '确认删除',
|
|
|
+ message: '确定要删除此计划吗?',
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: '取消',
|
|
|
+ role: 'cancel',
|
|
|
+ cssClass: 'secondary',
|
|
|
+ handler: () => {
|
|
|
+ console.log('删除操作被取消');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '确认',
|
|
|
+ handler: () => {
|
|
|
+ day.destroy()
|
|
|
+ .then(() => {
|
|
|
+ console.log('计划已删除');
|
|
|
+ this.loadPlanList();
|
|
|
+ })
|
|
|
+ .catch((error: any) => {
|
|
|
+ console.error('删除失败:', error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
|
|
|
- // 删除计划
|
|
|
- deletePlan(day: any) {
|
|
|
- console.log('删除计划:', day);
|
|
|
- const index = this.planList.indexOf(day);
|
|
|
- if (index !== -1) {
|
|
|
- this.planList.splice(index, 1);
|
|
|
- }
|
|
|
+ await alert.present();
|
|
|
}
|
|
|
- //问诊区域
|
|
|
|
|
|
+ //任务链
|
|
|
taskList: AgentTaskStep[] = []
|
|
|
//一个等待一秒的函数 每经过一秒
|
|
|
wait(duration: number = 1000) {
|
|
@@ -115,9 +165,7 @@ export class Tab2Page implements OnInit {
|
|
|
}, duration);
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
shareData: any = {}
|
|
|
-
|
|
|
// 任务:完成故事意境描述及图像绘制
|
|
|
doPoemTask() {
|
|
|
let task1 = TaskPoemPictureDesc({ shareData: this.shareData, modalCtrl: this.modalCtrl });
|
|
@@ -126,12 +174,10 @@ export class Tab2Page implements OnInit {
|
|
|
this.taskList = PoemTaskList
|
|
|
startTask(PoemTaskList)
|
|
|
}
|
|
|
-
|
|
|
doInqueryTask() {
|
|
|
let task1 = TaskInqueryUserStory({ shareData: this.shareData, modalCtrl: this.modalCtrl });
|
|
|
let task2 = TaskInqueryDoctorQuestion({ shareData: this.shareData, modalCtrl: this.modalCtrl });
|
|
|
let task3 = TaskInqueryUserAnswer({ shareData: this.shareData, modalCtrl: this.modalCtrl });
|
|
|
-
|
|
|
// 定义任务集
|
|
|
let InquireServiceTaskList = [
|
|
|
task1, task2, task3
|
|
@@ -142,19 +188,47 @@ export class Tab2Page implements OnInit {
|
|
|
startTask(InquireServiceTaskList)
|
|
|
}
|
|
|
// 聊天页面
|
|
|
- openInquiry(coach: CloudObject) {
|
|
|
+ async openInquiry(coach: CloudObject) {
|
|
|
+ let currentUser = new CloudUser();
|
|
|
+ let userPrompt = ``
|
|
|
+ if (!currentUser?.id) {
|
|
|
+ console.log("用户未登录,请登录后重试");
|
|
|
+ let user = await openUserLoginModal(this.modalCtrl);
|
|
|
+ if (!user?.id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ currentUser = user;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (currentUser?.get("realname")) {
|
|
|
+ userPrompt += `当前来访的患者,姓名:${currentUser?.get("realname")}`
|
|
|
+ }
|
|
|
+ if (currentUser?.get("gender")) {
|
|
|
+ userPrompt += `,性别:${currentUser?.get("gender")}`
|
|
|
+ }
|
|
|
+ if (currentUser?.get("age")) {
|
|
|
+ userPrompt += `,年龄:${currentUser?.get("age")}`
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
localStorage.setItem("company", "E4KpGvTEto")
|
|
|
+
|
|
|
let consult = new CloudObject("fitConsultation")
|
|
|
let now = new Date();
|
|
|
let dateStr = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`
|
|
|
+ // 对象权限的精确指定
|
|
|
+ let ACL: any = {
|
|
|
+ "*": { read: false, write: false }
|
|
|
+ }
|
|
|
+ if (currentUser?.id) {
|
|
|
+ ACL[currentUser?.id] = { read: true, write: true }
|
|
|
+ }
|
|
|
+ localStorage.setItem("company", "E4KpGvTEto")
|
|
|
consult.set({
|
|
|
title: `交流记录${dateStr}-${coach?.get("name")}`,
|
|
|
coach: coach.toPointer(),
|
|
|
- depart: {
|
|
|
- __type: "Pointer",
|
|
|
- className: "Coach",
|
|
|
- objectId: coach.get("depart")?.objectId
|
|
|
- },
|
|
|
+ user: currentUser.toPointer(),
|
|
|
+ ACL: ACL
|
|
|
})
|
|
|
let options: ChatPanelOptions = {
|
|
|
roleId: "2DXJkRsjXK",
|
|
@@ -184,15 +258,14 @@ export class Tab2Page implements OnInit {
|
|
|
- 完成训练计划时,请在消息结尾附带: [交流完成]
|
|
|
# 开始话语
|
|
|
当您准备好了,可以以一个健身教练的身份,向来访的学员打招呼。
|
|
|
-
|
|
|
-${coach?.get("name")}:你好!欢迎来到健身房,我是${coach?.get("name")}教练。今天你想要专注锻炼哪个部位呢?或者有什么具体的健身目标吗?`);
|
|
|
+你好!欢迎来到健身房,我是${coach?.get("name")}教练。今天你想要专注锻炼哪个部位呢?或者有什么具体的健身目标吗?`);
|
|
|
},
|
|
|
onMessage: (chat: FmodeChat, message: FmodeChatMessage) => {
|
|
|
console.log("onMessage", message)
|
|
|
let content: any = message?.content
|
|
|
if (typeof content == "string") {
|
|
|
if (content?.indexOf("[交流完成]") > -1) {
|
|
|
- console.log("门诊已完成")
|
|
|
+ console.log("交流已完成")
|
|
|
consult.set({
|
|
|
content: content // 处方内容
|
|
|
})
|
|
@@ -207,21 +280,16 @@ ${coach?.get("name")}:你好!欢迎来到健身房,我是${coach?.get("nam
|
|
|
}
|
|
|
openChatPanelModal(this.modalCtrl, options)
|
|
|
}
|
|
|
-
|
|
|
openChat() {
|
|
|
let options: ChatPanelOptions = {
|
|
|
roleId: "2DXJkRsjXK",
|
|
|
onChatSaved: (chat: FmodeChat) => {
|
|
|
// chat?.chatSession?.id 本次会话的 chatId
|
|
|
-
|
|
|
console.log("onChatSaved", chat, chat?.chatSession, chat?.chatSession?.id)
|
|
|
-
|
|
|
},
|
|
|
-
|
|
|
}
|
|
|
openChatPanelModal(this.modalCtrl, options)
|
|
|
}
|
|
|
-
|
|
|
restoreChat(chatId: string) {
|
|
|
let options: ChatPanelOptions = {
|
|
|
roleId: "2DXJkRsjXK",
|
|
@@ -229,12 +297,9 @@ ${coach?.get("name")}:你好!欢迎来到健身房,我是${coach?.get("nam
|
|
|
}
|
|
|
openChatPanelModal(this.modalCtrl, options)
|
|
|
}
|
|
|
-
|
|
|
goChat() {
|
|
|
this.router.navigateByUrl("/chat/session/role/2DXJkRsjXK")
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
// audioModalHeightPoint:number = 0.35;
|
|
|
// async startTalk(){
|
|
|
// // 根据手机兼容性,适配组件弹出高度
|
|
@@ -256,9 +321,6 @@ ${coach?.get("name")}:你好!欢迎来到健身房,我是${coach?.get("nam
|
|
|
// })
|
|
|
// modal.present();
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
// 页面跳转功能
|
|
|
goToPage(page: string) {
|
|
|
// 更新选中的tab
|