update pay ui
This commit is contained in:
@@ -209,11 +209,14 @@ const FlexScreen: React.FC = () => {
|
||||
(security: SearchResultItem | WatchlistItem): void => {
|
||||
const code = 'stock_code' in security ? security.stock_code : security.code;
|
||||
const name = 'stock_name' in security ? security.stock_name : security.name;
|
||||
const isIndex =
|
||||
security.isIndex || code.startsWith('000') || code.startsWith('399');
|
||||
// 优先使用 API 返回的 isIndex 字段
|
||||
const isIndex = security.isIndex === true;
|
||||
|
||||
// 检查是否已存在
|
||||
if (watchlist.some(item => item.code === code)) {
|
||||
// 生成唯一标识(带后缀的完整代码)
|
||||
const fullCode = getFullCode(code, isIndex);
|
||||
|
||||
// 检查是否已存在(使用带后缀的代码比较,避免上证指数和平安银行冲突)
|
||||
if (watchlist.some(item => getFullCode(item.code, item.isIndex) === fullCode)) {
|
||||
toast({
|
||||
title: '已在自选列表中',
|
||||
status: 'info',
|
||||
@@ -227,7 +230,7 @@ const FlexScreen: React.FC = () => {
|
||||
setWatchlist(prev => [...prev, { code, name, isIndex }]);
|
||||
|
||||
toast({
|
||||
title: `已添加 ${name}`,
|
||||
title: `已添加 ${name}${isIndex ? '(指数)' : ''}`,
|
||||
status: 'success',
|
||||
duration: 2000,
|
||||
isClosable: true,
|
||||
@@ -397,7 +400,7 @@ const FlexScreen: React.FC = () => {
|
||||
<List spacing={0}>
|
||||
{searchResults.map((stock, index) => (
|
||||
<ListItem
|
||||
key={stock.stock_code}
|
||||
key={`${stock.stock_code}-${stock.isIndex ? 'index' : 'stock'}`}
|
||||
px={4}
|
||||
py={2}
|
||||
cursor="pointer"
|
||||
@@ -408,9 +411,18 @@ const FlexScreen: React.FC = () => {
|
||||
>
|
||||
<HStack justify="space-between">
|
||||
<VStack align="start" spacing={0}>
|
||||
<Text fontWeight="medium" color={textColor}>
|
||||
{stock.stock_name}
|
||||
</Text>
|
||||
<HStack spacing={2}>
|
||||
<Text fontWeight="medium" color={textColor}>
|
||||
{stock.stock_name}
|
||||
</Text>
|
||||
<Badge
|
||||
colorScheme={stock.isIndex ? 'purple' : 'blue'}
|
||||
fontSize="xs"
|
||||
variant="subtle"
|
||||
>
|
||||
{stock.isIndex ? '指数' : '股票'}
|
||||
</Badge>
|
||||
</HStack>
|
||||
<Text fontSize="xs" color={subTextColor}>
|
||||
{stock.stock_code}
|
||||
</Text>
|
||||
|
||||
Reference in New Issue
Block a user