diff --git a/pages/deepMate/deepMate.vue b/pages/deepMate/deepMate.vue
index 297e790..1c9fcdc 100644
--- a/pages/deepMate/deepMate.vue
+++ b/pages/deepMate/deepMate.vue
@@ -3,18 +3,29 @@
-->
-
-
+
-->
+
+
+
+
+
+ 暂无历史记录
+
+
+ {{ section.title }}
+
+
+ 🇺🇸
+
+
+ {{ item.stockName }}
+ ({{ item.stockCode }})
+
+ {{ item.createdTime }}
+
+
+
+
@@ -206,7 +320,12 @@ import { ref, computed, onMounted, onUnmounted, watch, nextTick } from "vue";
import footerBar from "../../components/footerBar";
import marked from "marked"; // 引入 marked 库
import { onPageScroll } from "@dcloudio/uni-app";
-import { postStock, postIntent } from "../../api/deepMate/deepMate";
+import {
+ postStock,
+ postIntent,
+ postHistory,
+ postHistoryDetail,
+} from "../../api/deepMate/deepMate";
// 设置 marked 选项
marked.setOptions({
renderer: new marked.Renderer(),
@@ -237,6 +356,7 @@ const messages = ref([]);
const showHistoryDrawer = ref(false);
const drawerOffsetY = ref(0);
const searchHistory = ref([]);
+const historyList = ref([]);
const hotTopics = ref([
{
id: 1,
@@ -289,7 +409,7 @@ onMounted(() => {
// 缓存今天日期(YYYY-MM-DD)
const todayStr = new Date().toISOString().slice(0, 10);
- uni.setStorageSync('today_date', todayStr);
+ uni.setStorageSync("today_date", todayStr);
});
// 初始化 UUID
@@ -336,12 +456,26 @@ const goBlank = () => {
// 历史抽屉控制
const openHistoryDrawer = () => {
+ const res = postHistory({
+ model: 5,
+ });
+
+ if (res.code === 200) {
+ historyList.value = res.data;
+ }
+
+ console.log("historyList.value", historyList.value);
+
const hideDistance = uni.upx2px(900);
drawerOffsetY.value = hideDistance;
showHistoryDrawer.value = true;
- setTimeout(() => { drawerOffsetY.value = 0; }, 10);
+ setTimeout(() => {
+ drawerOffsetY.value = 0;
+ }, 10);
+};
+const closeHistoryDrawer = () => {
+ showHistoryDrawer.value = false;
};
-const closeHistoryDrawer = () => { showHistoryDrawer.value = false; };
const onDrawerBackClick = () => {
const hideDistance = uni.upx2px(900);
drawerOffsetY.value = hideDistance;
@@ -363,65 +497,65 @@ const formatTime = (t) => {
return `${y}-${m}-${day} ${hh}:${mm}`;
};
-// 历史分组(今天/昨天/近一周/按月)
-const groupedHistory = computed(() => {
- const sections = [];
-
- // 从缓存获取今天日期,如果没有则使用当前日期
- const cachedTodayStr = uni.getStorageSync('today_date');
- const now = cachedTodayStr ? new Date(cachedTodayStr + 'T00:00:00') : new Date();
-
- const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
- const isSameDay = (a, b) => startOfDay(a).getTime() === startOfDay(b).getTime();
- const isYesterday = (d) => {
- const y = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
- return isSameDay(d, y);
- };
- const isToday = (d) => isSameDay(d, now);
- const withinLast7Days = (d) => {
- const seven = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7);
- return d >= seven && !isToday(d) && !isYesterday(d);
- };
- const monthLabel = (d) => `${d.getMonth() + 1}月`;
-
- const today = [];
- const yesterday = [];
- const last7 = [];
- const byMonth = new Map();
-
- searchHistory.value.forEach((item) => {
- const dt = new Date(item.time);
- if (isToday(dt)) {
- today.push(item);
- } else if (isYesterday(dt)) {
- yesterday.push(item);
- } else if (withinLast7Days(dt)) {
- last7.push(item);
- } else {
- const year = dt.getFullYear();
- const month = dt.getMonth() + 1;
- const key = `${year}-${month}`;
- if (!byMonth.has(key)) byMonth.set(key, { title: `${month}月`, year, month, items: [] });
- byMonth.get(key).items.push(item);
- }
- });
-
- if (today.length) sections.push({ title: '今天', items: today });
- if (yesterday.length) sections.push({ title: '昨天', items: yesterday });
- if (last7.length) sections.push({ title: '近一周', items: last7 });
-
- const monthSections = Array.from(byMonth.values()).sort((a, b) => {
- if (a.year !== b.year) return b.year - a.year;
- return b.month - a.month; // 月份倒序,如 10月 在 9月 之前
- });
- sections.push(...monthSections);
-
- return sections;
-});
+// // 历史分组(今天/昨天/近一周/按月)
+// const groupedHistory = computed(() => {
+// const sections = [];
+
+// // 从缓存获取今天日期,如果没有则使用当前日期
+// const cachedTodayStr = uni.getStorageSync('today_date');
+// const now = cachedTodayStr ? new Date(cachedTodayStr + 'T00:00:00') : new Date();
+
+// const startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
+// const isSameDay = (a, b) => startOfDay(a).getTime() === startOfDay(b).getTime();
+// const isYesterday = (d) => {
+// const y = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
+// return isSameDay(d, y);
+// };
+// const isToday = (d) => isSameDay(d, now);
+// const withinLast7Days = (d) => {
+// const seven = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7);
+// return d >= seven && !isToday(d) && !isYesterday(d);
+// };
+// const monthLabel = (d) => `${d.getMonth() + 1}月`;
+
+// const today = [];
+// const yesterday = [];
+// const last7 = [];
+// const byMonth = new Map();
+
+// searchHistory.value.forEach((item) => {
+// const dt = new Date(item.time);
+// if (isToday(dt)) {
+// today.push(item);
+// } else if (isYesterday(dt)) {
+// yesterday.push(item);
+// } else if (withinLast7Days(dt)) {
+// last7.push(item);
+// } else {
+// const year = dt.getFullYear();
+// const month = dt.getMonth() + 1;
+// const key = `${year}-${month}`;
+// if (!byMonth.has(key)) byMonth.set(key, { title: `${month}月`, year, month, items: [] });
+// byMonth.get(key).items.push(item);
+// }
+// });
+
+// if (today.length) sections.push({ title: '今天', items: today });
+// if (yesterday.length) sections.push({ title: '昨天', items: yesterday });
+// if (last7.length) sections.push({ title: '近一周', items: last7 });
+
+// const monthSections = Array.from(byMonth.values()).sort((a, b) => {
+// if (a.year !== b.year) return b.year - a.year;
+// return b.month - a.month; // 月份倒序,如 10月 在 9月 之前
+// });
+// sections.push(...monthSections);
+
+// return sections;
+// });
const clearAllHistory = () => {
searchHistory.value = [];
- uni.setStorageSync('search_history', []);
+ uni.setStorageSync("search_history", []);
};
// 发送消息
@@ -465,15 +599,15 @@ const simulateBotResponse = async (userMessage) => {
messages.value.push(botMsg);
- await new Promise((resolve) => setTimeout(resolve, 2000));
isSending.value = true;
// 首先进行意图识别
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);
@@ -488,13 +622,12 @@ const simulateBotResponse = async (userMessage) => {
const parentId = res.data.parentId;
const stockId = res.data.stockId;
- await new Promise((resolve) => setTimeout(resolve, 2000));
// 获取股票信息
const StockInfo = await postStock({
recordId,
parentId,
stockId,
- token: memberStore.userInfo?.token || '',
+ token: memberStore.userInfo?.token || "",
language: "cn",
});
console.log("StockInfo", StockInfo);
@@ -543,8 +676,8 @@ const simulateBotResponse = async (userMessage) => {
const delay = slowPunct.test(ch)
? 220
: midPunct.test(ch)
- ? 120
- : baseDelay;
+ ? 120
+ : baseDelay;
setTimeout(typeWriter, delay);
} else {
const current = messages.value[botIndex];
@@ -691,6 +824,27 @@ const onBackTopClick = () => {
if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
scrollToTop();
};
+
+// 历史记录详情
+async function itemClick(item) {
+ const res = await postHistoryDetail({
+ recordId: item.id,
+ parentId: item.parentId,
+ model: 5,
+ });
+
+ if (res.code == 200) {
+ const message = res.data.wokeFlowData.One.markdown;
+ messages.value = [];
+ const botMsg = {
+ content: message,
+ isUser: false,
+ isTyping: false,
+ isThinking: false,
+ };
+ messages.value.push(botMsg);
+ }
+}