update pay function

This commit is contained in:
2025-11-23 23:08:30 +08:00
parent 69d05b664e
commit 3c7b55226c

View File

@@ -80,10 +80,22 @@ const TradeModal = ({ isOpen, onClose, topic, mode = 'buy', onTradeSuccess }) =>
if (!topic || !userAccount) return null; if (!topic || !userAccount) return null;
// 构建市场数据(兼容后端字段)
const positions = {
yes: {
total_shares: topic.yes_total_shares || 0,
current_price: topic.yes_price || 500,
},
no: {
total_shares: topic.no_total_shares || 0,
current_price: topic.no_price || 500,
},
};
// 获取市场数据 // 获取市场数据
const selectedSide = topic.positions[selectedOption]; const selectedSide = positions[selectedOption];
const otherOption = selectedOption === 'yes' ? 'no' : 'yes'; const otherOption = selectedOption === 'yes' ? 'no' : 'yes';
const otherSide = topic.positions[otherOption]; const otherSide = positions[otherOption];
// 计算交易数据 // 计算交易数据
let cost = 0; let cost = 0;
@@ -278,14 +290,14 @@ const TradeModal = ({ isOpen, onClose, topic, mode = 'buy', onTradeSuccess }) =>
</Text> </Text>
</HStack> </HStack>
<Text fontSize="xs" color={forumColors.text.secondary}> <Text fontSize="xs" color={forumColors.text.secondary}>
{topic.positions.yes.total_shares}份持仓 {positions.yes.total_shares}份持仓
</Text> </Text>
</VStack> </VStack>
</HStack> </HStack>
<VStack align="end" spacing="0"> <VStack align="end" spacing="0">
<Text fontSize="xl" fontWeight="bold" color="green.600"> <Text fontSize="xl" fontWeight="bold" color="green.600">
{Math.round(topic.positions.yes.current_price)} {Math.round(positions.yes.current_price)}
</Text> </Text>
<Text fontSize="xs" color={forumColors.text.secondary}> <Text fontSize="xs" color={forumColors.text.secondary}>
积分/ 积分/
@@ -324,14 +336,14 @@ const TradeModal = ({ isOpen, onClose, topic, mode = 'buy', onTradeSuccess }) =>
</Text> </Text>
</HStack> </HStack>
<Text fontSize="xs" color={forumColors.text.secondary}> <Text fontSize="xs" color={forumColors.text.secondary}>
{topic.positions.no.total_shares}份持仓 {positions.no.total_shares}份持仓
</Text> </Text>
</VStack> </VStack>
</HStack> </HStack>
<VStack align="end" spacing="0"> <VStack align="end" spacing="0">
<Text fontSize="xl" fontWeight="bold" color="red.600"> <Text fontSize="xl" fontWeight="bold" color="red.600">
{Math.round(topic.positions.no.current_price)} {Math.round(positions.no.current_price)}
</Text> </Text>
<Text fontSize="xs" color={forumColors.text.secondary}> <Text fontSize="xs" color={forumColors.text.secondary}>
积分/ 积分/