fix(shop): 修复商品详情页孤立“0”渲染问题

- 修正赚取积分、重量和销量条件渲染,避免数字0被渲染成文本节点
- 赚取积分判断改为仅判断数值是否大于0,防止0泄漏
- 重量同样改为判断数值大于0避免显示无效数据
- 销量为0时隐藏销量信息,符合用户需求
- 调整加购按钮尺寸,使其视觉更协调
This commit is contained in:
2026-07-14 03:01:54 +08:00
parent f159505ce2
commit b7bdefba96
3 changed files with 23 additions and 6 deletions

View File

@@ -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>

View File

@@ -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>