涨停分析选中修改
This commit is contained in:
@@ -25,12 +25,12 @@
|
||||
</view>
|
||||
<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"
|
||||
@click="clickSelectDate(item)">
|
||||
@click="clickSelectDate(item, index)">
|
||||
<block v-if="item.date==selectDateStr">
|
||||
<view :class="[
|
||||
'date',
|
||||
'select',
|
||||
getZtCountBgClass(getCalendarItemByDate(item.date)?.zt_count)
|
||||
getZtCountBgClass(getCalendarItemByDate(item.date)?.zt_count),selectedDateKey === item.date ? 'selected-border' : ''
|
||||
]">
|
||||
{{item.day}}
|
||||
<view v-if="index % 7 == 0 || index % 7 == 6" style="color: #999999; font-size: 18rpx;">休市
|
||||
@@ -57,7 +57,7 @@
|
||||
<block v-else>
|
||||
<view :class="[
|
||||
'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')}">
|
||||
@@ -105,6 +105,8 @@
|
||||
selectYear: '',
|
||||
Month: '',
|
||||
calendarApiData: [], // 新增:存储接口返回的日历数据
|
||||
|
||||
selectedDateKey: '', // 新增:选中日期的唯一标识(格式:YYYY-MM-DD)
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -120,6 +122,8 @@
|
||||
//结束日期默认为当前日期
|
||||
// this.endDateStr = this.selectDateStr = currentYear + '-' + (currentMonth > 9 ? currentMonth : ('0' +
|
||||
// currentMonth)) + '-' + (currentDay > 9 ? currentDay : ('0' + currentDay))
|
||||
|
||||
|
||||
this.endDateStr = this.selectDateStr =
|
||||
`${currentYear}-${currentMonth > 9 ? currentMonth : '0' + currentMonth}-${currentDay > 9 ? currentDay : '0' + currentDay}`
|
||||
this.getYesterdayDateData()
|
||||
@@ -152,7 +156,8 @@ this.emitDateChange(
|
||||
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 localItem = currentMonthList.find(item => item.date === targetDate) || null;
|
||||
const apiData = this.getCalendarItemByDate(targetDate) || {};
|
||||
@@ -184,30 +189,10 @@ this.emitDateChange(
|
||||
zaban_rate: apiData.zaban_rate || '0%' // 示例:炸板率
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 触发日期变更事件(传递包含接口数据的item)
|
||||
*/
|
||||
// emitDateChange(year, month, day, item) {
|
||||
// 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参数,设置默认值兜底
|
||||
|
||||
emitDateChange(year, month, day, item, prevItem = {
|
||||
zt_count: 0
|
||||
}) { // 新增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', {
|
||||
@@ -304,6 +289,7 @@ this.emitDateChange(
|
||||
* 获取日历接口数据
|
||||
*/
|
||||
async getCalendarCombinedData() {
|
||||
|
||||
try {
|
||||
let param = {
|
||||
year: this.selectYear,
|
||||
@@ -317,13 +303,13 @@ this.emitDateChange(
|
||||
if (this.selectDateStr) {
|
||||
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.getPrevDayItem(year, month, day) // 新增上一天数据
|
||||
)
|
||||
// this.emitDateChange(
|
||||
// year,
|
||||
// month,
|
||||
// day,
|
||||
// this.getTodayItem(year, month, day),
|
||||
// this.getPrevDayItem(year, month, day) // 新增上一天数据
|
||||
// )
|
||||
}
|
||||
} else {
|
||||
this.calendarApiData = [];
|
||||
@@ -440,6 +426,8 @@ this.emitDateChange(
|
||||
*/
|
||||
clickPreMonth() {
|
||||
if (this.selectMonthIndex > 0) {
|
||||
// 新增:切换月份时清空选中标识
|
||||
this.selectedDateKey = '';
|
||||
this.selectMonthIndex--
|
||||
let monthList = this.monthDateList[this.selectMonthIndex]
|
||||
let year = ''
|
||||
@@ -464,16 +452,19 @@ this.emitDateChange(
|
||||
|
||||
this.selectYear = year
|
||||
this.Month = month;
|
||||
|
||||
this.selectDateStr =this.startDateStr ;
|
||||
this.getCalendarCombinedData()
|
||||
console.log('点击上个月');
|
||||
}
|
||||
|
||||
},
|
||||
/**
|
||||
* 点击下个月
|
||||
*/
|
||||
clickNextMonth() {
|
||||
if (this.selectMonthIndex < this.monthDateList.length - 1) {
|
||||
// 新增:切换月份时清空选中标识
|
||||
this.selectedDateKey = '';
|
||||
this.selectMonthIndex++
|
||||
let monthList = this.monthDateList[this.selectMonthIndex]
|
||||
let year = ''
|
||||
@@ -498,9 +489,18 @@ this.emitDateChange(
|
||||
console.log('点击下个月');
|
||||
this.selectYear = year
|
||||
this.Month = month;
|
||||
this.selectDateStr =this.startDateStr ; // 统一格式 YYYY-MM
|
||||
this.getCalendarCombinedData()
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 通用补零函数:确保数字为两位数,不足则前面补0
|
||||
* @param {number|string} num - 需要补零的数字
|
||||
* @returns {string} 补零后的字符串
|
||||
*/
|
||||
padZero(num) {
|
||||
return String(num).padStart(2, '0');
|
||||
},
|
||||
monthChange(e) {
|
||||
let currentDate = new Date();
|
||||
//当前年份
|
||||
@@ -528,6 +528,8 @@ this.emitDateChange(
|
||||
clickSelectDate(item, index) { // 新增index参数
|
||||
if (!item.isCurrentMonth) return
|
||||
if (this.selectDateStr != item.date) {
|
||||
|
||||
this.selectedDateKey = item.date;
|
||||
this.selectDateStr = item.date
|
||||
// 1. 获取该日期的接口数据
|
||||
const apiData = this.getCalendarItemByDate(item.date) || {};
|
||||
@@ -547,7 +549,8 @@ this.emitDateChange(
|
||||
const prevYear = prevDate.getFullYear();
|
||||
const prevMonth = prevDate.getMonth() + 1;
|
||||
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 获取上一天的接口数据
|
||||
const prevApiData = this.getCalendarItemByDate(prevDateStr) || {};
|
||||
@@ -577,31 +580,13 @@ this.emitDateChange(
|
||||
// 3. 解析日期,触发事件传递【当前数据+上一天数据】
|
||||
const [year, month, day] = item.date.split('-').map(Number);
|
||||
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>
|
||||
@@ -673,6 +658,10 @@ this.emitDateChange(
|
||||
.chg.down {
|
||||
color: #38A169;
|
||||
}
|
||||
&.selected-border {
|
||||
border: 1px solid #FFCC00; // 黄色边框(可根据需求调整色值)
|
||||
box-sizing: border-box; // 保证边框不超出容器
|
||||
}
|
||||
}
|
||||
|
||||
// zt_count ≥80 背景色
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "JiaZhiQianYan",
|
||||
"appid" : "__UNI__1836EC9",
|
||||
"appid" : "__UNI__C546BDE",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
|
||||
@@ -460,7 +460,7 @@
|
||||
// 获取当前日期,并减去一天
|
||||
const now = new Date()
|
||||
// 核心修改:将日期减去 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 month = (now.getMonth() + 1).toString().padStart(2, '0')
|
||||
|
||||
Reference in New Issue
Block a user