|
@@ -4,7 +4,7 @@ import { addIcons } from 'ionicons';
|
|
|
import { checkmarkCircle, sunny, infiniteOutline, alertCircleOutline, bicycleOutline, logoGitlab, trash, calendar, helpCircle, create } from 'ionicons/icons';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
-import { IonDatetime, 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 { IonDatetime, IonSelect, IonItemOptions, 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, IonItemSliding, IonItemOption } from '@ionic/angular/standalone';
|
|
|
import { FmodeChatCompletion, ImagineWork, DalleOptions, ChatPanelOptions, FmodeChat, FmodeChatMessage, MarkdownPreviewModule, openChatPanelModal } from "fmode-ng";
|
|
|
import { AgentTaskStep } from './agent/agent.task';
|
|
|
import { TaskPoemPictureDesc } from './agent/tasks/poem/poem-desc';
|
|
@@ -18,6 +18,7 @@ import { EditPlanModalComponent } from './edit-plan-modal/edit-plan-modal.compon
|
|
|
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';
|
|
|
+import { TestPageComponent } from './test-page/test-page.component';
|
|
|
@Component({
|
|
|
selector: 'app-tab2',
|
|
|
templateUrl: 'tab2.page.html',
|
|
@@ -52,7 +53,10 @@ import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-log
|
|
|
IonLabel,
|
|
|
IonBadge,
|
|
|
IonInput,
|
|
|
- IonDatetime
|
|
|
+ IonDatetime,
|
|
|
+ IonItemOption,
|
|
|
+ IonItemSliding,
|
|
|
+ IonItemOptions,
|
|
|
]
|
|
|
})
|
|
|
export class Tab2Page implements OnInit {
|
|
@@ -96,6 +100,13 @@ export class Tab2Page implements OnInit {
|
|
|
let query = new CloudQuery("Coach");
|
|
|
this.coachList = await query.find();
|
|
|
}
|
|
|
+ calculateBMI(height: number, weight: number): number {
|
|
|
+ // 身高转换为米
|
|
|
+ const heightInMeters = height / 100;
|
|
|
+ // 计算 BMI
|
|
|
+ const bmi = weight / (heightInMeters * heightInMeters);
|
|
|
+ return parseFloat(bmi.toFixed(2));
|
|
|
+ }
|
|
|
getEncouragement(bmi: number): string {
|
|
|
if (bmi < 18.5) {
|
|
|
return '您的BMI偏低,注意保持健康的饮食哦!(๑•́ ₃ •̀๑)';
|
|
@@ -169,9 +180,8 @@ export class Tab2Page implements OnInit {
|
|
|
const formattedDate = this.formatDate(currentDate);
|
|
|
if (!this.checkInHistory.has(formattedDate)) {
|
|
|
this.checkInHistory.add(formattedDate);
|
|
|
- this.days = this.checkInHistory.size; // 更新总打卡天数
|
|
|
- this.calculateConsecutiveDays(); // 更新连续打卡天数
|
|
|
- // 获取当前用户数据并更新 checkeddays 字段
|
|
|
+ this.days = this.checkInHistory.size;
|
|
|
+ this.calculateConsecutiveDays();
|
|
|
let currentUser = new CloudUser();
|
|
|
const cloudQuery = new CloudQuery("fitUser");
|
|
|
cloudQuery.equalTo("user", currentUser.toPointer());
|
|
@@ -179,19 +189,15 @@ export class Tab2Page implements OnInit {
|
|
|
if (userData.length > 0) {
|
|
|
const user = userData[0];
|
|
|
let checkedDays = user.get("checkeddays") || [];
|
|
|
- checkedDays.push(formattedDate); // 添加新的打卡日期
|
|
|
-
|
|
|
- // 更新数据库中的 checkeddays 字段
|
|
|
+ checkedDays.push(formattedDate);
|
|
|
user.set({ "checkeddays": checkedDays });
|
|
|
- user.set({ "days": this.days }); // 更新已打卡天数
|
|
|
- user.set({ "sucdays": this.consecutiveDays }); // 更新连续打卡天数
|
|
|
+ user.set({ "days": this.days });
|
|
|
+ user.set({ "sucdays": this.consecutiveDays });
|
|
|
await user.save();
|
|
|
this.loadPlanUser()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 处理日期变更
|
|
|
onDateChange(event: any) {
|
|
|
this.realDate = new Date(this.correctDate(event.detail.value));
|
|
|
}
|
|
@@ -238,37 +244,58 @@ 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);
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // ]
|
|
|
- // });
|
|
|
+ regeneratePlan() {
|
|
|
+ console.log('重新生成计划:');
|
|
|
|
|
|
- // await alert.present();
|
|
|
- // }
|
|
|
+ // 创建一个弹出框
|
|
|
+ this.modalCtrl.create({
|
|
|
+ component: TestPageComponent,
|
|
|
+ componentProps: {}
|
|
|
+ }).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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.loadPlanList()
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ await alert.present();
|
|
|
+ }
|
|
|
//任务链
|
|
|
taskList: AgentTaskStep[] = []
|
|
|
//一个等待一秒的函数 每经过一秒
|
|
@@ -282,6 +309,7 @@ export class Tab2Page implements OnInit {
|
|
|
shareData: any = {}
|
|
|
// 任务:完成故事意境描述及图像绘制
|
|
|
doPoemTask() {
|
|
|
+
|
|
|
let task1 = TaskPoemPictureDesc({ shareData: this.shareData, modalCtrl: this.modalCtrl });
|
|
|
let task2 = TaskPoemPictureCreate({ shareData: this.shareData, modalCtrl: this.modalCtrl });
|
|
|
let PoemTaskList = [task1, task2]
|
|
@@ -337,7 +365,6 @@ export class Tab2Page implements OnInit {
|
|
|
if (currentUser?.id) {
|
|
|
ACL[currentUser?.id] = { read: true, write: true }
|
|
|
}
|
|
|
- localStorage.setItem("company", "E4KpGvTEto")
|
|
|
consult.set({
|
|
|
title: `交流记录${dateStr}-${coach?.get("name")}`,
|
|
|
coach: coach.toPointer(),
|