涨停分析选中修改

This commit is contained in:
renzhijun
2026-02-04 15:40:55 +08:00
parent b957844c6b
commit eeca65538c
3 changed files with 504 additions and 515 deletions

View File

@@ -25,12 +25,12 @@
</view> </view>
<view class="monthDateList" style="display: grid; grid-template-columns: repeat(7, 1fr); gap: 17rpx;"> <view class="monthDateList" style="display: grid; grid-template-columns: repeat(7, 1fr); gap: 17rpx;">
<view class="item" v-for="(item,index) in monthDateList[selectMonthIndex]" :key="index" <view class="item" v-for="(item,index) in monthDateList[selectMonthIndex]" :key="index"
@click="clickSelectDate(item)"> @click="clickSelectDate(item, index)">
<block v-if="item.date==selectDateStr"> <block v-if="item.date==selectDateStr">
<view :class="[ <view :class="[
'date', 'date',
'select', 'select',
getZtCountBgClass(getCalendarItemByDate(item.date)?.zt_count) getZtCountBgClass(getCalendarItemByDate(item.date)?.zt_count),selectedDateKey === item.date ? 'selected-border' : ''
]"> ]">
{{item.day}} {{item.day}}
<view v-if="index % 7 == 0 || index % 7 == 6" style="color: #999999; font-size: 18rpx;">休市 <view v-if="index % 7 == 0 || index % 7 == 6" style="color: #999999; font-size: 18rpx;">休市
@@ -57,7 +57,7 @@
<block v-else> <block v-else>
<view :class="[ <view :class="[
'date', 'date',
getZtCountBgClass(getCalendarItemByDate(item.date)?.zt_count) getZtCountBgClass(getCalendarItemByDate(item.date)?.zt_count),selectedDateKey === item.date ? 'selected-border' : ''
]"> ]">
<view :style="{color: (index % 7 == 0 || index % 7 == 6 ? '#999999' : '#2A2A2A')}"> <view :style="{color: (index % 7 == 0 || index % 7 == 6 ? '#999999' : '#2A2A2A')}">
@@ -105,6 +105,8 @@
selectYear: '', selectYear: '',
Month: '', Month: '',
calendarApiData: [], // 新增:存储接口返回的日历数据 calendarApiData: [], // 新增:存储接口返回的日历数据
selectedDateKey: '', // 新增选中日期的唯一标识格式YYYY-MM-DD
}; };
}, },
created() { created() {
@@ -120,6 +122,8 @@
//结束日期默认为当前日期 //结束日期默认为当前日期
// this.endDateStr = this.selectDateStr = currentYear + '-' + (currentMonth > 9 ? currentMonth : ('0' + // this.endDateStr = this.selectDateStr = currentYear + '-' + (currentMonth > 9 ? currentMonth : ('0' +
// currentMonth)) + '-' + (currentDay > 9 ? currentDay : ('0' + currentDay)) // currentMonth)) + '-' + (currentDay > 9 ? currentDay : ('0' + currentDay))
this.endDateStr = this.selectDateStr = this.endDateStr = this.selectDateStr =
`${currentYear}-${currentMonth > 9 ? currentMonth : '0' + currentMonth}-${currentDay > 9 ? currentDay : '0' + currentDay}` `${currentYear}-${currentMonth > 9 ? currentMonth : '0' + currentMonth}-${currentDay > 9 ? currentDay : '0' + currentDay}`
this.getYesterdayDateData() this.getYesterdayDateData()
@@ -127,13 +131,13 @@
// 新增:初始化时触发一次事件,传递当天数据给父页面 // 新增:初始化时触发一次事件,传递当天数据给父页面
//this.emitDateChange(currentYear, currentMonth, currentDay, this.getTodayItem(currentYear, currentMonth, currentDay)) //this.emitDateChange(currentYear, currentMonth, currentDay, this.getTodayItem(currentYear, currentMonth, currentDay))
this.emitDateChange( this.emitDateChange(
currentYear, currentYear,
currentMonth, currentMonth,
currentDay, currentDay,
this.getTodayItem(currentYear, currentMonth, currentDay), this.getTodayItem(currentYear, currentMonth, currentDay),
this.getPrevDayItem(currentYear, currentMonth, currentDay) // 新增上一天数据 this.getPrevDayItem(currentYear, currentMonth, currentDay) // 新增上一天数据
) )
}, },
mounted() { mounted() {
this.getCalendarCombinedData() this.getCalendarCombinedData()
@@ -152,7 +156,8 @@ this.emitDateChange(
const prevDay = prevDate.getDate(); const prevDay = prevDate.getDate();
// 获取上一天的完整数据 // 获取上一天的完整数据
const targetDate = `${prevYear}-${prevMonth > 9 ? prevMonth : '0' + prevMonth}-${prevDay > 9 ? prevDay : '0' + prevDay}`; const targetDate =
`${prevYear}-${prevMonth > 9 ? prevMonth : '0' + prevMonth}-${prevDay > 9 ? prevDay : '0' + prevDay}`;
const currentMonthList = this.monthDateList[this.selectMonthIndex] || []; const currentMonthList = this.monthDateList[this.selectMonthIndex] || [];
const localItem = currentMonthList.find(item => item.date === targetDate) || null; const localItem = currentMonthList.find(item => item.date === targetDate) || null;
const apiData = this.getCalendarItemByDate(targetDate) || {}; const apiData = this.getCalendarItemByDate(targetDate) || {};
@@ -184,30 +189,10 @@ this.emitDateChange(
zaban_rate: apiData.zaban_rate || '0%' // 示例:炸板率 zaban_rate: apiData.zaban_rate || '0%' // 示例:炸板率
}; };
}, },
/**
* 触发日期变更事件传递包含接口数据的item emitDateChange(year, month, day, item, prevItem = {
*/ zt_count: 0
// emitDateChange(year, month, day, item) { }) { // 新增prevItem参数设置默认值兜底
// const yearMonth = `${year}-${month > 9 ? month : '0' + month}`;
// const fullDate = `${year}-${month > 9 ? month : '0' + month}-${day > 9 ? day : '0' + day}`;
// this.$emit('date-change', {
// yearMonth,
// fullDate,
// item: item || { // 兜底无item时赋值空对象+默认值
// date: fullDate,
// year,
// month,
// day,
// zt_count: 0,
// top_sector: '-',
// zaban_rate: '0%'
// },
// year,
// month,
// day
// });
// },
emitDateChange(year, month, day, item, prevItem = { zt_count: 0 }) { // 新增prevItem参数设置默认值兜底
const yearMonth = `${year}-${month > 9 ? month : '0' + month}`; const yearMonth = `${year}-${month > 9 ? month : '0' + month}`;
const fullDate = `${year}-${month > 9 ? month : '0' + month}-${day > 9 ? day : '0' + day}`; const fullDate = `${year}-${month > 9 ? month : '0' + month}-${day > 9 ? day : '0' + day}`;
this.$emit('date-change', { this.$emit('date-change', {
@@ -304,6 +289,7 @@ this.emitDateChange(
* 获取日历接口数据 * 获取日历接口数据
*/ */
async getCalendarCombinedData() { async getCalendarCombinedData() {
try { try {
let param = { let param = {
year: this.selectYear, year: this.selectYear,
@@ -317,13 +303,13 @@ this.emitDateChange(
if (this.selectDateStr) { if (this.selectDateStr) {
const [year, month, day] = this.selectDateStr.split('-').map(Number); const [year, month, day] = this.selectDateStr.split('-').map(Number);
//this.emitDateChange(year, month, day, this.getTodayItem(year, month, day)); //this.emitDateChange(year, month, day, this.getTodayItem(year, month, day));
this.emitDateChange( // this.emitDateChange(
year, // year,
month, // month,
day, // day,
this.getTodayItem(year, month, day), // this.getTodayItem(year, month, day),
this.getPrevDayItem(year, month, day) // 新增上一天数据 // this.getPrevDayItem(year, month, day) // 新增上一天数据
) // )
} }
} else { } else {
this.calendarApiData = []; this.calendarApiData = [];
@@ -440,6 +426,8 @@ this.emitDateChange(
*/ */
clickPreMonth() { clickPreMonth() {
if (this.selectMonthIndex > 0) { if (this.selectMonthIndex > 0) {
// 新增:切换月份时清空选中标识
this.selectedDateKey = '';
this.selectMonthIndex-- this.selectMonthIndex--
let monthList = this.monthDateList[this.selectMonthIndex] let monthList = this.monthDateList[this.selectMonthIndex]
let year = '' let year = ''
@@ -464,16 +452,19 @@ this.emitDateChange(
this.selectYear = year this.selectYear = year
this.Month = month; this.Month = month;
this.selectDateStr =this.startDateStr ;
this.getCalendarCombinedData() this.getCalendarCombinedData()
console.log('点击上个月'); console.log('点击上个月');
} }
}, },
/** /**
* 点击下个月 * 点击下个月
*/ */
clickNextMonth() { clickNextMonth() {
if (this.selectMonthIndex < this.monthDateList.length - 1) { if (this.selectMonthIndex < this.monthDateList.length - 1) {
// 新增:切换月份时清空选中标识
this.selectedDateKey = '';
this.selectMonthIndex++ this.selectMonthIndex++
let monthList = this.monthDateList[this.selectMonthIndex] let monthList = this.monthDateList[this.selectMonthIndex]
let year = '' let year = ''
@@ -498,9 +489,18 @@ this.emitDateChange(
console.log('点击下个月'); console.log('点击下个月');
this.selectYear = year this.selectYear = year
this.Month = month; this.Month = month;
this.selectDateStr =this.startDateStr ; // 统一格式 YYYY-MM
this.getCalendarCombinedData() this.getCalendarCombinedData()
} }
}, },
/**
* 通用补零函数确保数字为两位数不足则前面补0
* @param {number|string} num - 需要补零的数字
* @returns {string} 补零后的字符串
*/
padZero(num) {
return String(num).padStart(2, '0');
},
monthChange(e) { monthChange(e) {
let currentDate = new Date(); let currentDate = new Date();
//当前年份 //当前年份
@@ -528,6 +528,8 @@ this.emitDateChange(
clickSelectDate(item, index) { // 新增index参数 clickSelectDate(item, index) { // 新增index参数
if (!item.isCurrentMonth) return if (!item.isCurrentMonth) return
if (this.selectDateStr != item.date) { if (this.selectDateStr != item.date) {
this.selectedDateKey = item.date;
this.selectDateStr = item.date this.selectDateStr = item.date
// 1. 获取该日期的接口数据 // 1. 获取该日期的接口数据
const apiData = this.getCalendarItemByDate(item.date) || {}; const apiData = this.getCalendarItemByDate(item.date) || {};
@@ -547,7 +549,8 @@ this.emitDateChange(
const prevYear = prevDate.getFullYear(); const prevYear = prevDate.getFullYear();
const prevMonth = prevDate.getMonth() + 1; const prevMonth = prevDate.getMonth() + 1;
const prevDay = prevDate.getDate(); const prevDay = prevDate.getDate();
const prevDateStr = `${prevYear}-${prevMonth > 9 ? prevMonth : '0' + prevMonth}-${prevDay > 9 ? prevDay : '0' + prevDay}`; const prevDateStr =
`${prevYear}-${prevMonth > 9 ? prevMonth : '0' + prevMonth}-${prevDay > 9 ? prevDay : '0' + prevDay}`;
// 2.2 获取上一天的接口数据 // 2.2 获取上一天的接口数据
const prevApiData = this.getCalendarItemByDate(prevDateStr) || {}; const prevApiData = this.getCalendarItemByDate(prevDateStr) || {};
@@ -577,31 +580,13 @@ this.emitDateChange(
// 3. 解析日期,触发事件传递【当前数据+上一天数据】 // 3. 解析日期,触发事件传递【当前数据+上一天数据】
const [year, month, day] = item.date.split('-').map(Number); const [year, month, day] = item.date.split('-').map(Number);
this.emitDateChange(year, month, day, mergedItem, prevMergedItem); // 新增传递上一天数据 this.emitDateChange(year, month, day, mergedItem, prevMergedItem); // 新增传递上一天数据
console.log('点击某天(含接口数据)', { current: mergedItem, prev: prevMergedItem }); console.log('点击某天(含接口数据)', {
current: mergedItem,
prev: prevMergedItem
});
} }
} }
// clickSelectDate(item, index) {
// if (!item.isCurrentMonth) return
// if (this.selectDateStr != item.date) {
// this.selectDateStr = item.date
// const apiData = this.getCalendarItemByDate(item.date) || {};
// const mergedItem = {
// ...item,
// zt_count: apiData.zt_count || 0,
// top_sector: apiData.top_sector || '-',
// zaban_rate: apiData.zaban_rate || '0%',
// isWeekend: index % 7 === 0 || index % 7 === 6
// };
// this.chgStockData = mergedItem;
// const [year, month, day] = item.date.split('-').map(Number);
// this.emitDateChange(year, month, day, mergedItem);
// console.log('点击某天(含接口数据)', mergedItem);
// }
// }
} }
} }
</script> </script>
@@ -673,6 +658,10 @@ this.emitDateChange(
.chg.down { .chg.down {
color: #38A169; color: #38A169;
} }
&.selected-border {
border: 1px solid #FFCC00; // 黄色边框(可根据需求调整色值)
box-sizing: border-box; // 保证边框不超出容器
}
} }
// zt_count ≥80 背景色 // zt_count ≥80 背景色

View File

@@ -1,6 +1,6 @@
{ {
"name" : "JiaZhiQianYan", "name" : "JiaZhiQianYan",
"appid" : "__UNI__1836EC9", "appid" : "__UNI__C546BDE",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",

View File

@@ -460,7 +460,7 @@
// 获取当前日期,并减去一天 // 获取当前日期,并减去一天
const now = new Date() const now = new Date()
// 核心修改:将日期减去 1 天1 天 = 24 * 60 * 60 * 1000 毫秒) // 核心修改:将日期减去 1 天1 天 = 24 * 60 * 60 * 1000 毫秒)
now.setTime(now.getTime() - 24 * 60 * 60 * 1000) // now.setTime(now.getTime() - 24 * 60 * 60 * 1000)
const year = now.getFullYear() const year = now.getFullYear()
const month = (now.getMonth() + 1).toString().padStart(2, '0') const month = (now.getMonth() + 1).toString().padStart(2, '0')