|
|
@ -10,14 +10,14 @@ |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<!-- 大盘指数 --> |
|
|
<!-- 大盘指数 --> |
|
|
<view class="section"> |
|
|
|
|
|
|
|
|
<view class="section" v-if="activeTabIndex === 0"> |
|
|
<view class="section_header"> |
|
|
<view class="section_header"> |
|
|
<text class="section_title">大盘指数</text> |
|
|
<text class="section_title">大盘指数</text> |
|
|
<text class="section_action" @click="viewMore('indices')">查看更多 ></text> |
|
|
<text class="section_action" @click="viewMore('indices')">查看更多 ></text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="indices_grid"> |
|
|
<view class="indices_grid"> |
|
|
<view v-for="(index, i) in countryInfo.mainIndices" :key="i" class="index_item"> |
|
|
|
|
|
<IndexCard :market="countryInfo.market" :indexName="index.name" :currentPrice="index.price" :changeAmount="index.change" :changePercent="index.changePercent" :isRising="index.isRising" /> |
|
|
|
|
|
|
|
|
<view v-for="(index, i) in countryInfo" :key="i" class="index_item"> |
|
|
|
|
|
<IndexCard :market="index.market" :stockName="index.name" :currentPrice="index.price" :changeAmount="index.change" :changePercent="index.changePercent" :isRising="index.isRising" /> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
@ -39,13 +39,13 @@ |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<!-- 板块 --> |
|
|
<!-- 板块 --> |
|
|
<view class="section"> |
|
|
|
|
|
|
|
|
<view class="section" v-if="activeTabIndex === 1"> |
|
|
<view class="section_header"> |
|
|
<view class="section_header"> |
|
|
<text class="section_title">板块</text> |
|
|
<text class="section_title">板块</text> |
|
|
<text class="section_action" @click="viewMore('sectors')">查看更多 ></text> |
|
|
<text class="section_action" @click="viewMore('sectors')">查看更多 ></text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="sectors_grid"> |
|
|
<view class="sectors_grid"> |
|
|
<view v-for="(sec, i) in sectors" :key="i" class="sector_item"> |
|
|
|
|
|
|
|
|
<view v-for="(sec, i) in countryInfo" :key="i" class="sector_item"> |
|
|
<view class="sector_header"> |
|
|
<view class="sector_header"> |
|
|
<text class="sector_name">{{ sec.name }}</text> |
|
|
<text class="sector_name">{{ sec.name }}</text> |
|
|
<text :class="['sector_change', sec.isRising ? 'rising' : 'falling']"> |
|
|
<text :class="['sector_change', sec.isRising ? 'rising' : 'falling']"> |
|
|
@ -58,7 +58,7 @@ |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<!-- 股票 --> |
|
|
<!-- 股票 --> |
|
|
<view class="section"> |
|
|
|
|
|
|
|
|
<view class="section" v-if="activeTabIndex === 2"> |
|
|
<view class="section_header"> |
|
|
<view class="section_header"> |
|
|
<text class="section_title">股票</text> |
|
|
<text class="section_title">股票</text> |
|
|
<text class="section_action" @click="viewMore('stocks')">查看更多 ></text> |
|
|
<text class="section_action" @click="viewMore('stocks')">查看更多 ></text> |
|
|
@ -69,7 +69,7 @@ |
|
|
<text class="cell price">最新</text> |
|
|
<text class="cell price">最新</text> |
|
|
<text class="cell change">涨幅</text> |
|
|
<text class="cell change">涨幅</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="table_row" v-for="(stk, i) in stocks" :key="i"> |
|
|
|
|
|
|
|
|
<view class="table_row" v-for="(stk, i) in countryInfo" :key="i"> |
|
|
<view class="cell name"> |
|
|
<view class="cell name"> |
|
|
<text class="stk_name">{{ stk.name }}</text> |
|
|
<text class="stk_name">{{ stk.name }}</text> |
|
|
<text class="stk_code">{{ stk.code }}</text> |
|
|
<text class="stk_code">{{ stk.code }}</text> |
|
|
@ -92,14 +92,30 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script setup> |
|
|
<script setup> |
|
|
import { ref, computed, onMounted } from "vue"; |
|
|
|
|
|
|
|
|
import { ref, computed, onMounted, watch } from "vue"; |
|
|
import IndexCard from "../../components/IndexCard.vue"; |
|
|
import IndexCard from "../../components/IndexCard.vue"; |
|
|
|
|
|
import { queryStockDataAPI } from "@/api/marketSituation/marketSituation"; |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
|
switchTab(0); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// 子Tab与操作 |
|
|
// 子Tab与操作 |
|
|
// const marketTabs = ["全部", "美股", "纽交所", "纳斯达克"]; |
|
|
// const marketTabs = ["全部", "美股", "纽交所", "纳斯达克"]; |
|
|
const activeTabIndex = ref(0); |
|
|
const activeTabIndex = ref(0); |
|
|
const switchTab = (i) => { |
|
|
const switchTab = (i) => { |
|
|
activeTabIndex.value = i; |
|
|
activeTabIndex.value = i; |
|
|
|
|
|
queryStockDataAPI({ |
|
|
|
|
|
parentId: props.countryId, |
|
|
|
|
|
tradeId: activeTabIndex.value+1, |
|
|
|
|
|
}).then((res) => { |
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
countryInfo.value = res.data.dataPage.records; |
|
|
|
|
|
console.log(res.data) |
|
|
|
|
|
console.log(res.data.dataPage.records) |
|
|
|
|
|
console.log(countryInfo.value); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 今日情绪温度示例数据 |
|
|
// 今日情绪温度示例数据 |
|
|
@ -125,80 +141,31 @@ const props = defineProps({ |
|
|
marketTabs: { |
|
|
marketTabs: { |
|
|
type: Array, |
|
|
type: Array, |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 国家/地区信息映射 |
|
|
|
|
|
const countryInfoMap = { |
|
|
|
|
|
2: { |
|
|
|
|
|
// 新加坡 |
|
|
|
|
|
name: "新加坡", |
|
|
|
|
|
flag: "🇸🇬", |
|
|
|
|
|
isMarketOpen: true, |
|
|
|
|
|
mainIndices: [ |
|
|
|
|
|
{ name: "海峡时报指数", price: "3,234.56", change: "+12.34", changePercent: "+0.38%", isRising: true }, |
|
|
|
|
|
{ name: "FTSE ST Mid Cap", price: "1,234.56", change: "-5.67", changePercent: "-0.46%", isRising: false }, |
|
|
|
|
|
], |
|
|
|
|
|
hotStocks: [ |
|
|
|
|
|
{ name: "星展银行", code: "D05.SI", price: "35.20", change: "+0.15", isRising: true }, |
|
|
|
|
|
{ name: "华侨银行", code: "O39.SI", price: "13.45", change: "-0.05", isRising: false }, |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
tabData: { |
|
|
|
|
|
type: Object, |
|
|
|
|
|
default: null |
|
|
}, |
|
|
}, |
|
|
3: { |
|
|
|
|
|
// 马来西亚 |
|
|
|
|
|
name: "马来西亚", |
|
|
|
|
|
flag: "🇲🇾", |
|
|
|
|
|
isMarketOpen: false, |
|
|
|
|
|
mainIndices: [{ name: "富时大马KLCI指数", price: "1,567.89", change: "+8.90", changePercent: "+0.57%", isRising: true }], |
|
|
|
|
|
hotStocks: [ |
|
|
|
|
|
{ name: "马来亚银行", code: "1155.KL", price: "9.85", change: "+0.10", isRising: true }, |
|
|
|
|
|
{ name: "大众银行", code: "1295.KL", price: "4.32", change: "-0.02", isRising: false }, |
|
|
|
|
|
], |
|
|
|
|
|
}, |
|
|
|
|
|
4: { |
|
|
|
|
|
// 印度尼西亚 |
|
|
|
|
|
name: "印度尼西亚", |
|
|
|
|
|
flag: "🇮🇩", |
|
|
|
|
|
isMarketOpen: true, |
|
|
|
|
|
mainIndices: [{ name: "雅加达综合指数", price: "7,234.56", change: "+45.67", changePercent: "+0.63%", isRising: true }], |
|
|
|
|
|
hotStocks: [], |
|
|
|
|
|
}, |
|
|
|
|
|
5: { |
|
|
|
|
|
// 美国 |
|
|
|
|
|
name: "美国", |
|
|
|
|
|
flag: "🇺🇸", |
|
|
|
|
|
isMarketOpen: false, |
|
|
|
|
|
mainIndices: [ |
|
|
|
|
|
{ name: "道琼斯", price: "45,757.90", change: "-125.22", changePercent: "-0.27%", isRising: false }, |
|
|
|
|
|
{ name: "纳斯达克", price: "22,333.96", change: "+125.22", changePercent: "+0.47%", isRising: true }, |
|
|
|
|
|
{ name: "标普500", price: "6,606.08", change: "+125.22", changePercent: "+0.27%", isRising: true }, |
|
|
|
|
|
], |
|
|
|
|
|
hotStocks: [ |
|
|
|
|
|
{ name: "苹果", code: "AAPL", price: "195.89", change: "+2.34", isRising: true }, |
|
|
|
|
|
{ name: "微软", code: "MSFT", price: "378.85", change: "-1.23", isRising: false }, |
|
|
|
|
|
], |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// 计算当前国家信息 |
|
|
// 计算当前国家信息 |
|
|
const countryInfo = computed(() => { |
|
|
|
|
|
return ( |
|
|
|
|
|
countryInfoMap[props.countryId] || { |
|
|
|
|
|
name: "未知地区", |
|
|
|
|
|
flag: "🌍", |
|
|
|
|
|
isMarketOpen: false, |
|
|
|
|
|
mainIndices: [], |
|
|
|
|
|
hotStocks: [], |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const countryInfo = ref('') |
|
|
|
|
|
|
|
|
// 计算当前国家的板块与股票 |
|
|
|
|
|
const sectors = computed(() => { |
|
|
|
|
|
return countryInfoMap[props.countryId]?.sectors || []; |
|
|
|
|
|
}); |
|
|
|
|
|
const stocks = computed(() => { |
|
|
|
|
|
return countryInfoMap[props.countryId]?.stocks || []; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// 处理从父组件接收的数据 |
|
|
|
|
|
const handleTabData = (tabData) => { |
|
|
|
|
|
if (tabData && tabData.type === 'country' && tabData.data) { |
|
|
|
|
|
if (tabData.data.dataPage && tabData.data.dataPage.records) { |
|
|
|
|
|
countryInfo.value = tabData.data.dataPage.records; |
|
|
|
|
|
console.log('countryMarket接收到数据:', countryInfo.value); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 监听tabData变化 |
|
|
|
|
|
watch(() => props.tabData, (newTabData) => { |
|
|
|
|
|
if (newTabData) { |
|
|
|
|
|
handleTabData(newTabData); |
|
|
|
|
|
} |
|
|
|
|
|
}, { immediate: true }); |
|
|
|
|
|
|
|
|
// 查看更多占位 |
|
|
// 查看更多占位 |
|
|
const viewMore = (type) => { |
|
|
const viewMore = (type) => { |
|
|
@ -257,11 +224,8 @@ const viewMore = (type) => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.indices_grid { |
|
|
.indices_grid { |
|
|
padding: 20rpx; |
|
|
|
|
|
display: grid; |
|
|
display: grid; |
|
|
grid-template-columns: repeat(3, 1fr); |
|
|
grid-template-columns: repeat(3, 1fr); |
|
|
gap: 20rpx; |
|
|
|
|
|
background-color: #f6f6f6; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* 情绪温度 */ |
|
|
/* 情绪温度 */ |
|
|
|