张田田 4 місяців тому
батько
коміт
c903ebcd2b

+ 14 - 6
miniprogram/module/chats/components/message-consult/message-consult.ts

@@ -305,12 +305,20 @@ Component({
       
       // 鸿蒙系统兼容:延迟检查键盘高度,确保第一次打开时能正确更新位置
       // 在 _ensureFocus 延迟聚焦之后,再延迟一点时间检查键盘高度
-      setTimeout(() => {
-        // 如果此时键盘高度已记录但位置未更新,强制更新一次
-        if (this.data._keyboardHeight > 0 && this.data.keepFocus) {
-          this._updateInputPosition(this.data._keyboardHeight);
-        }
-      }, 300);
+      const systemInfo = wx.getSystemInfoSync();
+      // 判断是否是鸿蒙系统:通过 system 字段判断,鸿蒙系统通常包含 "HarmonyOS"
+      const isHarmonyOS = systemInfo.system && systemInfo.system.toLowerCase().includes('harmony');
+      console.log("isHarmonyOS==是否是鸿蒙系统", isHarmonyOS);
+      const delayTime = isHarmonyOS ? 300 : 0;
+      
+      if (delayTime > 0) {
+        setTimeout(() => {
+          // 如果此时键盘高度已记录但位置未更新,强制更新一次
+          if (this.data._keyboardHeight > 0 && this.data.keepFocus) {
+            this._updateInputPosition(this.data._keyboardHeight);
+          }
+        }, delayTime);
+      }
 
       // 如果咨询未结束,启动轮询最新消息
       if (!consultEnded) {

+ 8 - 8
miniprogram/module/chats/pages/index/index.ts

@@ -120,14 +120,14 @@ Component({
           scroll.scrollIntoView(`#${id}`, { alignment: "end" });
         }
         // 再补一次,处理内容异步渲染晚于滚动触发的情况
-        setTimeout(() => {
-          if (id === "bottom") {
-            // 使用 scrollIntoView 滚动到 #bottom 元素,实现平滑滚动
-            scroll.scrollIntoView(`#bottom`, { alignment: "end" });
-          } else if (id) {
-            scroll.scrollIntoView(`#${id}`, { alignment: "end" });
-          }
-        }, 200);
+        // setTimeout(() => {
+        //   if (id === "bottom") {
+        //     // 使用 scrollIntoView 滚动到 #bottom 元素,实现平滑滚动
+        //     scroll.scrollIntoView(`#bottom`, { alignment: "end" });
+        //   } else if (id) {
+        //     scroll.scrollIntoView(`#${id}`, { alignment: "end" });
+        //   }
+        // }, 200);
       };
 
       getScrollcontext.call(this).timer = setTimeout(() => {

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

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