update pay function
This commit is contained in:
@@ -167,55 +167,76 @@ const ConceptTimelineModal = ({
|
||||
}
|
||||
};
|
||||
|
||||
// 转换时间轴数据为日历事件格式
|
||||
// 转换时间轴数据为日历事件格式(一天拆分为多个独立事件)
|
||||
const calendarEvents = useMemo(() => {
|
||||
return timelineData.map(item => {
|
||||
const events = [];
|
||||
|
||||
timelineData.forEach(item => {
|
||||
const priceInfo = getPriceInfo(item.price);
|
||||
const hasEvents = item.events && item.events.length > 0;
|
||||
const newsCount = (item.events || []).filter(e => e.type === 'news').length;
|
||||
const reportCount = (item.events || []).filter(e => e.type === 'report').length;
|
||||
|
||||
// 根据涨跌幅和事件确定颜色
|
||||
let backgroundColor = '#e2e8f0'; // 默认灰色(无数据)
|
||||
if (hasEvents) {
|
||||
backgroundColor = '#9F7AEA'; // 紫色(有事件)
|
||||
} else if (item.price) {
|
||||
if (priceInfo.color === 'red') {
|
||||
backgroundColor = '#FC8181'; // 红色(上涨)
|
||||
} else if (priceInfo.color === 'green') {
|
||||
backgroundColor = '#68D391'; // 绿色(下跌)
|
||||
}
|
||||
}
|
||||
|
||||
// 构建显示标题:同时显示事件和涨跌幅
|
||||
const hasPriceData = item.price && item.price.avg_change_pct !== null;
|
||||
let title = '';
|
||||
|
||||
if (hasEvents && hasPriceData) {
|
||||
// 同时有事件和价格数据
|
||||
title = `📰${newsCount} 📊${reportCount} ${priceInfo.text}`;
|
||||
} else if (hasEvents) {
|
||||
// 只有事件
|
||||
title = `📰${newsCount} 📊${reportCount}`;
|
||||
} else if (hasPriceData) {
|
||||
// 只有价格数据
|
||||
title = priceInfo.text;
|
||||
}
|
||||
|
||||
return {
|
||||
id: item.date,
|
||||
title,
|
||||
// 如果有新闻,添加新闻事件
|
||||
if (newsCount > 0) {
|
||||
events.push({
|
||||
id: `${item.date}-news`,
|
||||
title: `📰 ${newsCount} 条新闻`,
|
||||
date: item.date,
|
||||
backgroundColor,
|
||||
borderColor: backgroundColor,
|
||||
start: item.date,
|
||||
backgroundColor: '#9F7AEA',
|
||||
borderColor: '#9F7AEA',
|
||||
extendedProps: {
|
||||
...item,
|
||||
newsCount,
|
||||
reportCount,
|
||||
priceInfo,
|
||||
eventType: 'news',
|
||||
count: newsCount,
|
||||
originalData: item,
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// 如果有研报,添加研报事件
|
||||
if (reportCount > 0) {
|
||||
events.push({
|
||||
id: `${item.date}-report`,
|
||||
title: `📊 ${reportCount} 篇研报`,
|
||||
date: item.date,
|
||||
start: item.date,
|
||||
backgroundColor: '#805AD5',
|
||||
borderColor: '#805AD5',
|
||||
extendedProps: {
|
||||
eventType: 'report',
|
||||
count: reportCount,
|
||||
originalData: item,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 如果有价格数据,添加价格事件
|
||||
if (hasPriceData) {
|
||||
let bgColor = '#e2e8f0';
|
||||
if (priceInfo.color === 'red') {
|
||||
bgColor = '#FC8181'; // 红色(上涨)
|
||||
} else if (priceInfo.color === 'green') {
|
||||
bgColor = '#68D391'; // 绿色(下跌)
|
||||
}
|
||||
|
||||
events.push({
|
||||
id: `${item.date}-price`,
|
||||
title: priceInfo.text,
|
||||
date: item.date,
|
||||
start: item.date,
|
||||
backgroundColor: bgColor,
|
||||
borderColor: bgColor,
|
||||
extendedProps: {
|
||||
eventType: 'price',
|
||||
priceInfo,
|
||||
originalData: item,
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return events;
|
||||
}, [timelineData]);
|
||||
|
||||
// 处理日期点击
|
||||
@@ -235,11 +256,11 @@ const ConceptTimelineModal = ({
|
||||
|
||||
// 处理事件点击
|
||||
const handleEventClick = (info) => {
|
||||
const clickedDate = info.event.id;
|
||||
const dateData = timelineData.find(item => item.date === clickedDate);
|
||||
// 从事件的 extendedProps 中获取原始数据
|
||||
const dateData = info.event.extendedProps?.originalData;
|
||||
|
||||
if (dateData) {
|
||||
setSelectedDate(clickedDate);
|
||||
setSelectedDate(dateData.date);
|
||||
setSelectedDateData(dateData);
|
||||
onDateDetailOpen();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user