个股搜索添加

This commit is contained in:
renzhijun
2026-02-04 11:07:11 +08:00
parent 0a2dab4936
commit 16ba613a82
3 changed files with 269 additions and 37 deletions

View File

@@ -5,9 +5,15 @@
<view class="searchC fixed flex" :style="'top:'+navH+'px;'"> <view class="searchC fixed flex" :style="'top:'+navH+'px;'">
<image class="icon" src="/static/icon/home/conceptCenter/search.png" mode="widthFix"></image> <image class="icon" src="/static/icon/home/conceptCenter/search.png" mode="widthFix"></image>
<input class="flex1" type="text" v-model="keywords" placeholder="输入股票代码或名称" <input class="flex1" type="text" v-model="keywords" placeholder="输入股票代码或名称"
placeholder-style="color:#eeeeee" confirm-type="search" @confirm="clickSearch()" /> placeholder-style="color:#eeeeee" confirm-type="search" @input="clickSearch()" />
</view>
<view v-if="searchShow" class="searchResultList fixed" :style="'top:'+searchResultTop+'px;'" @click="clickSearchResultBg()">
<view class="list">
<view class="item" v-for="(item,index) in searchResultList" :key="index" @click.stop="clickSearchResultListItem(item)">
{{item.stock_code}} {{item.stock_name}}
</view>
</view>
</view> </view>
<scroll-view scroll-y class="stockDetailsC fixed" :style="'top:'+contentTop+'px;'"> <scroll-view scroll-y class="stockDetailsC fixed" :style="'top:'+contentTop+'px;'">
<view> <view>
<view style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16rpx; margin: 0 20rpx;"> <view style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16rpx; margin: 0 20rpx;">
@@ -60,7 +66,9 @@
inject inject
} from 'vue' } from 'vue'
import { import {
marketHeatmap marketHeatmap,
searchStockInfo,
stockBasicInfo
} from '@/request/api' } from '@/request/api'
export default { export default {
@@ -71,6 +79,12 @@
allStockData: [], allStockData: [],
filteredData: [], filteredData: [],
currentDate: '', // 最终要赋值的日期 currentDate: '', // 最终要赋值的日期
searchResultTop:'', //搜索结果
contentTop: '',
keywords: '', //搜索关键字
searchShow:false, //是否展示搜索结果
searchResultList:[], //搜索结果
selectSearchStockInfo:null, //选中的搜索股票信息
topLists: [{ topLists: [{
title: '超大盘股', title: '超大盘股',
value: '>1000亿', value: '>1000亿',
@@ -89,10 +103,66 @@
}, },
onLoad(e) { onLoad(e) {
this.currentDate = e.currentDate this.currentDate = e.currentDate
this.searchResultTop = this.navH + (20 + 70) / 750 * inject('windowWidth')
this.contentTop = this.navH + (20 + 70 + 25) / 750 * inject('windowWidth') this.contentTop = this.navH + (20 + 70 + 25) / 750 * inject('windowWidth')
this.marketHeatmap() this.marketHeatmap()
}, },
methods: { methods: {
/**
* 点击搜索
*/
clickSearch() {
if(this.keywords) {
this.getSearchStockInfoListData()
}else
this.selectSearchStockInfo = null
},
/**
* 点击搜索结果背景
*/
clickSearchResultBg()
{
this.searchShow = false
},
/**
* 点击搜索结果列表项
*/
clickSearchResultListItem(item) {
this.selectSearchStockInfo = item
this.searchShow = false
this.getStockBasicInfoData()
//this.getQuoteDetailsData()
},
/**
* 根据输入内容获取搜索列表项
*/
getSearchStockInfoListData() {
let param = {q:this.keywords,limit:10}
searchStockInfo(param).then(res=>{
this.searchResultList = res.data
this.searchShow = this.searchResultList.length>0
}).catch(error=>{
})
},
/**
* 获取股票基本信息
*/
getStockBasicInfoData() {
let code = this.stockCode
if (this.selectSearchStockInfo) {
code = this.selectSearchStockInfo.stock_code
}
// stockBasicInfo(code).then(res=>{
// this.stockBasicInfo = res.data
// this.navTitle = res.data.SECNAME+'('+res.data.SECCODE+')'
// }).catch(error=>{
// })
uni.navigateTo({
url: '/pagesStock/stockCenterDetails/stockCenterDetails?code=' + code
})
},
handleTypeClick(index) { handleTypeClick(index) {
this.list2Index = index; this.list2Index = index;
// 先请求数据,再筛选 // 先请求数据,再筛选
@@ -130,8 +200,10 @@
}, },
marketHeatmap() { marketHeatmap() {
let param = { let param = {
limit: 500, limit: 500
date: this.currentDate }
if (this.currentDate && this.currentDate !== 'undefined' && this.currentDate.trim() !== '') {
param.date = this.currentDate;
} }
marketHeatmap(param).then(res => { marketHeatmap(param).then(res => {
// 存储原始数据 // 存储原始数据
@@ -218,4 +290,25 @@
background-color: white; background-color: white;
border-radius: 10rpx; border-radius: 10rpx;
} }
.searchResultList {
background-color: #00000080;
left: 0;
right: 0;
bottom: 0;
padding: 0 25rpx;
.list
{
background-color: white;
border-radius: 10rpx;
.item
{
padding: 0 42rpx;
line-height: 60rpx;
font-size: 22rpx;
font-weight: 500;
color: #333;
}
}
z-index: 20;
}
</style> </style>

View File

@@ -5,9 +5,15 @@
<view class="searchC fixed flex" :style="'top:'+navH+'px;'"> <view class="searchC fixed flex" :style="'top:'+navH+'px;'">
<image class="icon" src="/static/icon/home/conceptCenter/search.png" mode="widthFix"></image> <image class="icon" src="/static/icon/home/conceptCenter/search.png" mode="widthFix"></image>
<input class="flex1" type="text" v-model="keywords" placeholder="输入股票代码或名称" <input class="flex1" type="text" v-model="keywords" placeholder="输入股票代码或名称"
placeholder-style="color:#eeeeee" confirm-type="search" @confirm="clickSearch()" /> placeholder-style="color:#eeeeee" confirm-type="search" @input="clickSearch()" />
</view>
<view v-if="searchShow" class="searchResultList fixed" :style="'top:'+searchResultTop+'px;'" @click="clickSearchResultBg()">
<view class="list">
<view class="item" v-for="(item,index) in searchResultList" :key="index" @click.stop="clickSearchResultListItem(item)">
{{item.stock_code}} {{item.stock_name}}
</view>
</view>
</view> </view>
<scroll-view scroll-y class="stockDetailsC fixed" :style="'top:'+contentTop+'px;'"> <scroll-view scroll-y class="stockDetailsC fixed" :style="'top:'+contentTop+'px;'">
<view> <view>
<view style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16rpx; padding: 20rpx;"> <view style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16rpx; padding: 20rpx;">
@@ -74,12 +80,12 @@
mode="widthFix"></image> mode="widthFix"></image>
<view style="font-size: 28rpx; color: #2B2B2B; font-weight: bold; flex: 1; margin-left: 10rpx;">异动监控 <view style="font-size: 28rpx; color: #2B2B2B; font-weight: bold; flex: 1; margin-left: 10rpx;">异动监控
</view> </view>
<view @click="allAction(1)" <!-- <view @click="allAction(1)"
style="border: 1rpx solid #DCDCDC; border-radius: 5rpx; padding: 2rpx 10rpx; display: flex; align-items: center; justify-content: center; margin: 0 10rpx;"> style="border: 1rpx solid #DCDCDC; border-radius: 5rpx; padding: 2rpx 10rpx; display: flex; align-items: center; justify-content: center; margin: 0 10rpx;">
<view style="color: #888888; font-size: 22rpx; font-weight: 500;">全部</view> <view style="color: #888888; font-size: 22rpx; font-weight: 500;">全部</view>
<image style="width: 11rpx; height: 6rpx; margin-left: 40rpx;" <image style="width: 11rpx; height: 6rpx; margin-left: 40rpx;"
src="/static/icon/invest/downArrow.png" mode="widthFix"></image> src="/static/icon/invest/downArrow.png" mode="widthFix"></image>
</view> </view> -->
<view @click="allAction(2)" <view @click="allAction(2)"
style="border: 1rpx solid #DCDCDC; border-radius: 5rpx; padding: 2rpx 10rpx; display: flex; align-items: center; justify-content: center;"> style="border: 1rpx solid #DCDCDC; border-radius: 5rpx; padding: 2rpx 10rpx; display: flex; align-items: center; justify-content: center;">
<view style="color: #888888; font-size: 22rpx; font-weight: 500;">{{currentDate}}</view> <view style="color: #888888; font-size: 22rpx; font-weight: 500;">{{currentDate}}</view>
@@ -88,9 +94,9 @@
</view> </view>
</view> </view>
<view <!-- <view
style="height: 400rpx; display: flex; align-items: center; justify-content: center; background-color: red;"> style="height: 400rpx; display: flex; align-items: center; justify-content: center; background-color: red;">
折线图占位 </view> 折线图占位 </view> -->
<view style="height: 1rpx; margin: 0 20rpx; background-color: #E7E7E7;"></view> <view style="height: 1rpx; margin: 0 20rpx; background-color: #E7E7E7;"></view>
<view style="height: 88rpx; display: flex; align-items: center; margin: 0 20rpx;"> <view style="height: 88rpx; display: flex; align-items: center; margin: 0 20rpx;">
@@ -107,8 +113,9 @@
<view style="display: flex; align-items: center; margin-top: 10rpx;"> <view style="display: flex; align-items: center; margin-top: 10rpx;">
<view style="color: #2B2B2B; font-weight: bold; font-size: 26rpx; margin-right: 10rpx;"> <view style="color: #2B2B2B; font-weight: bold; font-size: 26rpx; margin-right: 10rpx;">
{{item.concept_name}} {{truncateText(item.concept_name, 5)}}
</view> </view>
<view :style="{ <view :style="{
color: alertTypeConfig[item.alert_type]?.color || '#FF7A45', color: alertTypeConfig[item.alert_type]?.color || '#FF7A45',
fontSize: '20rpx', fontSize: '20rpx',
@@ -306,8 +313,11 @@
marketHeatmap, marketHeatmap,
marketStatistics, marketStatistics,
marketHotspotOverview, marketHotspotOverview,
conceptStocks conceptStocks,
searchStockInfo,
stockBasicInfo
} from '@/request/api' } from '@/request/api'
export default { export default {
data() { data() {
return { return {
@@ -431,26 +441,116 @@
formattedAvg: 0, formattedAvg: 0,
upCount: 0, upCount: 0,
downCount: 0, downCount: 0,
limit_up_ratio: 0 limit_up_ratio: 0,
searchResultTop:'', //搜索结果
contentTop: '',
keywords: '', //搜索关键字
searchShow:false, //是否展示搜索结果
searchResultList:[], //搜索结果
selectSearchStockInfo:null, //选中的搜索股票信息
isShowTime:false
} }
}, },
onLoad(e) { onLoad(e) {
this.activeIndex = e.index this.activeIndex = e.index
this.contentTop = this.navH + (20 + 70 + 25) / 750 * inject('windowWidth') this.searchResultTop = this.navH + (20 + 70) / 750 * inject('windowWidth')
//this.conceptsDailyTop() this.contentTop = this.navH + (20 + 70 + 25) / 750 * inject('windowWidth')
const now = new Date() this.conceptsDailyTop()
const year = now.getFullYear()
const month = (now.getMonth() + 1).toString().padStart(2, '0') // 获取当前日期,并减去一天
const day = now.getDate().toString().padStart(2, '0') const now = new Date()
this.currentDate = `${year}-${month}-${day}` // 核心修改:将日期减去 1 天1 天 = 24 * 60 * 60 * 1000 毫秒)
now.setTime(now.getTime() - 24 * 60 * 60 * 1000)
const year = now.getFullYear()
const month = (now.getMonth() + 1).toString().padStart(2, '0')
const day = now.getDate().toString().padStart(2, '0')
this.currentDate = `${year}-${month}-${day}`
}, },
onShow() { onShow() {
this.isShowTime=false;
this.marketHeatmap(); this.marketHeatmap();
this.marketStatistics() this.marketStatistics()
this.marketHotspotListOverview() this.marketHotspotListOverview()
}, },
methods: { methods: {
truncateText(text, length) {
if (!text) return ''; // 处理空值,避免报错
return text.length > length
? text.substring(0, length) + '...'
: text;
},
/**
* 点击搜索
*/
clickSearch() {
if(this.keywords) {
this.getSearchStockInfoListData()
}else
this.selectSearchStockInfo = null
},
/**
* 点击搜索结果背景
*/
clickSearchResultBg()
{
this.searchShow = false
},
/**
* 点击搜索结果列表项
*/
clickSearchResultListItem(item) {
this.selectSearchStockInfo = item
this.searchShow = false
this.getStockBasicInfoData()
//this.getQuoteDetailsData()
},
/**
* 根据输入内容获取搜索列表项
*/
getSearchStockInfoListData() {
let param = {q:this.keywords,limit:10}
searchStockInfo(param).then(res=>{
this.searchResultList = res.data
this.searchShow = this.searchResultList.length>0
}).catch(error=>{
})
},
/**
* 获取股票基本信息
*/
getStockBasicInfoData() {
let code = this.stockCode
if (this.selectSearchStockInfo) {
code = this.selectSearchStockInfo.stock_code
}
// stockBasicInfo(code).then(res=>{
// this.stockBasicInfo = res.data
// this.navTitle = res.data.SECNAME+'('+res.data.SECCODE+')'
// }).catch(error=>{
// })
uni.navigateTo({
url: '/pagesStock/stockCenterDetails/stockCenterDetails?code=' + code
})
},
/**
* 获取股票当前市场价格信息
*/
getQuoteDetailsData() {
let code = this.stockCode
if (this.selectSearchStockInfo) {
code = this.selectSearchStockInfo.stock_code
}
quoteDetailsInfo(code).then(res=>{
this.quoteDetailsInfo = res.data
}).catch(error=>{
})
},
formatAlpha(value) { formatAlpha(value) {
// 1. 空值/非数字处理 // 1. 空值/非数字处理
if (value === null || value === undefined || isNaN(Number(value))) { if (value === null || value === undefined || isNaN(Number(value))) {
@@ -519,9 +619,13 @@
let param = { let param = {
limit: 500 limit: 500
} }
if (currentDate && currentDate !== 'undefined' && currentDate.trim() !== '') { if(this.isShowTime){
param.date = currentDate;
if (currentDate && currentDate !== 'undefined' && currentDate.trim() !== '') {
param.date = currentDate;
}
} }
marketHeatmap(param).then(res => { marketHeatmap(param).then(res => {
this.topLists[2].value = res.statistics.rising_count + "/" + res.statistics.falling_count; this.topLists[2].value = res.statistics.rising_count + "/" + res.statistics.falling_count;
// 存储原始数据 // 存储原始数据
@@ -694,9 +798,14 @@
}) })
}, },
moreAction() { moreAction() {
if(this.isShowTime){
uni.navigateTo({ uni.navigateTo({
url: '/pages/geGuCenter/detail?currentDate=' + this.currentDate url: '/pages/geGuCenter/detail?currentDate=' + this.currentDate
}) })}else{
uni.navigateTo({
url: '/pages/geGuCenter/detail'
})
}
}, },
allAction(index) { allAction(index) {
if (index == 1) { if (index == 1) {
@@ -734,6 +843,7 @@
const day = now.getDate().toString().padStart(2, '0') const day = now.getDate().toString().padStart(2, '0')
this.currentDate = `${year}-${month}-${day}` this.currentDate = `${year}-${month}-${day}`
} }
this.isShowTime=true;
this.marketHeatmap(this.currentDate) this.marketHeatmap(this.currentDate)
this.marketStatistics() this.marketStatistics()
@@ -846,4 +956,26 @@
border-radius: 20rpx 20rpx 0 0; border-radius: 20rpx 20rpx 0 0;
padding-bottom: env(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom);
} }
.searchResultList {
background-color: #00000080;
left: 0;
right: 0;
bottom: 0;
padding: 0 25rpx;
.list
{
background-color: white;
border-radius: 10rpx;
.item
{
padding: 0 42rpx;
line-height: 60rpx;
font-size: 22rpx;
font-weight: 500;
color: #333;
}
}
z-index: 20;
}
</style> </style>

View File

@@ -8,7 +8,7 @@
<image style="width: 40rpx; height: 40rpx;" src="/pagesStock/static/icon/ai-icon.png" mode="widthFix"> <image style="width: 40rpx; height: 40rpx;" src="/pagesStock/static/icon/ai-icon.png" mode="widthFix">
</image> </image>
<text style="font-size: 36rpx; margin-left: 10rpx; margin-right: 20rpx;">AI总结</text> <text style="font-size: 36rpx; margin-left: 10rpx; margin-right: 20rpx;">AI总结</text>
<text style="font-size: 28rpx;">市场情绪温和主线题材存储芯片</text> <text style="font-size: 28rpx;"></text>
</view> </view>
<view style="background-color: white; border-radius: 10rpx; overflow: hidden; margin: 25rpx;"> <view style="background-color: white; border-radius: 10rpx; overflow: hidden; margin: 25rpx;">
@@ -94,7 +94,7 @@
</view> </view>
</view> </view>
<view style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 7rpx; margin-top: 25rpx;"> <view style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 7rpx; margin-top: 25rpx;">
<view v-for="(item, index) in bkList" :key="index" @click="bkydAction(index)" :style="{ <view v-for="(item, index) in bkList" :key="index" :style="{
backgroundColor: item.bgColor, backgroundColor: item.bgColor,
borderRadius: '5rpx', borderRadius: '5rpx',
padding: '15rpx', padding: '15rpx',
@@ -132,17 +132,17 @@
style="width: 100%; height: 500rpx; display: flex; align-items: center; justify-content: center; color: #999;"> style="width: 100%; height: 500rpx; display: flex; align-items: center; justify-content: center; color: #999;">
板块关联图内容区域 板块关联图内容区域
</view> --> </view> -->
<view v-show="activeType === 0" style="width: 100%; height: 500rpx;"> <!-- <view v-show="activeType === 0" style="width: 100%; height: 500rpx;">
<l-echart ref="graphChartRef"></l-echart> <l-echart ref="graphChartRef"></l-echart>
</view> </view> -->
<view v-show="activeType === 1" style="width: 100%; height: 500rpx;"> <view v-show="activeType === 0" style="width: 100%; height: 500rpx;">
<l-echart ref="chartRef"></l-echart> <l-echart ref="chartRef"></l-echart>
</view> </view>
<WordCloud v-show="activeType === 2" :wordData="wordData" :width="330" :height="330" /> <WordCloud v-show="activeType === 1" :wordData="wordData" :width="330" :height="330" />
</view> </view>
<view style="color: #2B2B2B; font-weight: 500; display: flex; margin: 25rpx 20rpx;"> <!-- <view style="color: #2B2B2B; font-weight: 500; display: flex; margin: 25rpx 20rpx;">
<image style="width: 40rpx; height: 42rpx;" src="/pagesStock/static/icon/all-icon-3.png" <image style="width: 40rpx; height: 42rpx;" src="/pagesStock/static/icon/all-icon-3.png"
mode="widthFix"></image> mode="widthFix"></image>
<view style="margin-left: 10rpx;"> <view style="margin-left: 10rpx;">
@@ -186,7 +186,7 @@
<image style="width: 27rpx; height: 25rpx; margin-right: 10rpx;" <image style="width: 27rpx; height: 25rpx; margin-right: 10rpx;"
src="/pagesStock/static/icon/all-icon-5.png" mode="widthFix"></image> src="/pagesStock/static/icon/all-icon-5.png" mode="widthFix"></image>
<text>高位股风险较高追涨需谨慎</text> <text>高位股风险较高追涨需谨慎</text>
</view> </view> -->
</view> </view>
</scroll-view> </scroll-view>
@@ -355,8 +355,13 @@
level: '无热度' level: '无热度'
} // ≤20% } // ≤20%
], ],
// bkTypes: [
// '板块关联图',
// '板块分布',
// '热门概念词云'
// ],
bkTypes: [ bkTypes: [
'板块关联图',
'板块分布', '板块分布',
'热门概念词云' '热门概念词云'
], ],
@@ -446,7 +451,7 @@
this.fetchData() this.fetchData()
// 页面就绪后,若默认选中的是板块分布,初始化饼图 // 页面就绪后,若默认选中的是板块分布,初始化饼图
//if (this.activeType === 0) { //if (this.activeType === 0) {
this.initGraphChart(); // 初始化关系图 //this.initPieChart(); // 初始化关系图
//} else if (this.activeType === 1) { //} else if (this.activeType === 1) {
// 初始化饼图 // 初始化饼图
//} //}
@@ -467,10 +472,12 @@
switch (index) { switch (index) {
case 0: case 0:
this.$refs.graphChartRef && this.initGraphChart(); // 增加存在性判断 //this.$refs.graphChartRef && this.initGraphChart(); // 增加存在性判断
this.$refs.chartRef && this.initPieChart(); // 增加存在性判断
break; break;
case 1: case 1:
this.$refs.chartRef && this.initPieChart(); // 增加存在性判断 //this.$refs.chartRef && this.initPieChart(); // 增加存在性判断
this.initWordCloud();
break; break;
case 2: case 2:
this.initWordCloud(); this.initWordCloud();