123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- import { Component } from '@angular/core';
- import { IonCardHeader, IonHeader, IonToolbar, IonTitle, IonContent, IonTabButton, IonSearchbar, IonLabel, IonItem, IonList, NavController, IonCard, IonCardTitle, IonCardSubtitle, IonCardContent, IonThumbnail, IonRippleEffect, IonFab, IonFabList, IonFabButton, IonBadge } from '@ionic/angular/standalone';
- import { ExploreContainerComponent } from '../explore-container/explore-container.component';
- import { IonButton } from '@ionic/angular/standalone';
- import { IonIcon } from '@ionic/angular/standalone';
- import { Router } from '@angular/router';
- import { CommonModule } from '@angular/common';
- import { ModalController } from '@ionic/angular/standalone';
- import { HttpClient } from '@angular/common/http';
- import { addIcons } from 'ionicons';
- import { documentText, chatbubbles, person, calendar, newspaper,
- medkit,clipboard, podium, videocam, people, chevronForwardOutline,
- add} from 'ionicons/icons';
- import { CloudObject, CloudQuery, CloudUser } from 'src/lib/ncloud';
- import { ChatPanelOptions, FmodeChat, FmodeChatMessage, openChatPanelModal } from 'fmode-ng';
- addIcons({ documentText, chatbubbles, person, calendar, newspaper,
- medkit,clipboard, podium, videocam, people,add
- });
- import { FmodeMapModule } from 'fmode-ng';
-
- interface ClinicAd {
- id: number;
- title: string;
- price?: string;
- description: string;
- image: string;
- backgroundColor: string;
- }
- interface ServiceItem {
- id: number;
- title: string;
- description: string;
- image: string;
- hasDetail?: boolean;
- isHot?: boolean;
- backgroundColor?: string;
- size?: 'large' | 'small';
- }
- @Component({
- selector: 'app-tab1',
- templateUrl: 'tab1.page.html',
- styleUrls: ['tab1.page.scss'],
- standalone: true,
- imports: [
- IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent, IonTabButton, IonButton,
- IonIcon,IonSearchbar,IonLabel,IonItem,IonList,CommonModule,IonCard,IonCardHeader,IonCardTitle,IonCardSubtitle,
- IonCardContent, IonThumbnail, IonRippleEffect, IonFab, IonFabButton, IonFabList,IonBadge
- ],
- })
- export class Tab1Page {
- title1 = "特色服务";
- subtitle1 = "一站式医疗健康解决方案";
-
- services: ServiceItem[] = [
- {
- id: 1,
- title: "援脑妇科病",
- description: "小症状隐藏大隐患",
- image: "../../assets/image/doctor7.png",
- hasDetail: true,
- backgroundColor: "#E8F5F2",
- size: 'large'
- },
- {
- id: 2,
- title: "解决口腔难题",
- description: "享健康生活",
- image: "../../assets/image/doctor7.png",
- hasDetail: true,
- isHot: true,
- backgroundColor: "#E8F5F2",
- size: 'large'
- },
- {
- id: 3,
- title: "解决皮肤难题",
- description: "专业医生来助力",
- image: "../../assets/image/doctor7.png",
- size: 'small'
- },
- {
- id: 4,
- title: "儿科常见疾病",
- description: "在家就能请专家",
- image: "../../assets/image/doctor7.png",
- size: 'small'
- },
- {
- id: 5,
- title: "赶走烦恼困扰",
- description: "科学治疗好经不费",
- image: "../../assets/image/doctor7.png",
- size: 'small'
- },
- {
- id: 6,
- title: "知己心理",
- description: "温暖地陪你懂自己",
- image: "../../assets/image/doctor7.png",
- size: 'small'
- },
- {
- id: 7,
- title: "搞定偏头痛",
- description: "止疼彻底合集",
- image: "../../assets/image/doctor7.png",
- size: 'small'
- },
- {
- id: 8,
- title: "搞定偏头痛",
- description: "止疼彻底合集",
- image: "../../assets/image/doctor7.png",
- size: 'small'
- }
- ];
- title = "专科门诊";
- subtitle = "智养高复诊率、高口碑名医";
-
- clinicAds: ClinicAd[] = [
- {
- id: 1,
- title: "专业男科",
- price: "18元起",
- description: "阳痿早泄",
- image: "../../assets/image/doctor7.png",
- backgroundColor: "#EEF4FF"
- },
- {
- id: 2,
- title: "智养中医馆",
- price: "18元起",
- description: "口碑中医",
- image: "../../assets/image/doctor6.png",
- backgroundColor: "#FFF5EB"
- }
- ];
- constructor(
- private router: Router,
- private modalCtrl: ModalController,
- // private navCtrl: NavController,
- private http: HttpClient // 注入 HttpClient
- ) {
- addIcons({chevronForwardOutline});}
- /**
- * 轮播图
- */
- images = [
- 'https://picsum.photos/800/400?random=1',
- 'https://picsum.photos/800/400?random=2',
- 'https://picsum.photos/800/400?random=3',
- 'https://picsum.photos/800/400?random=4',
- 'https://picsum.photos/800/400?random=5',
- 'https://picsum.photos/800/400?random=6',
- ];
- currentSlide = 0;
- intervalId: any;
- setSlidePosition() {
- // 这里不需要额外的逻辑,因为在 HTML 中已经通过绑定实现
- }
- nextSlide() {
- this.currentSlide = (this.currentSlide + 1) % this.images.length;
- }
- prevSlide() {
- this.currentSlide = (this.currentSlide - 1 + this.images.length) % this.images.length;
- }
- goToSlide(index: number) {
- this.currentSlide = index;
- }
- startAutoSlide() {
- this.intervalId = setInterval(() => this.nextSlide(), 3000);
- }
- ngOnDestroy() {
- if (this.intervalId) {
- clearInterval(this.intervalId);
- }
- }
- /**
- * Go to the ai page
- */
- goToPage1(){
- console.log(['route'])
- this.router.navigate(['/tabs/inquiry/ai'])
- }
- /**
- * Go to the human page
- */
- goToPage2(){
- this.router.navigate(['/tabs/inquiry/human'])
- }
- goToPicture(){
- console.log(['route'])
- this.router.navigate(['/tabs/picture'])
- }
- searchContent:string = ''; //搜索内容
- handleInput(ev:any) {
- console.log("ev.detail.value: ",ev.detail.value)
- this.searchContent = ev.detail.value;
- }
- search(){
- if (this.searchContent == ''){
- console.log("请输入搜索内容")
- }
- else {
- console.log("搜索内容: ",this.searchContent)
- this.searchContent = '';
- }
- }
- // 功能按钮数据
- functionItems1 = [
- { label: '专属医生', icon: 'document-text', route: '/tabs/create-agent' },
- { label: '我的健康', icon: 'person', route: '/tabs/my-health' },
- { label: '药品展示', icon: 'calendar', route: '/tabs/tab3' },
- { label: '健康科普', icon: 'medkit', route: '/tabs/tab2' },
- ];
- // 导航到指定路由
- navigateTo(route: string) {
- this.router.navigate([route]);
- console.log("route: ",route)
- }
- ngOnInit() {
- this.loadDoctorList()
- this.startAutoSlide();
- }
- doctorList:Array<CloudObject> = []
- async loadDoctorList(){
- let query = new CloudQuery("Doctor");
- query.include("depart")
- let List = await query.find()
- for(let i = 0; i < 3; i++) {
- this.doctorList.push(List[i])
- }
- }
- goToViewAll(){
- console.log(['route'])
- this.router.navigate(['/tabs/inquiry/ai'])
- }
-
- currentUser:CloudUser|undefined
- /** 示例:问诊根据doctor拼接提示词 */
- async openInquiry(doctor:any){
- // 验证用户登录
- let currentUser = new CloudUser();
- let userPrompt = ``
- if(!currentUser?.id){
- console.log("用户未登录,请登录后重试");
- // let user = await openUserLoginModal(this.modalCtrl);
- // if(!user?.id){
- // return
- // }
- // currentUser = user;
- this.router.navigate(['/tabs/tab4'])
- return
- }
- console.log("currentUser: ",currentUser)
- 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("Consultation")
- 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}
- }
- consult.set({
- title:`${doctor.get('depart')?.name || ""}门诊记录${dateStr}-${doctor?.get("name")}`,
- doctor:doctor.toPointer(),
- depart:{
- __type:"Pointer",
- className:"Department",
- objectId:doctor.get("depart")?.objectId
- },
- user:currentUser.toPointer(),
- ACL:ACL
- })
- let options:ChatPanelOptions = {
- roleId:"2DXJkRsjXK",
- onChatInit:(chat:FmodeChat)=>{
- console.log("onChatInit");
- console.log("预设角色",chat.role);
- chat.role.set("name",doctor?.get("name"));
- chat.role.set("title",doctor?.get("title"));
- chat.role.set("desc",doctor?.get("desc"));
- chat.role.set("tags",doctor?.get("qualifications"));
- chat.role.set("avatar",doctor?.get("avatar") || "../../assets/image/doctor7.png")
- chat.role.set("prompt",`
- # 角色设定
- 您是${doctor?.get("name")},${doctor?.get("desc")},年龄${doctor?.get("age")}岁,需要完成一次完整的门诊服务。
- # 对话环节
- 0.导诊(根据用户基本情况,引导挂号合适的科室)
- 1.预设的问询方式(根据不同症状来问询具体的情况)
- - 打招呼,以用户自述为主
- - 当信息充足时候,确认用户症状对应的科室,并进入下一个环节
- 2.拓展的问询细节
- 例如:用户反映呼吸不畅,拓展出:是否咳嗽;是否感觉痛或者痒等其他需要的问题。
- - 当问询细节补充完成后进入下一个环节
- 3.初步的诊断结果,并且同时列出检查检验项目
- 初步诊断:确定需要有哪些进一步检查
- 检查检验:获取医学客观数据
- - 等待用户提交客观数据,进入下一阶段
- 4.给出诊断方案并给出处方
- - 完成处方时,请在消息结尾附带: [处方完成]
- # 开始话语
- 当您准备好了,可以以一个医生的身份,先向来访的用户亲切地打招呼。
- ${userPrompt}
- `);
- },
- onMessage:(chat:FmodeChat,message:FmodeChatMessage)=>{
- console.log("onMessage",message)
- let content:any = message?.content
- if(typeof content == "string"){
- if(content?.indexOf("[处方完成]")>-1){
- console.log("门诊已完成")
- consult.set({
- content:content // 处方内容
- })
- consult.save();
- }
- }
- },
- onChatSaved:(chat:FmodeChat)=>{
- // chat?.chatSession?.id 本次会话的 chatId
- console.log("onChatSaved",chat,chat?.chatSession,chat?.chatSession?.id)
- // consult.set({
- // chatId:chat?.chatSession?.id
- // })
- console.log("chat.MessageList", chat?.messageList)
- }
- }
- openChatPanelModal(this.modalCtrl,options)
- }
- addNew(){
- this.router.navigate(["/tabs/create-agent"]);
- }
- }
|