|
@@ -1,66 +1,156 @@
|
|
|
-import { Component, NgModule, OnInit } from '@angular/core';
|
|
|
-import { ModalController, IonModal, IonHeader, IonToolbar, IonTitle, IonContent, IonList, IonItem, IonLabel, IonAvatar, IonButton, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView, IonCardContent, IonCardTitle, IonCardHeader, IonCard, IonIcon, IonButtons, IonInput, IonRefresherContent, IonRefresher } from '@ionic/angular/standalone';
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import {
|
|
|
+ ModalController,
|
|
|
+ IonModal,
|
|
|
+ IonHeader,
|
|
|
+ IonToolbar,
|
|
|
+ IonTitle,
|
|
|
+ IonContent,
|
|
|
+ IonList,
|
|
|
+ IonItem,
|
|
|
+ IonLabel,
|
|
|
+ IonAvatar,
|
|
|
+ IonButton,
|
|
|
+ IonSegment,
|
|
|
+ IonSegmentButton,
|
|
|
+ IonSegmentContent,
|
|
|
+ IonSegmentView,
|
|
|
+ IonCardContent,
|
|
|
+ IonCardTitle,
|
|
|
+ IonCardHeader,
|
|
|
+ IonCard,
|
|
|
+ IonIcon,
|
|
|
+ IonButtons,
|
|
|
+ IonInput,
|
|
|
+ IonRefresherContent,
|
|
|
+ IonRefresher,
|
|
|
+ LoadingController,
|
|
|
+ IonSpinner,
|
|
|
+ IonGrid, // 导入 IonGrid
|
|
|
+ IonRow, // 导入 IonRow
|
|
|
+ IonCol // 导入 IonCol
|
|
|
+} from '@ionic/angular/standalone'; // 确保导入自 '@ionic/angular/standalone'
|
|
|
+
|
|
|
import { addIcons } from 'ionicons';
|
|
|
-import { airplane, bluetooth, call, wifi } from 'ionicons/icons';
|
|
|
+import { airplane, bluetooth, call, wifi, arrowBackOutline, menuOutline, personOutline, businessOutline, medicalOutline, documentTextOutline, folderOpenOutline } from 'ionicons/icons';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud';
|
|
|
// import { FmMarkdownPreview } from 'fmode-ng';
|
|
|
import { Router } from '@angular/router';
|
|
|
addIcons({ airplane, bluetooth, call, wifi });
|
|
|
+
|
|
|
@Component({
|
|
|
selector: 'page-my-health',
|
|
|
templateUrl: './page-my-health.component.html',
|
|
|
styleUrls: ['./page-my-health.component.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [
|
|
|
- IonHeader, IonToolbar, IonTitle, IonContent,
|
|
|
- IonLabel,IonItem,IonList,IonAvatar,CommonModule,IonButton,
|
|
|
- IonSegment, IonSegmentButton,
|
|
|
- IonSegmentContent,IonSegmentView,IonCardContent, IonCardTitle, IonCardHeader,IonCard,
|
|
|
- IonModal,IonIcon, IonButtons,IonInput,IonRefresher,IonRefresherContent
|
|
|
- // FmMarkdownPreview,
|
|
|
- ]
|
|
|
+ imports: [
|
|
|
+ IonHeader,
|
|
|
+ IonToolbar,
|
|
|
+ IonTitle,
|
|
|
+ IonContent,
|
|
|
+ IonLabel,
|
|
|
+ IonItem,
|
|
|
+ IonList,
|
|
|
+ IonAvatar,
|
|
|
+ CommonModule,
|
|
|
+ IonButton,
|
|
|
+ IonSegment,
|
|
|
+ IonSegmentButton,
|
|
|
+ IonSegmentContent,
|
|
|
+ IonSegmentView,
|
|
|
+ IonCardContent,
|
|
|
+ IonCardTitle,
|
|
|
+ IonCardHeader,
|
|
|
+ IonCard,
|
|
|
+ IonModal,
|
|
|
+ IonIcon,
|
|
|
+ IonButtons,
|
|
|
+ IonInput,
|
|
|
+ IonRefresher,
|
|
|
+ IonRefresherContent,
|
|
|
+ IonSpinner,
|
|
|
+ IonGrid, // 添加 IonGrid 到 imports
|
|
|
+ IonRow, // 添加 IonRow 到 imports
|
|
|
+ IonCol // 添加 IonCol 到 imports
|
|
|
+ // FmMarkdownPreview,
|
|
|
+ ]
|
|
|
})
|
|
|
-export class PageMyHealthComponent implements OnInit {
|
|
|
- handleRefresh(event:any) {
|
|
|
- setTimeout(() => {
|
|
|
- // Any calls to load data go here
|
|
|
- this.loadData();
|
|
|
- event.target.complete();
|
|
|
- }, 2000);
|
|
|
- }
|
|
|
+export class PageMyHealthComponent implements OnInit {
|
|
|
+ allMessage: Array<CloudObject> = [];
|
|
|
+ isLoading: boolean = false;
|
|
|
+ errorMessage: string = "";
|
|
|
|
|
|
- avatar : string = "../assets/imgs/avatar.png";
|
|
|
- currentUser : CloudUser | undefined ;
|
|
|
- objectId : string = "";
|
|
|
+ avatar: string = "../assets/imgs/avatar.png"; // 默认头像
|
|
|
+ currentUser: CloudUser | undefined;
|
|
|
+ objectId: string = "";
|
|
|
+ userName: string = "";
|
|
|
+
|
|
|
+ back: string = "back";
|
|
|
+
|
|
|
+ // 备用头像 URL
|
|
|
+ fallbackAvatarUrl: string = 'https://app.fmode.cn/dev/jxnu/202226701019/头像示例.png';
|
|
|
|
|
|
constructor(
|
|
|
- private router: Router
|
|
|
+ private router: Router,
|
|
|
+ private loadingController: LoadingController
|
|
|
) {
|
|
|
this.currentUser = new CloudUser();
|
|
|
- this.avatar = this.currentUser.data["avatar"];
|
|
|
+ this.avatar = this.currentUser.data["avatar"] || this.fallbackAvatarUrl;
|
|
|
this.objectId = this.currentUser.data['objectId'];
|
|
|
+ this.userName = this.currentUser.data["realname"] || "用户";
|
|
|
}
|
|
|
- allMessage : Array<CloudObject> = [];
|
|
|
|
|
|
- async loadData(){
|
|
|
- let user = new CloudUser();
|
|
|
- console.log("objectId",this.objectId);
|
|
|
- let query = new CloudQuery('Consultation');
|
|
|
- query.include("doctor","depart");
|
|
|
- query.equalTo("user",user?.id);
|
|
|
- this.allMessage = await query.find();
|
|
|
- console.log("allMessage",this.allMessage);
|
|
|
- }
|
|
|
-
|
|
|
ngOnInit() {
|
|
|
this.loadData();
|
|
|
}
|
|
|
- back:string = "back"
|
|
|
- backHome(){
|
|
|
+
|
|
|
+ async loadData() {
|
|
|
+ this.isLoading = true;
|
|
|
+ const loading = await this.loadingController.create({
|
|
|
+ message: '加载中...',
|
|
|
+ });
|
|
|
+ await loading.present();
|
|
|
+
|
|
|
+ try {
|
|
|
+ let user = new CloudUser();
|
|
|
+ console.log("objectId", this.objectId);
|
|
|
+ let query = new CloudQuery('Consultation');
|
|
|
+ query.include("doctor", "depart");
|
|
|
+ query.equalTo("user", { "__type": "Pointer", "className": "_User", "objectId": this.objectId });
|
|
|
+
|
|
|
+ const messages = await query.find();
|
|
|
+ console.log("allMessage", messages);
|
|
|
+
|
|
|
+ this.allMessage = messages;
|
|
|
+ } catch (error) {
|
|
|
+ console.error("加载数据失败:", error);
|
|
|
+ this.errorMessage = "数据加载失败,请稍后再试。";
|
|
|
+ } finally {
|
|
|
+ this.isLoading = false;
|
|
|
+ await loading.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ handleRefresh(event: any) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.allMessage = [];
|
|
|
+ this.loadData().then(() => {
|
|
|
+ event.target.complete();
|
|
|
+ });
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+
|
|
|
+ backHome() {
|
|
|
this.router.navigate(['/tabs/tab1']);
|
|
|
}
|
|
|
- gotouser(){
|
|
|
|
|
|
+ gotouser() {
|
|
|
+ // 用户相关逻辑
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理图片加载错误,设置备用图片
|
|
|
+ handleImageError() {
|
|
|
+ this.avatar = this.fallbackAvatarUrl;
|
|
|
}
|
|
|
-}
|
|
|
+}
|