From 8f267cc82bbea9118ae2748b20d5f9781c619a29 Mon Sep 17 00:00:00 2001
From: Ethereal <3432649580@qq.com>
Date: Tue, 28 Oct 2025 14:46:10 +0800
Subject: [PATCH] =?UTF-8?q?deepmate=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/deepMate/deepMate.js | 2 +-
pages/deepMate/deepMate.vue | 72 +++++++++++++++++++++++++++++++++++-------
pages/home/deepExploration.vue | 3 ++
utils/http.js | 2 +-
4 files changed, 66 insertions(+), 13 deletions(-)
diff --git a/api/deepMate/deepMate.js b/api/deepMate/deepMate.js
index 7eabd99..9416772 100644
--- a/api/deepMate/deepMate.js
+++ b/api/deepMate/deepMate.js
@@ -34,7 +34,7 @@ export const postIntent = (data) => {
export const postStock = (data) => {
return http({
method: 'POST',
- url: '/api/coze/decodingSecond',
+ url: '/api/deepMate/dmSecond',
data
})
}
diff --git a/pages/deepMate/deepMate.vue b/pages/deepMate/deepMate.vue
index 5eb8d58..8f119cf 100644
--- a/pages/deepMate/deepMate.vue
+++ b/pages/deepMate/deepMate.vue
@@ -287,7 +287,7 @@
:key="sIdx"
class="history-section"
>
- {{ section.title }}
+ {{ section.stockName }}
{
};
// 历史抽屉控制
-const openHistoryDrawer = () => {
- const res = postHistory({
+ const openHistoryDrawer = async() => {
+ const res = await postHistory({
model: 5,
});
@@ -604,18 +604,67 @@ const simulateBotResponse = async (userMessage) => {
// 首先进行意图识别
const res = await postIntent({
content: userMessage,
- language: 'cn',
- marketList: 'hk,cn,usa,my,sg,vi,in,gb',
- token: "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
+ language: "cn",
+ marketList: "hk,cn,usa,my,sg,vi,in,gb",
+ token:
+ "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
});
console.log("res" + res);
// 意图识别不通过
if (res.code !== 200) {
+ console.log("未通过意图识别");
+
+ // 更新机器人的消息内容
+ const errorMessage = res.message || "请求失败,请稍后重试";
+ let responseText = `我已经收到您的消息: "${userMessage}"。错误信息: "${errorMessage}"`;
+
+ // 开始打字机效果显示错误信息
+ let index = 0;
+ const botIndex = messages.value.length - 1;
+
+ const typeWriter = () => {
+ if (index < responseText.length) {
+ const ch = responseText.charAt(index);
+ const current = messages.value[botIndex];
+ // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
+ messages.value.splice(botIndex, 1, {
+ ...current,
+ content: current.content + ch,
+ isTyping: true,
+ });
+ index++;
+ scrollToBottom();
+
+ // 字符间延迟,模拟打字效果
+ const baseDelay = 5; // 普通字符基础延迟(毫秒)
+ const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
+ const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
+ const delay = slowPunct.test(ch)
+ ? 220
+ : midPunct.test(ch)
+ ? 120
+ : baseDelay;
+ setTimeout(typeWriter, delay);
+ } else {
+ // 打字完成,更新状态
+ const current = messages.value[botIndex];
+ messages.value.splice(botIndex, 1, { ...current, isTyping: false });
+ isSending.value = false;
+ nextTick(() => {
+ scrollToBottom();
+ });
+ }
+ };
+
+ // 启动打字机效果
+ setTimeout(typeWriter, 300);
return;
}
+ console.log("通过意图识别");
+
// 获取意图识别结果
const recordId = res.data.recordId;
const parentId = res.data.parentId;
@@ -623,10 +672,11 @@ const simulateBotResponse = async (userMessage) => {
// 获取股票信息
const StockInfo = await postStock({
- recordId: "42",
- parentId: "0",
- stockId:"42",
- token: memberStore.userInfo?.token || '',
+ recordId: recordId,
+ parentId: parentId,
+ stockId: stockId,
+ token:
+ "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
language: "cn",
});
console.log("StockInfo", StockInfo);
@@ -635,7 +685,7 @@ const simulateBotResponse = async (userMessage) => {
// return ;
// }
- const markdown = StockInfo.markdown;
+ const markdown = StockInfo.data.markdown;
console.log("StockInfo", StockInfo);
// 添加请求延迟
diff --git a/pages/home/deepExploration.vue b/pages/home/deepExploration.vue
index c1c8335..4d580f0 100644
--- a/pages/home/deepExploration.vue
+++ b/pages/home/deepExploration.vue
@@ -20,6 +20,9 @@ function showLoginPrompt() {
userStore.clearUserInfo();
}
+console.log(userStore.userInfo);
+
+
function toDeepMate() {
uni.navigateTo({
url: "/pages/deepMate/deepMate",
diff --git a/utils/http.js b/utils/http.js
index 5e96a94..6e0072a 100644
--- a/utils/http.js
+++ b/utils/http.js
@@ -39,7 +39,7 @@ const httpInterceptor = {
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
const memberStore = useUserStore()
// const token = memberStore.userInfo?.token || options.data?.token
- const token = '790750702588f1ea79f24dc56ccd5d8a'
+ const token = 'dccec0b65a94f498b8183a17589ab16e'
if (token) {
options.header.token = token
}