فهرست منبع

修复在线咨询以及优化ai或者医生返回的信息支持md格式

张田田 4 ماه پیش
والد
کامیت
89bdeadb3e

+ 23 - 8
miniprogram/app.json

@@ -1,10 +1,17 @@
 {
-  "pages": ["pages/home/home", "pages/mine/mine"],
+  "pages": [
+    "pages/home/home",
+    "pages/mine/mine"
+  ],
   "subpackages": [
     {
       "name": "chats",
       "root": "module/chats",
-      "pages": ["pages/index/index", "pages/analysis/analysis", "pages/consultation-record/consultation-record"]
+      "pages": [
+        "pages/index/index",
+        "pages/analysis/analysis",
+        "pages/consultation-record/consultation-record"
+      ]
     },
     {
       "name": "health",
@@ -52,12 +59,16 @@
     {
       "name": "charts",
       "root": "module/charts",
-      "pages": ["record-index/record-index"]
+      "pages": [
+        "record-index/record-index"
+      ]
     },
     {
       "name": "follow",
       "root": "module/follow",
-      "pages": ["pages/evaluation/report"]
+      "pages": [
+        "pages/evaluation/report"
+      ]
     },
     {
       "name": "care",
@@ -72,7 +83,9 @@
   ],
   "preloadRule": {
     "pages/home/home": {
-      "packages": ["chats"]
+      "packages": [
+        "chats"
+      ]
     }
   },
   "window": {
@@ -84,7 +97,6 @@
     "backgroundColorTop": "#ffffff",
     "backgroundColorBottom": "#ffffff"
   },
-
   "rendererOptions": {
     "skyline": {
       "defaultDisplayBlock": true,
@@ -103,10 +115,13 @@
     "popup-user-auth": "./components/popup-user-auth/popup-user-auth",
     "popup-privacy": "./components/popup-privacy/popup-privacy"
   },
-  "requiredPrivateInfos": ["getFuzzyLocation", "chooseAddress"],
+  "requiredPrivateInfos": [
+    "getFuzzyLocation",
+    "chooseAddress"
+  ],
   "permission": {
     "scope.userFuzzyLocation": {
       "desc": "你的位置信息将用于小程序推荐"
     }
   }
-}
+}

+ 9 - 9
miniprogram/module/chats/components/message-consult/message-consult.scss

@@ -13,7 +13,7 @@
   display: flex;
   justify-content: center;
   align-items: flex-start; // 改为 flex-start,避免影响内部元素
-  min-height: 72rpx;
+  // min-height: 72rpx;
   font-size: 28rpx;
   color: #333;
   
@@ -29,7 +29,7 @@
     
     // 加粗和斜体样式 - 现在使用 span 标签
     // span 标签默认就是行内元素,不需要额外设置
-    :deep(span) {
+    span {
       display: inline !important;
       white-space: normal !important;
       line-height: inherit !important;
@@ -41,7 +41,7 @@
     }
     
     // 代码块样式
-    :deep(pre) {
+    pre {
       background-color: #f5f5f5;
       padding: 16rpx;
       border-radius: 8rpx;
@@ -49,7 +49,7 @@
       margin: 16rpx 0;
     }
     
-    :deep(code) {
+    code {
       background-color: #f5f5f5;
       padding: 4rpx 8rpx;
       border-radius: 4rpx;
@@ -57,28 +57,28 @@
       font-size: 24rpx;
     }
     
-    :deep(pre code) {
+    pre code {
       background-color: transparent;
       padding: 0;
     }
     
     // 列表样式
-    :deep(ul) {
+    ul {
       margin: 16rpx 0;
       padding-left: 40rpx;
     }
     
-    :deep(li) {
+    li {
       margin: 8rpx 0;
       list-style-type: disc;
       // 确保列表项内的加粗文字不会换行
-      :deep(span) {
+      span {
         display: inline !important;
       }
     }
     
     // 换行处理
-    :deep(br) {
+    br {
       line-height: 1.5;
     }
   }

+ 35 - 5
miniprogram/module/chats/components/message-consult/message-consult.ts

@@ -287,9 +287,11 @@ Component({
           return;
         }
         
-        // 键盘弹起时,只有当输入框聚焦时才更新位置
-        // 如果输入框未聚焦,说明键盘可能是其他原因弹起的,忽略
-        if (this.data.inputFocus) {
+        // 键盘弹起时的处理:
+        // 1. 如果输入框已聚焦,直接更新位置
+        // 2. 如果输入框未聚焦但 keepFocus 为 true,说明正在等待聚焦(第一次打开的情况),也应该更新位置
+        // 这样可以解决鸿蒙系统第一次打开时键盘先弹起但输入框未聚焦的问题
+        if (this.data.inputFocus || this.data.keepFocus) {
           // 直接更新位置,每次键盘高度变化时都更新
           this._updateInputPosition(height);
         }
@@ -300,6 +302,15 @@ Component({
 
       // 渲染完成后再触发一次聚焦,确保键盘弹起
       this._ensureFocus();
+      
+      // 鸿蒙系统兼容:延迟检查键盘高度,确保第一次打开时能正确更新位置
+      // 在 _ensureFocus 延迟聚焦之后,再延迟一点时间检查键盘高度
+      setTimeout(() => {
+        // 如果此时键盘高度已记录但位置未更新,强制更新一次
+        if (this.data._keyboardHeight > 0 && this.data.keepFocus) {
+          this._updateInputPosition(this.data._keyboardHeight);
+        }
+      }, 300);
 
       // 如果咨询未结束,启动轮询最新消息
       if (!consultEnded) {
@@ -372,7 +383,16 @@ Component({
       this.setData({ inputFocus: false });
       wx.nextTick?.(() => {
         setTimeout(() => {
-          if (this.data.keepFocus) this.setData({ inputFocus: true });
+          if (this.data.keepFocus) {
+            this.setData({ inputFocus: true });
+            // 鸿蒙系统兼容:在聚焦后延迟检查键盘高度并更新位置
+            // 这样可以确保即使键盘在聚焦前弹起,也能在聚焦后正确更新位置
+            setTimeout(() => {
+              if (this.data._keyboardHeight > 0 && this.data.inputFocus) {
+                this._updateInputPosition(this.data._keyboardHeight);
+              }
+            }, 150);
+          }
         }, 120);
       });
     },
@@ -516,9 +536,19 @@ Component({
       });
 
       // 如果从 focus 事件获取到有效的键盘高度,立即更新位置
-      // 如果键盘高度为0,说明键盘还没完全弹起,等待 kbHandler 来更新
       if (keyboardHeight > 0) {
         this._updateInputPosition(keyboardHeight);
+      } else {
+        // 如果键盘高度为0,但之前已经记录了键盘高度(可能是鸿蒙系统的问题)
+        // 尝试使用已记录的键盘高度来更新位置
+        if (this.data._keyboardHeight > 0) {
+          // 延迟一点时间,等待键盘完全弹起后再更新
+          setTimeout(() => {
+            if (this.data.inputFocus && this.data._keyboardHeight > 0) {
+              this._updateInputPosition(this.data._keyboardHeight);
+            }
+          }, 100);
+        }
       }
     },
     onInputBlur() {

+ 6 - 1
miniprogram/module/chats/components/questionnaire/questionnaire.wxml

@@ -5,9 +5,12 @@
   module.exports.show = function (message, type) {
     return message && message.type === type
   }
+   module.exports.returnBottomId = function (index) {
+    return "bottom-" + index;
+  }
 </wxs>
 <!--module/chats/components/questionnaire/questionnaire.wxml-->
-<block wx:for="{{messages}}" wx:key="id">
+<block wx:for="{{messages}}" wx:index="{{index}}" wx:key="id">
   <message-again wx:if="{{_.show(item,'again')}}" bind:nextType="nextType" workId="{{workId}}" bind:boxBottom="boxBottom" bind:scroll="scroll"/>
   <message-count wx:elif="{{_.show(item,'count')}}" payload="{{item.payload}}" id="{{item.id}}" active="{{_.active(lastId,item.id)}}" bind:next="handle" /> 
   <message-analysis wx:elif="{{_.show(item,'analysis')}}" active="{{_.active(lastId,item.id)}}" id="{{item.id}}"
@@ -20,4 +23,6 @@
   <message-text wx:elif="{{_.show(item,'text')}}" active="{{_.active(lastId,item.id)}}" id="{{item.id}}" payload="{{item.payload}}" bind:next="handle" />
   <message-report wx:elif="{{_.show(item,'report')}}" active="{{_.active(lastId,item.id)}}" id="{{item.id}}" payload="{{item.payload}}" bind:next="handle" />
   <message-system wx:elif="{{_.show(item,'system')}}" active="{{_.active(lastId,item.id)}}" id="{{item.id}}" payload="{{item.payload}}" />
+  <view id="{{_.returnBottomId(index)}}" style="height: 10rpx;"></view>
+  
 </block>

+ 2 - 1
miniprogram/module/chats/pages/index/index.wxml

@@ -6,6 +6,7 @@
     return message && message.component === component;
   }
 </wxs>
+
 <!--module/chats/pages/index/index.wxml-->
 <view class="chats-container">
   <t-navbar title="对话管家" />
@@ -25,7 +26,7 @@
       <view class="title">对话管家 已进入聊天</view>
     </view>
     
-    <block wx:for="{{messages}}" wx:key="id">
+    <block wx:for="{{messages}}" wx:index="{{index}}" wx:key="id">
       <chat-guide wx:if="{{(_.show(item, 'guide') && isShowGuide)}}" id="{{item.id}}" active="{{_.active(lastId, item.id)}}" bind:next="handle" bind:to="scrollIntoView" bind:nextType="nextType" bind:getCount="getCount" analysisCount="{{analysisCount}}" />
       <chat-questionnaire wx:if="{{_.show(item, 'questionnaire') && messageType}}" id="{{item.id}}" active="{{_.active(lastId, item.id)}}" bind:next="handle" 
       bind:to="scrollIntoView" bind:nextType="nextType" messageType="{{messageType}}" workId="{{id}}" bind:boxBottom="boxBottom" />

+ 7 - 0
miniprogram/module/chats/pages/index/utils.wxs

@@ -0,0 +1,7 @@
+var returnBottomId = function (index) {
+  return "bottom-" + index;
+}
+
+module.exports = {
+  returnBottomId: returnBottomId
+}

+ 2 - 8
miniprogram/pages/home/home.ts

@@ -640,12 +640,10 @@ Page({
     wx.navigateTo({ url: `/module/article/pages/science-list/science-list` });
   },
   async toReportPage() {
-    console.log("toReportPage==跳转到报告页面");
     // const { patient } = await getPatients(/*this.data.patientId*/);
     if (!this.data.patient) await toCertificationPage();
     else {
       const id = this.data.healthId;
-      console.log("id==报告id", id);
       if (id)
         wx.navigateTo({ url: `/module/health/pages/report/report?id=${id}` });
       else wx.showToast({ title: "暂无分析报告", icon: "none" });
@@ -717,7 +715,7 @@ Page({
   async checkConsultationStatus() {
     //获取正在咨询中的咨询id
     const res = await Post("/consultManage/getConsultIng");
-    const isConsulting = !!res.data.id;
+    const isConsulting = !!res.data?.id;
     const hasNewMessage = res.data?.patientUnreadCount > 0;
     // 是否有新消息
     this.setData({ hasNewMessage });
@@ -757,7 +755,7 @@ Page({
         url: `/module/article/pages/punch-card/punch-card?id=${id}`,
       });
     } else {
-      //  todo 打卡
+      // 打卡
       const cardId = e.currentTarget.dataset.id;
       await addPatientOnlineRecordClockIn(cardId);
       wx.showToast({
@@ -799,7 +797,6 @@ Page({
               src: item.photo,
             });
           }
-
           // 添加itemImgFirst
           if (item?.itemImgFirst) {
             item.carouselMediaList.push({
@@ -816,12 +813,10 @@ Page({
           }
         }
       });
-
       // 更新 careList
       this.setData({
         careList: res,
       });
-
       // 更新 displayList 并恢复展开状态
       const { allExpanded } = this.data;
       let newDisplayList: any[] =
@@ -853,7 +848,6 @@ Page({
    * 轮播组件进入/退出全屏时,隐藏/显示底部 tabbar,防止遮挡视频进度条
    */
   onCarouselFullscreenChange(e: { detail?: { fullScreen?: boolean } }) {
-    console.log(e, "全屏模式");
     const fullScreen = !!e.detail?.fullScreen;
     this.setData({
       tabbarHidden: fullScreen,