feat: 新增首页IP交互

This commit is contained in:
duanshuwen
2025-11-05 20:34:02 +08:00
parent fad25e951c
commit 19c21d2510
5 changed files with 87 additions and 16 deletions

View File

@@ -2,7 +2,10 @@
<view class="flex flex-col h-screen" @touchend="handleTouchEnd">
<!-- 顶部自定义导航栏 -->
<view class="header" :style="{ paddingTop: statusBarHeight + 'px' }">
<ChatTopNavBar :mainPageDataModel="mainPageDataModel" />
<ChatTopNavBar
ref="topNavBarRef"
:mainPageDataModel="mainPageDataModel"
/>
</view>
<!-- 消息列表可滚动区域 -->
@@ -120,7 +123,7 @@
</template>
<script setup>
import { onMounted, nextTick, onUnmounted, ref, defineEmits } from "vue";
import { onMounted, nextTick, onUnmounted, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import {
SCROLL_TO_BOTTOM,
@@ -153,7 +156,7 @@ import {
recentConversation,
} from "@/request/api/ConversationApi";
import WebSocketManager from "@/utils/WebSocketManager";
import { IdUtils } from "@/utils";
import { ThrottleUtils, IdUtils } from "@/utils";
import { checkToken } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store";
@@ -162,6 +165,8 @@ const appStore = useAppStore();
const statusBarHeight = ref(20);
/// 输入框组件引用
const inputAreaRef = ref(null);
const topNavBarRef = ref();
const welcomeRef = ref();
const holdKeyboardTimer = ref(null);
/// focus时点击页面的时候不收起键盘
@@ -174,9 +179,6 @@ const isKeyboardShow = ref(false);
///(控制滚动位置)
const scrollTop = ref(99999);
// 用户滚动状态控制
const isUserScrolling = ref(false);
/// 会话列表
const chatMsgList = ref([]);
/// 输入口的输入消息
@@ -234,9 +236,10 @@ const handleKeyboardHide = () => {
};
// 处理用户滚动事件
const handleScroll = (e) => {
// 标记用户正在滚动
};
const welcomeHeight = ref(0);
const handleScroll = ThrottleUtils.createThrottle(({ detail }) => {
topNavBarRef.value.show = parseInt(detail.scrollTop) > welcomeHeight.value;
}, 50);
// 处理滚动到底部事件
const handleScrollToLower = () => {};
@@ -381,6 +384,7 @@ const loadConversationMsgList = async () => {
};
// 获取首页数据
const getMainPageData = async () => {
/// 从个渠道获取如二维,没有的时候就返回首页的数据
const sceneId = appStore.sceneId || "";
@@ -390,6 +394,11 @@ const getMainPageData = async () => {
initData();
mainPageDataModel.value = res.data;
agentId.value = res.data.agentId;
// 数据更新后再次测量欢迎区高度
welcomeRef.value.measureWelcomeHeight((data) => {
console.log("🚀 ~ getMainPageData ~ data:", data);
welcomeHeight.value = data.height;
});
}
appStore.setSceneId(""); // 清空sceneId,分身二次进入展示默认的
};