From f0fbd2d2b40ac462153afb2902627962bcaa667d Mon Sep 17 00:00:00 2001 From: zhaowenkang Date: Fri, 31 Oct 2025 15:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IndexCard.vue | 15 +++++++++++++++ pages/marketSituation/countryMarket.vue | 25 ++++++++++++++++++++----- pages/marketSituation/marketCondition.vue | 15 +++++++++++++++ pages/marketSituation/marketOverview.vue | 16 ++++++++-------- pages/marketSituation/marketSituation.vue | 9 ++++----- stores/modules/marketSituation.js | 2 ++ 6 files changed, 64 insertions(+), 18 deletions(-) diff --git a/components/IndexCard.vue b/components/IndexCard.vue index 69a3de3..01cf7f5 100644 --- a/components/IndexCard.vue +++ b/components/IndexCard.vue @@ -63,6 +63,21 @@ const props = defineProps({ }, }); +const judgeSymbol = (num) => { + // 兼容 undefined/null/数字/字符串 + if (num === null || num === undefined) return ''; + const n = Number(num); + if (!isNaN(n)) { + // 数值:正数加'+',负数原样 + return (n < 0 ? '' : '+') + n; + } + // 字符串:去空格后判断前缀 + const s = String(num).trim(); + if (s.startsWith('-')) return s; + if (s.startsWith('+')) return s; + return '+' + s; +}; + const getMarketFlag = (market) => { let imagePath; diff --git a/pages/marketSituation/countryMarket.vue b/pages/marketSituation/countryMarket.vue index a31933e..7f23c1c 100644 --- a/pages/marketSituation/countryMarket.vue +++ b/pages/marketSituation/countryMarket.vue @@ -17,7 +17,7 @@ - + @@ -95,6 +95,8 @@ import { ref, computed, onMounted, watch } from "vue"; import IndexCard from "../../components/IndexCard.vue"; import { queryStockDataAPI } from "@/api/marketSituation/marketSituation"; +import { useMarketSituationStore } from "../../stores/modules/marketSituation.js"; +const marketSituationStore = useMarketSituationStore(); onMounted(() => { switchTab(0); @@ -111,6 +113,11 @@ const switchTab = (i) => { }).then((res) => { if (res.code === 200) { countryInfo.value = res.data.dataPage.records; + marketSituationStore.countryMarketCardData = countryInfo.value.map((item) => ({ + market: item.market, + stockCode: item.code, + stockName: item.name, + })); console.log(res.data) console.log(res.data.dataPage.records) console.log(countryInfo.value); @@ -149,12 +156,23 @@ const props = defineProps({ // 计算当前国家信息 const countryInfo = ref('') - +// 方法:查看指数详情 +const viewIndexDetail = (item, index) => { + console.log("查看指数详情:", item); + uni.navigateTo({ + url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}&index=${index}&from=countryMarket`, + }); +}; // 处理从父组件接收的数据 const handleTabData = (tabData) => { if (tabData && tabData.type === 'country' && tabData.data) { if (tabData.data.dataPage && tabData.data.dataPage.records) { countryInfo.value = tabData.data.dataPage.records; + marketSituationStore.countryMarketCardData = countryInfo.value.map((item) => ({ + market: item.market, + stockCode: item.code, + stockName: item.name, + })); console.log('countryMarket接收到数据:', countryInfo.value); } } @@ -169,9 +187,6 @@ watch(() => props.tabData, (newTabData) => { // 查看更多占位 const viewMore = (type) => { - // 可根据 type 跳转到相应页面或加载更多 - // 例如:indices/sectors/stocks - // uni.navigateTo({ url: `/pages/marketSituation/${type}List` }) }; diff --git a/pages/marketSituation/marketCondition.vue b/pages/marketSituation/marketCondition.vue index 3d398d9..9b3d55d 100644 --- a/pages/marketSituation/marketCondition.vue +++ b/pages/marketSituation/marketCondition.vue @@ -686,6 +686,8 @@ const toLeftPage = () => { nextStockInformation = marketSituationStore.marketDetailCardData[currentStockIndex.value]; } else if (currentStockFrom.value == "globalIndex") { nextStockInformation = marketSituationStore.gloablCardData[currentStockParentIndex.value].list[currentStockIndex.value]; + } else if (currentStockFrom.value == "countryMarket") { + nextStockInformation = marketSituationStore.countryMarketCardData[currentStockIndex.value]; } else { uni.showToast({ title: "没有更多股票了", @@ -739,6 +741,19 @@ const toRightPage = () => { nextStockInformation = marketSituationStore.gloablCardData[currentStockParentIndex.value].list[currentStockIndex.value]; updateStockInformation(nextStockInformation); } + } else if (currentStockFrom.value == "countryMarket") { + if (currentStockIndex.value == marketSituationStore.countryMarketCardData.length) { + uni.showToast({ + title: "没有更多股票了", + icon: "none", + duration: 1000, + }); + return; + } else { + currentStockIndex.value++; + nextStockInformation = marketSituationStore.countryMarketCardData[currentStockIndex.value]; + updateStockInformation(nextStockInformation); + } } else { uni.showToast({ title: "没有更多股票了", diff --git a/pages/marketSituation/marketOverview.vue b/pages/marketSituation/marketOverview.vue index 732a946..0827d43 100644 --- a/pages/marketSituation/marketOverview.vue +++ b/pages/marketSituation/marketOverview.vue @@ -719,8 +719,8 @@ watch(headerHeight, (newHeight) => { .NDX { position: absolute; - top: 30%; - left: 17%; + top: 23vh; + left: 17vw; transform: translate(-50%, -50%); font-size: 11rpx; color: #000000; @@ -731,8 +731,8 @@ watch(headerHeight, (newHeight) => { } .INDU { position: absolute; - top: 22%; - left: 35%; + top: 15vh; + left: 35vw; transform: translate(-50%, -50%); font-size: 11rpx; color: #000000; @@ -743,8 +743,8 @@ watch(headerHeight, (newHeight) => { } .HSI { position: absolute; - top: 30%; - right: 13%; + top: 23vh; + right: 4vw; transform: translate(-50%, -50%); font-size: 11rpx; color: #000000; @@ -755,8 +755,8 @@ watch(headerHeight, (newHeight) => { } .CN { position: absolute; - top: 23%; - right: 16%; + top: 16vh; + right: 8vw; transform: translate(-50%, -50%); font-size: 11rpx; color: #000000; diff --git a/pages/marketSituation/marketSituation.vue b/pages/marketSituation/marketSituation.vue index 1503954..d589b9c 100644 --- a/pages/marketSituation/marketSituation.vue +++ b/pages/marketSituation/marketSituation.vue @@ -177,11 +177,10 @@ const selected = () => { // 历史记录点击事件 const history = () => { - uni.showToast({ - title: "历史记录", - icon: "none", - }); - // 这里可以跳转到历史页面 + // 跳转到自定义股票列表页面 + uni.navigateTo({ + url: '/pages/customStockList/customStockList' + }) }; // Tab 栏点击事件 diff --git a/stores/modules/marketSituation.js b/stores/modules/marketSituation.js index 2ae69fe..f8db4c1 100644 --- a/stores/modules/marketSituation.js +++ b/stores/modules/marketSituation.js @@ -9,11 +9,13 @@ export const useMarketSituationStore = defineStore( const cardData = ref([]); const gloablCardData = ref([]); const marketDetailCardData = ref([]); + const countryMarketCardData = ref([]); // 记得 return return { cardData, gloablCardData, marketDetailCardData, + countryMarketCardData, }; }, // TODO: 持久化