个股中心列表对接,涨停分析词云和板块分布图实现
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
</view>
|
||||
|
||||
<view style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16rpx; margin: 0 20rpx;">
|
||||
<view @click="list2Index = index" v-for="(item,index) in topLists2" :key="index"
|
||||
<view @click="handleTypeClick(index)" v-for="(item,index) in topLists2" :key="index"
|
||||
style="border: 1rpx solid #D2D2D2; padding: 12rpx;"
|
||||
:style="{border: `1rpx solid ${list2Index == index ? '#F2C369' : '#D2D2D2'}`}">
|
||||
<view style="font-size: 24rpx; color: #070707; font-weight: bold; text-align: center;"
|
||||
@@ -39,20 +39,20 @@
|
||||
<!-- '股票名称', '涨跌幅', '市值', '成交额', '行业' -->
|
||||
<view
|
||||
style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 10rpx; background-color: #FAFAFC; line-height: 60rpx; margin: 0 20rpx; margin-top: 20rpx;">
|
||||
<view v-for="(item,index) in ['股票名称', '涨跌幅', '市值', '成交额', '行业']" :key="index"
|
||||
<view v-for="(item,index) in ['股票名称', '涨跌幅', '市值', '成交额', '行业']" :key="index"
|
||||
style="color: #666666; font-size: 20rpx; font-weight: 500; text-align: center;">
|
||||
{{item}}
|
||||
</view>
|
||||
</view>
|
||||
<!-- '股票名称', '涨跌幅', '市值', '成交额', '行业' 的 内容 -->
|
||||
<view v-for="(obj, j) in 10"
|
||||
<view v-for="(obj, j) in filteredData" @click="itemDetails(obj)"
|
||||
style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 10rpx; min-height: 60rpx; margin: 0 20rpx;"
|
||||
:style="{'background-color': (j % 2 == 0 ? '#fff' : '#FAFAFC')}">
|
||||
<view v-for="(item,index) in ['云南白药', '+0.04%', '996.85 亿元', '4.44 亿元', '医药生物']" :key="index"
|
||||
<view v-for="(item,index) in getTableItem(obj)" :key="index"
|
||||
style="padding: 10rpx 0; color: #666666; font-size: 20rpx; font-weight: 500; text-align: center; display: flex; justify-content: center; align-items: center; flex-direction: column;"
|
||||
:style="{color: (index == 0 ? '#222222' : index == 1 ? '#EC3440' : '#666666')}">
|
||||
<view>{{item}}</view>
|
||||
<view v-if="index == 0" style="color: #666666; font-size: 20rpx; font-weight: 500;">000768
|
||||
<view>{{item[0]}}</view>
|
||||
<view v-if="index == 0" style="color: #666666; font-size: 20rpx; font-weight: 500;">{{item[1]}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -234,6 +234,8 @@ import { conceptsDailyTop,marketHeatmap,marketStatistics,marketHotspotOverview }
|
||||
return {
|
||||
navH: inject('navHeight'),
|
||||
contentTop: '',
|
||||
allStockData:[],
|
||||
filteredData:[],
|
||||
topLists: [{
|
||||
title: '大盘涨跌幅',
|
||||
value: '+0.31%',
|
||||
@@ -310,12 +312,31 @@ import { conceptsDailyTop,marketHeatmap,marketStatistics,marketHotspotOverview }
|
||||
onLoad(e) {
|
||||
this.activeIndex = e.index
|
||||
this.contentTop = this.navH + (20 + 70 + 25) / 750 * inject('windowWidth')
|
||||
this.conceptsDailyTop()
|
||||
//this.conceptsDailyTop()
|
||||
this.marketHeatmap()
|
||||
this.marketStatistics()
|
||||
this.marketHotspotOverview()
|
||||
//this.marketStatistics()
|
||||
//this.marketHotspotOverview()
|
||||
},
|
||||
methods: {
|
||||
handleTypeClick(index) {
|
||||
this.list2Index = index;
|
||||
// 先请求数据,再筛选
|
||||
this.marketHeatmap();
|
||||
},
|
||||
getTableItem(obj) {
|
||||
// 先处理空值,避免 toFixed 调用时报错
|
||||
const marketCap = obj.market_cap ? obj.market_cap.toFixed(2) : '0.00';
|
||||
const amount = obj.amount ? obj.amount.toFixed(2) : '0.00';
|
||||
const changePercent = obj.change_percent ? obj.change_percent : 0;
|
||||
|
||||
return [
|
||||
[obj.stock_name, obj.stock_code],
|
||||
[`${changePercent}%`], // 使用模板字符串更规范
|
||||
[`${marketCap}亿元`],
|
||||
[`${amount}亿元`],
|
||||
[obj.industry || '暂无'] // 处理行业为空的情况
|
||||
];
|
||||
},
|
||||
conceptsDailyTop(){
|
||||
conceptsDailyTop().then(res=>{
|
||||
|
||||
@@ -324,12 +345,40 @@ import { conceptsDailyTop,marketHeatmap,marketStatistics,marketHotspotOverview }
|
||||
})
|
||||
},
|
||||
marketHeatmap(){
|
||||
marketHeatmap().then(res=>{
|
||||
let param = {
|
||||
limit: 500
|
||||
}
|
||||
marketHeatmap(param).then(res=>{
|
||||
// 存储原始数据
|
||||
this.allStockData = res.data || [];
|
||||
// 调用筛选方法
|
||||
this.filterStockByMarketCap();
|
||||
|
||||
}).catch(error=>{
|
||||
|
||||
})
|
||||
},
|
||||
// 根据市值区间筛选数据
|
||||
filterStockByMarketCap() {
|
||||
const { list2Index, allStockData } = this;
|
||||
let filtered = [];
|
||||
|
||||
switch (list2Index) {
|
||||
case 0: // 超大盘股(>1000亿)
|
||||
filtered = allStockData.filter(item => item.market_cap > 1000);
|
||||
break;
|
||||
case 1: // 大盘股(500-1000亿)
|
||||
filtered = allStockData.filter(item => item.market_cap >= 500 && item.market_cap <= 1000);
|
||||
break;
|
||||
case 2: // 中盘股(100-500亿)
|
||||
filtered = allStockData.filter(item => item.market_cap >= 100 && item.market_cap <= 500);
|
||||
break;
|
||||
default:
|
||||
filtered = allStockData;
|
||||
}
|
||||
|
||||
this.filteredData = filtered;
|
||||
},
|
||||
marketStatistics(){
|
||||
marketStatistics().then(res=>{
|
||||
|
||||
@@ -344,6 +393,11 @@ import { conceptsDailyTop,marketHeatmap,marketStatistics,marketHotspotOverview }
|
||||
|
||||
})
|
||||
},
|
||||
itemDetails(item){
|
||||
uni.navigateTo({
|
||||
url: '/pagesStock/stockCenterDetails/stockCenterDetails?code='+item.stock_code
|
||||
})
|
||||
},
|
||||
moreAction() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/geGuCenter/detail'
|
||||
|
||||
Reference in New Issue
Block a user