From 46cd0637520dbf724479354fc3ceb95bd1075aa3 Mon Sep 17 00:00:00 2001
From: dongqian <3475123872@qq.com>
Date: Wed, 29 Oct 2025 17:35:52 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E4=B8=8A=E9=80=89=E8=82=A1=E7=AD=96?=
=?UTF-8?q?=E7=95=A5=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/tcpConnection.js | 2 +-
pages/deepExploration/deepExploration.vue | 94 +++++++++++--------------------
utils/http.js | 4 +-
3 files changed, 36 insertions(+), 64 deletions(-)
diff --git a/api/tcpConnection.js b/api/tcpConnection.js
index c31188e..c701ca3 100644
--- a/api/tcpConnection.js
+++ b/api/tcpConnection.js
@@ -6,7 +6,7 @@
*/
// 引用TCP插件
-const TCPSocket = uni.requireNativePlugin('Aimer-TCPPlugin');
+// const TCPSocket = uni.requireNativePlugin('Aimer-TCPPlugin');
// const TCPSocket = uni.requireNativePlugin("Aimer-TCPPlugin");
// TCP连接配置
diff --git a/pages/deepExploration/deepExploration.vue b/pages/deepExploration/deepExploration.vue
index 0bab615..026d156 100644
--- a/pages/deepExploration/deepExploration.vue
+++ b/pages/deepExploration/deepExploration.vue
@@ -96,9 +96,9 @@
- {{ item.name }}
+ {{ item.tscode }}
{{ item.close }}
- {{ item.select }}
+ {{ item.preClose }}
@@ -131,9 +131,9 @@
- {{ item.name }}
+ {{ item.tscode }}
{{ item.close }}
- {{ item.select }}
+ {{ item.preClose }}
@@ -186,76 +186,48 @@ const searchStock = () => {
});
};
-//查看全部选股策略
-const viewAll = () => {
- uni.navigateTo({
- url: "/pages/deepExploration/stockSelectDetail",
- });
-};
-//选股策略数据
-const stockData = [
- {
- name: "(MKTW)MarketWise Inc",
- close: "$14.190",
- select: "$13.180",
- },
- {
- name: "(MTCH)Match Group Inc",
- close: "$32.120",
- select: "$28.120",
- },
- {
- name: "(MKTW)MarketWise Inc",
- close: "$14.190",
- select: "$13.180",
- },
-];
-onMounted(() => {
- // 状态栏高度
- iSMT.value = uni.getSystemInfoSync().statusBarHeight;
-});
-
-
//查看全部选股策略
const viewAll = () => {
uni.navigateTo({
url: '/pages/deepExploration/stockSelectDetail'
})
}
- //选股策略数据
- const stockData = [{
- name: "(MKTW)MarketWise Inc",
- close: "$14.190",
- select: "$13.180"
- },
- {
- name: "(MTCH)Match Group Inc",
- close: "$32.120",
- select: "$28.120"
- },
- {
- name: "(MKTW)MarketWise Inc",
- close: "$14.190",
- select: "$13.180"
- }
- ];
+ //选股策略数据(接口填充)
+ const stockData = ref([]);
// 加载选股策略(接口)
const loadStockSelection = async () => {
try {
- const res = await stocSelectApi({
- language: 'cn'
- })
- console.log('选股策略接口响应:', res)
- const list = Array.isArray(res?.data?.list) ? res.data.list : (Array.isArray(res?.data) ? res.data : [])
+ const res = await stocSelectApi({ language: 'cn', size: 3 })
+ // console.log('选股策略接口响应原始:', typeof res === 'object' ? JSON.stringify(res) : res)
+ const raw = res?.data
+ const listCandidates = [
+ raw?.list,
+ raw?.data?.list,
+ raw?.data?.rows,
+ raw?.rows,
+ Array.isArray(raw) ? raw : null
+ ].filter(Array.isArray)
+ let list = listCandidates.length ? listCandidates[0] : []
+
+ // 若是对象包含多个数组(如不同市场),进行扁平化
+ if ((!Array.isArray(list) || !list.length) && raw && typeof raw === 'object' && !Array.isArray(raw)) {
+ const arrays = Object.values(raw).filter(Array.isArray)
+ if (arrays.length) {
+ list = arrays.flat()
+ }
+ }
+
if (Array.isArray(list) && list.length) {
- stockData.value = list.map(item => ({
- name: item.name || item.stockName || item.code || '',
- close: item.close || item.lastClose || item.closePrice || '',
- select: item.select || item.selectPrice || item.price || ''
+ const mapped = list.map(item => ({
+ tscode: item.tsCode ?? item.tscode ?? item.code ?? '',
+ close: item.close ?? item.lastClose ?? '',
+ preClose: item.preClose ?? item.preclose ?? item.prevClose ?? ''
}))
+ stockData.value = mapped.slice(0, 3)
+ console.log('选股策略列表长度:', stockData.value.length, '首项:', stockData.value[0])
} else {
- console.warn('选股策略接口返回空列表或结构不匹配')
+ console.warn('选股策略接口返回空列表或结构不匹配', raw)
}
} catch (e) {
console.error('选股策略接口调用失败', e)
diff --git a/utils/http.js b/utils/http.js
index 8ffb08f..f22c5d5 100644
--- a/utils/http.js
+++ b/utils/http.js
@@ -42,8 +42,8 @@ const httpInterceptor = {
}
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
const memberStore = useUserStore()
- // const token = memberStore.userInfo?.token || options.data?.token
- const token = '1b3a58424c5324e40d4bf4d085e18047'
+ const token = memberStore.userInfo?.token || options.data?.token
+ // const token = 'a72cf584af42525f214670cb47443820'
if (token) {
options.header.token = token
}