涨停分析修改
This commit is contained in:
@@ -94,14 +94,14 @@
|
|||||||
</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" :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',
|
||||||
color: 'white',
|
color: 'white',
|
||||||
fontSize: '24rpx',
|
fontSize: '24rpx',
|
||||||
fontWeight: '500'
|
fontWeight: '500'
|
||||||
}">
|
}" >
|
||||||
<view class="single-line-ellipsis">{{item.title}}</view>
|
<view class="single-line-ellipsis">{{item.title}}</view>
|
||||||
<view class="count-text">{{item.count}}只</view>
|
<view class="count-text">{{item.count}}只</view>
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
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 === 0" style="width: 100%; height: 500rpx;">
|
<view v-show="activeType === 0" style="width: 100%; height: 500rpx;">
|
||||||
@@ -442,13 +442,17 @@
|
|||||||
this.activeIndex = e.index
|
this.activeIndex = e.index
|
||||||
this.contentTop = this.navH + 20 / 750 * inject('windowWidth')
|
this.contentTop = this.navH + 20 / 750 * inject('windowWidth')
|
||||||
|
|
||||||
|
//this.selectedFullDate = this.getPreviousDayDate();
|
||||||
|
//console.log("selectedFullDate", this.selectedFullDate)
|
||||||
|
//this.fetchData()
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onReady() {
|
onReady() {
|
||||||
this.fetchData()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 页面就绪后,若默认选中的是板块分布,初始化饼图
|
// 页面就绪后,若默认选中的是板块分布,初始化饼图
|
||||||
//if (this.activeType === 0) {
|
//if (this.activeType === 0) {
|
||||||
//this.initPieChart(); // 初始化关系图
|
//this.initPieChart(); // 初始化关系图
|
||||||
@@ -473,18 +477,29 @@
|
|||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
//this.$refs.graphChartRef && this.initGraphChart(); // 增加存在性判断
|
//this.$refs.graphChartRef && this.initGraphChart(); // 增加存在性判断
|
||||||
this.$refs.chartRef && this.initPieChart(); // 增加存在性判断
|
this.$refs.chartRef && this.initPieChart(); // 增加存在性判断
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
//this.$refs.chartRef && this.initPieChart(); // 增加存在性判断
|
//this.$refs.chartRef && this.initPieChart(); // 增加存在性判断
|
||||||
this.initWordCloud();
|
this.initWordCloud();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
this.initWordCloud();
|
this.initWordCloud();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getPreviousDayDate(dateStr) {
|
|
||||||
|
|
||||||
|
getPreviousDayDate() {
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
// 步骤2:将系统时间格式化为 YYYY-MM-DD 格式(适配后续校验逻辑)
|
||||||
|
const currentYear = now.getFullYear();
|
||||||
|
const currentMonth = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const currentDay = String(now.getDate()).padStart(2, '0');
|
||||||
|
const dateStr = `${currentYear}-${currentMonth}-${currentDay}`; // 示例:2026-02-04
|
||||||
|
|
||||||
|
|
||||||
// 校验输入日期格式是否正确
|
// 校验输入日期格式是否正确
|
||||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateStr)) {
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateStr)) {
|
||||||
console.error('日期格式错误,请传入 YYYY-MM-DD 格式的日期');
|
console.error('日期格式错误,请传入 YYYY-MM-DD 格式的日期');
|
||||||
@@ -496,7 +511,7 @@
|
|||||||
const date = new Date(year, month - 1, day);
|
const date = new Date(year, month - 1, day);
|
||||||
|
|
||||||
// 将日期减一天
|
// 将日期减一天
|
||||||
date.setDate(date.getDate() - 2);
|
date.setDate(date.getDate() - 1);
|
||||||
|
|
||||||
// 格式化前一天的日期为 YYYYMMDD 格式(补零处理)
|
// 格式化前一天的日期为 YYYYMMDD 格式(补零处理)
|
||||||
const prevYear = date.getFullYear();
|
const prevYear = date.getFullYear();
|
||||||
@@ -515,7 +530,8 @@
|
|||||||
|
|
||||||
|
|
||||||
// 调用上面的函数,获取前一天的格式化日期(YYYYMMDD)
|
// 调用上面的函数,获取前一天的格式化日期(YYYYMMDD)
|
||||||
const formattedDate = this.getPreviousDayDate(this.selectedFullDate);
|
// const formattedDate = this.getPreviousDayDate(this.selectedFullDate);
|
||||||
|
const formattedDate = this.selectedFullDate;
|
||||||
const baseURL = getBaseURL1();
|
const baseURL = getBaseURL1();
|
||||||
const requestUrl = `${baseURL}/data/zt/daily/${formattedDate}.json?t=${timestamp}`;
|
const requestUrl = `${baseURL}/data/zt/daily/${formattedDate}.json?t=${timestamp}`;
|
||||||
|
|
||||||
@@ -664,7 +680,7 @@
|
|||||||
});
|
});
|
||||||
// 赋值到父页面的变量中
|
// 赋值到父页面的变量中
|
||||||
this.selectedYearMonth = data.yearMonth;
|
this.selectedYearMonth = data.yearMonth;
|
||||||
this.selectedFullDate = data.fullDate;
|
this.selectedFullDate = data.fullDate ? data.fullDate.replace(/-/g, '') : '';
|
||||||
this.selectedItem = data.item;
|
this.selectedItem = data.item;
|
||||||
|
|
||||||
// 2. 格式化日期:年-月-日 → 月日(如 2026-01-14 → 1月14日)
|
// 2. 格式化日期:年-月-日 → 月日(如 2026-01-14 → 1月14日)
|
||||||
@@ -686,27 +702,49 @@
|
|||||||
ztCount - prevZtCount;
|
ztCount - prevZtCount;
|
||||||
this.tabTypes[1].change = changeValue;
|
this.tabTypes[1].change = changeValue;
|
||||||
// =======================================
|
// =======================================
|
||||||
|
// ===== 新增:判断选中日期是否为系统当天,若是则日期减一天 =====
|
||||||
|
if (this.selectedFullDate) {
|
||||||
|
// 获取系统当前日期并格式化为 YYYYMMDD
|
||||||
|
const today = new Date();
|
||||||
|
const todayYear = today.getFullYear();
|
||||||
|
const todayMonth = String(today.getMonth() + 1).padStart(2, '0');
|
||||||
|
const todayDay = String(today.getDate()).padStart(2, '0');
|
||||||
|
const todayFormatted = `${todayYear}${todayMonth}${todayDay}`;
|
||||||
|
|
||||||
|
// 判断选中日期是否等于系统当天
|
||||||
|
if (this.selectedFullDate === todayFormatted) {
|
||||||
|
// 创建选中日期的Date对象
|
||||||
|
const selectedDate = new Date(
|
||||||
|
parseInt(this.selectedFullDate.substring(0, 4)), // 年
|
||||||
|
parseInt(this.selectedFullDate.substring(4, 6)) - 1, // 月(月份从0开始)
|
||||||
|
parseInt(this.selectedFullDate.substring(6, 8)) // 日
|
||||||
|
);
|
||||||
|
|
||||||
|
// 将日期减一天
|
||||||
|
selectedDate.setDate(selectedDate.getDate() - 1);
|
||||||
|
|
||||||
|
// 格式化前一天的日期为 YYYYMMDD 格式(补零处理)
|
||||||
|
const prevYear = selectedDate.getFullYear();
|
||||||
|
const prevMonth = String(selectedDate.getMonth() + 1).padStart(2, '0');
|
||||||
|
const prevDay = String(selectedDate.getDate()).padStart(2, '0');
|
||||||
|
const prevDateFormatted = `${prevYear}${prevMonth}${prevDay}`;
|
||||||
|
|
||||||
|
// 更新选中的日期为前一天
|
||||||
|
this.selectedFullDate = prevDateFormatted;
|
||||||
|
|
||||||
|
console.log(`选中日期为当天(${todayFormatted}),已自动调整为前一天:`, prevDateFormatted);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
// this.analyseHighStocks()
|
|
||||||
},
|
},
|
||||||
analyseHighStocks() {
|
|
||||||
|
|
||||||
const formatDate = this.getPreviousDayDate(this.selectedFullDate);
|
|
||||||
let param = {
|
|
||||||
date: formatDate
|
|
||||||
}
|
|
||||||
analyseHighStocks(param).then(res => {
|
|
||||||
|
|
||||||
}).catch(error => {
|
|
||||||
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bkydAction(index) {
|
bkydAction(index) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pagesStock/stockCenterDetails/bkydmx?index=${index}`
|
url: `/pagesStock/stockCenterDetails/bkydmx?index=${index}&data=${this.selectedFullDate}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,9 @@
|
|||||||
import {
|
import {
|
||||||
inject
|
inject
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
import {
|
||||||
|
getBaseURL1
|
||||||
|
} from '@/request/http.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -75,85 +78,110 @@
|
|||||||
navH: inject('navHeight'),
|
navH: inject('navHeight'),
|
||||||
contentTop: '',
|
contentTop: '',
|
||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
bkList: [{
|
bkList: [],
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
}, {
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '存储芯片',
|
|
||||||
count: 8
|
|
||||||
}
|
|
||||||
],
|
|
||||||
bkFilters: [
|
bkFilters: [
|
||||||
'按涨幅',
|
'按涨幅',
|
||||||
'按连板数',
|
'按连板数',
|
||||||
'只看龙头'
|
'只看龙头'
|
||||||
],
|
],
|
||||||
filterIndex: 0
|
filterIndex: 0,
|
||||||
|
selectedFullDate: '', // 年-月-日
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
this.activeIndex = e.index
|
this.activeIndex = e.index
|
||||||
|
this.selectedFullDate=e.data
|
||||||
this.contentTop = this.navH + 20 / 750 * inject('windowWidth')
|
this.contentTop = this.navH + 20 / 750 * inject('windowWidth')
|
||||||
|
|
||||||
|
this.fetchData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
getPreviousDayDate(dateStr) {
|
||||||
|
// 校验输入日期格式是否正确
|
||||||
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateStr)) {
|
||||||
|
console.error('日期格式错误,请传入 YYYY-MM-DD 格式的日期');
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建日期对象(注意:月份是 0 开始的,所以需要处理)
|
||||||
|
const [year, month, day] = dateStr.split('-').map(Number);
|
||||||
|
const date = new Date(year, month - 1, day);
|
||||||
|
|
||||||
|
// 将日期减一天
|
||||||
|
date.setDate(date.getDate() - 2);
|
||||||
|
|
||||||
|
// 格式化前一天的日期为 YYYYMMDD 格式(补零处理)
|
||||||
|
const prevYear = date.getFullYear();
|
||||||
|
const prevMonth = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const prevDay = String(date.getDate()).padStart(2, '0');
|
||||||
|
|
||||||
|
return `${prevYear}${prevMonth}${prevDay}`;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求接口数据(优化:动态日期+自动时间戳)
|
||||||
|
*/
|
||||||
|
async fetchData() {
|
||||||
|
try {
|
||||||
|
// 1. 自动生成当前时间戳(替代固定值)
|
||||||
|
const timestamp = new Date().getTime();
|
||||||
|
|
||||||
|
|
||||||
|
// 调用上面的函数,获取前一天的格式化日期(YYYYMMDD)
|
||||||
|
const formattedDate = this.getPreviousDayDate(this.selectedFullDate);
|
||||||
|
const baseURL = getBaseURL1();
|
||||||
|
const requestUrl = `${baseURL}/data/zt/daily/${formattedDate}.json?t=${timestamp}`;
|
||||||
|
|
||||||
|
console.log('请求URL:', requestUrl); // 打印URL便于调试
|
||||||
|
|
||||||
|
const res = await uni.request({
|
||||||
|
url: requestUrl,
|
||||||
|
method: 'GET'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.statusCode === 200 && res.data) {
|
||||||
|
this.originData = res.data;
|
||||||
|
|
||||||
|
|
||||||
|
const chartData = this.originData.chart_data || {};
|
||||||
|
const labels = chartData.labels || [];
|
||||||
|
const counts = chartData.counts || [];
|
||||||
|
|
||||||
|
// 1. 找到counts中的最大值(用于计算热度颜色)
|
||||||
|
const maxCount = counts.length > 0 ? Math.max(...counts) : 0;
|
||||||
|
|
||||||
|
// 2. 遍历组装bkList(包含标题、数量、背景色、占比),先保证labels和counts长度一致
|
||||||
|
let bkList = [];
|
||||||
|
const maxLen = Math.min(labels.length, counts.length); // 取两者较短的长度,避免越界
|
||||||
|
for (let i = 0; i < maxLen; i++) {
|
||||||
|
const title = labels[i];
|
||||||
|
const count = counts[i] || 0;
|
||||||
|
|
||||||
|
bkList.push({
|
||||||
|
title, // 板块名称
|
||||||
|
count, // 数量
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.bkList = bkList;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '数据请求失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('请求异常:', error);
|
||||||
|
uni.showToast({
|
||||||
|
title: '网络异常',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user