update pay function

This commit is contained in:
2025-11-24 21:23:09 +08:00
parent 83d7c19fed
commit 96bedb8439

View File

@@ -11,7 +11,8 @@ import {
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import { eventService, stockService } from '../../../services/eventService'; import { eventService, stockService } from '../../../services/eventService';
import StockChartAntdModal from '../../../components/StockChart/StockChartAntdModal'; import TimelineChartModal from '../../../components/StockChart/TimelineChartModal';
import KLineChartModal from '../../../components/StockChart/KLineChartModal';
import { useSubscription } from '../../../hooks/useSubscription'; import { useSubscription } from '../../../hooks/useSubscription';
import SubscriptionUpgradeModal from '../../../components/SubscriptionUpgradeModal'; import SubscriptionUpgradeModal from '../../../components/SubscriptionUpgradeModal';
import CitationMark from '../../../components/Citation/CitationMark'; import CitationMark from '../../../components/Citation/CitationMark';
@@ -41,8 +42,10 @@ const InvestmentCalendar = () => {
const [stockModalVisible, setStockModalVisible] = useState(false); const [stockModalVisible, setStockModalVisible] = useState(false);
const [selectedStocks, setSelectedStocks] = useState([]); const [selectedStocks, setSelectedStocks] = useState([]);
const [stockQuotes, setStockQuotes] = useState({}); const [stockQuotes, setStockQuotes] = useState({});
const [timelineModalVisible, setTimelineModalVisible] = useState(false);
const [klineModalVisible, setKlineModalVisible] = useState(false); const [klineModalVisible, setKlineModalVisible] = useState(false);
const [selectedStock, setSelectedStock] = useState(null); const [selectedStock, setSelectedStock] = useState(null);
const [selectedEventTime, setSelectedEventTime] = useState(null); // 记录事件时间
const [followingIds, setFollowingIds] = useState([]); // 正在处理关注的事件ID列表 const [followingIds, setFollowingIds] = useState([]); // 正在处理关注的事件ID列表
const [addingToWatchlist, setAddingToWatchlist] = useState({}); // 正在添加到自选的股票代码 const [addingToWatchlist, setAddingToWatchlist] = useState({}); // 正在添加到自选的股票代码
const [expandedReasons, setExpandedReasons] = useState({}); // 跟踪每个股票关联理由的展开状态 const [expandedReasons, setExpandedReasons] = useState({}); // 跟踪每个股票关联理由的展开状态
@@ -263,12 +266,40 @@ const InvestmentCalendar = () => {
loadStockQuotes(sortedStocks, eventTime); loadStockQuotes(sortedStocks, eventTime);
}; };
// 显示K线图 // 添加交易所后缀
const showKline = (stock) => { const addExchangeSuffix = (code) => {
const sixDigitCode = getSixDigitCode(code);
// 如果已有后缀,直接返回
if (code.includes('.')) return code;
// 根据股票代码规则添加后缀
if (sixDigitCode.startsWith('6')) {
return `${sixDigitCode}.SH`; // 上海
} else if (sixDigitCode.startsWith('0') || sixDigitCode.startsWith('3')) {
return `${sixDigitCode}.SZ`; // 深圳
} else if (sixDigitCode.startsWith('688')) {
return `${sixDigitCode}.SH`; // 科创板
}
return sixDigitCode;
};
// 显示分时图
const showTimeline = (stock, eventTime) => {
setSelectedStock({ setSelectedStock({
code: getSixDigitCode(stock[0]), // 确保使用六位代码 stock_code: addExchangeSuffix(stock[0]), // 添加交易所后缀
name: stock[1] stock_name: stock[1]
}); });
setSelectedEventTime(eventTime);
setTimelineModalVisible(true);
};
// 显示K线图
const showKline = (stock, eventTime) => {
setSelectedStock({
stock_code: addExchangeSuffix(stock[0]), // 添加交易所后缀
stock_name: stock[1]
});
setSelectedEventTime(eventTime);
setKlineModalVisible(true); setKlineModalVisible(true);
}; };
@@ -635,17 +666,26 @@ const InvestmentCalendar = () => {
}, },
{ {
title: 'K线图', title: '图',
key: 'kline', key: 'charts',
width: 80, width: 150,
render: (_, record) => ( render: (_, record) => (
<Button <Space size="small">
type="primary" <Button
size="small" type="default"
onClick={() => showKline(record)} size="small"
> onClick={() => showTimeline(record, selectedDate?.toISOString())}
查看 >
</Button> 分时图
</Button>
<Button
type="primary"
size="small"
onClick={() => showKline(record, selectedDate?.toISOString())}
>
日K线
</Button>
</Space>
) )
}, },
{ {
@@ -808,12 +848,31 @@ const InvestmentCalendar = () => {
)} )}
</Modal> </Modal>
{/* K线图模态框 */} {/* 分时图弹窗 */}
{klineModalVisible && selectedStock && ( {selectedStock && (
<StockChartAntdModal <TimelineChartModal
open={klineModalVisible} isOpen={timelineModalVisible}
onClose={() => {
setTimelineModalVisible(false);
setSelectedStock(null);
setSelectedEventTime(null);
}}
stock={selectedStock} stock={selectedStock}
onCancel={() => setKlineModalVisible(false)} eventTime={selectedEventTime}
/>
)}
{/* K线图弹窗 */}
{selectedStock && (
<KLineChartModal
isOpen={klineModalVisible}
onClose={() => {
setKlineModalVisible(false);
setSelectedStock(null);
setSelectedEventTime(null);
}}
stock={selectedStock}
eventTime={selectedEventTime}
/> />
)} )}