Browse Source

接上选股策略接口

dongqian/feature-20251022181325-deepmate简版
dongqian 4 weeks ago
parent
commit
46cd063752
  1. 2
      api/tcpConnection.js
  2. 94
      pages/deepExploration/deepExploration.vue
  3. 4
      utils/http.js

2
api/tcpConnection.js

@ -6,7 +6,7 @@
*/ */
// 引用TCP插件 // 引用TCP插件
const TCPSocket = uni.requireNativePlugin('Aimer-TCPPlugin');
// const TCPSocket = uni.requireNativePlugin('Aimer-TCPPlugin');
// const TCPSocket = uni.requireNativePlugin("Aimer-TCPPlugin"); // const TCPSocket = uni.requireNativePlugin("Aimer-TCPPlugin");
// TCP连接配置 // TCP连接配置

94
pages/deepExploration/deepExploration.vue

@ -96,9 +96,9 @@
</view> </view>
<view class="contentItem"> <view class="contentItem">
<view class="row" v-for="(item, index) in stockData" :key="index"> <view class="row" v-for="(item, index) in stockData" :key="index">
<view class="nameItem">{{ item.name }}</view>
<view class="nameItem">{{ item.tscode }}</view>
<view class="closeItem">{{ item.close }}</view> <view class="closeItem">{{ item.close }}</view>
<view class="priceItem">{{ item.select }}</view>
<view class="priceItem">{{ item.preClose }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -131,9 +131,9 @@
</view> </view>
<view class="contentItem"> <view class="contentItem">
<view class="row" v-for="(item, index) in stockData" :key="index"> <view class="row" v-for="(item, index) in stockData" :key="index">
<view class="nameItem">{{ item.name }}</view>
<view class="nameItem">{{ item.tscode }}</view>
<view class="closeItem">{{ item.close }}</view> <view class="closeItem">{{ item.close }}</view>
<view class="priceItem">{{ item.select }}</view>
<view class="priceItem">{{ item.preClose }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -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 = () => { const viewAll = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/deepExploration/stockSelectDetail' 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 () => { const loadStockSelection = async () => {
try { 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) { 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 { } else {
console.warn('选股策略接口返回空列表或结构不匹配')
console.warn('选股策略接口返回空列表或结构不匹配', raw)
} }
} catch (e) { } catch (e) {
console.error('选股策略接口调用失败', e) console.error('选股策略接口调用失败', e)

4
utils/http.js

@ -42,8 +42,8 @@ const httpInterceptor = {
} }
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致 //4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
const memberStore = useUserStore() 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) { if (token) {
options.header.token = token options.header.token = token
} }

Loading…
Cancel
Save