import { Button, Col, Divider, InputNumber, Modal, Row, Space } from 'antd' import { ShoppingCartOutlined } from '@ant-design/icons' import type { RockStats } from '../../api' export interface PurchaseTokenModalProps { open: boolean stats: RockStats | null purchaseCount: number purchasing: boolean maxPurchasable: number upstreamPoints: number estimatedCost: number isPointsInsufficient: boolean tokenCost: number upstreamStock: number | null onPurchaseCountChange: (value: number) => void onCancel: () => void onConfirm: (count: number) => void } export function PurchaseTokenModal({ open, stats, purchaseCount, purchasing, maxPurchasable, upstreamPoints, estimatedCost, isPointsInsufficient, tokenCost, upstreamStock, onPurchaseCountChange, onCancel, onConfirm, }: PurchaseTokenModalProps) { const isStockInsufficient = upstreamStock !== null && purchaseCount > upstreamStock return ( 手动采购通用黑色 Token (0666.pro) } open={open} onCancel={onCancel} footer={[ , , ]} destroyOnClose width={500} >
{/* 账户与资产概览 */}
0666.pro 采购商户
{stats?.username || '正常商户'}
当前实时积分余额
{upstreamPoints.toFixed(1)} 点
采购单价:{tokenCost.toFixed(2)} 点 / 个 上游可用库存: {upstreamStock === null ? '未获取' : `${upstreamStock} 个`} 最大可采购:{maxPurchasable} 个
{/* 上游库存不足提示 */} {isStockInsufficient && (
⚠️ 上游可用库存不足:当前 {upstreamStock} 个,本次需要 {purchaseCount} 个,请减少采购数量。
)} {/* 采购数量输入 */}
采购数量:
0 ? maxPurchasable : 10000} value={purchaseCount} onChange={(val) => onPurchaseCountChange(val || 1)} style={{ width: '100%' }} addonAfter="个 Token" size="large" />
{/* 快捷数量选择胶囊 */}
快捷选择:
{[10, 20, 50, 100].map((num) => ( ))} {maxPurchasable > 0 && ( )}
{/* 实时消耗与结余试算 */}
本次采购消耗积分: {estimatedCost.toFixed(2)} 点
{isPointsInsufficient ? '⚠️ 账户积分不足,请先充值或减少采购数量' : '采购后预计剩余积分:'} {!isPointsInsufficient && ( {(upstreamPoints - estimatedCost).toFixed(1)} 点 )}
) }