fix(shop): 修复商品详情页孤立“0”渲染问题
- 修正赚取积分、重量和销量条件渲染,避免数字0被渲染成文本节点 - 赚取积分判断改为仅判断数值是否大于0,防止0泄漏 - 重量同样改为判断数值大于0避免显示无效数据 - 销量为0时隐藏销量信息,符合用户需求 - 调整加购按钮尺寸,使其视觉更协调
This commit is contained in:
@@ -262,7 +262,7 @@ const CategoryPage: React.FC = () => {
|
||||
</View>
|
||||
{/* 加购按钮 */}
|
||||
<View
|
||||
className='w-7 h-7 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0'
|
||||
className='w-6 h-6 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0'
|
||||
onClick={(e) => handleAddToCart(e, item)}
|
||||
>
|
||||
<Text className='text-white text-lg leading-none'>+</Text>
|
||||
|
||||
@@ -309,13 +309,15 @@ const ProductDetailPage: React.FC = () => {
|
||||
</View>
|
||||
)}
|
||||
{/* 赚取积分 */}
|
||||
{product.gainIntegral && Number(product.gainIntegral) > 0 && (
|
||||
{Number(product.gainIntegral) > 0 && (
|
||||
<View className='mt-1'>
|
||||
<Text className='text-xs text-orange-500'>购买可得 {product.gainIntegral} 积分</Text>
|
||||
</View>
|
||||
)}
|
||||
<View className='flex gap-2 mt-2'>
|
||||
<Text className='text-xs text-gray-400'>销量: {product.sales || 0}</Text>
|
||||
{Number(product.sales) > 0 && (
|
||||
<Text className='text-xs text-gray-400'>销量: {product.sales}</Text>
|
||||
)}
|
||||
<Text className='text-xs text-gray-400'>库存: {product.stock || 0}</Text>
|
||||
{product.unitName && (
|
||||
<Text className='text-xs text-gray-400'>单位: {product.unitName}</Text>
|
||||
@@ -363,7 +365,7 @@ const ProductDetailPage: React.FC = () => {
|
||||
<View className='flex items-center'>
|
||||
<Text className='text-xs text-gray-500 mr-2'>配送</Text>
|
||||
<Text className='text-sm text-gray-700'>{deliveryText}</Text>
|
||||
{product.goodsWeight && Number(product.goodsWeight) > 0 && (
|
||||
{Number(product.goodsWeight) > 0 && (
|
||||
<Text className='text-xs text-gray-400 ml-2'>重量: {product.goodsWeight}kg</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user