Files
mp-10550/src/components/CouponStats.tsx
赵忠林 89cadc3886 refactor(shop): 重构优惠券和礼品卡相关功能
- 优化了优惠券和礼品卡的搜索功能
- 重新设计了统计卡片的样式和布局- 改进了优惠券和礼品卡的领取和兑换流程
- 统一了图标样式和大小
- 调整了部分组件的显示逻辑
2025-08-13 11:17:00 +08:00

72 lines
2.3 KiB
TypeScript

import React from 'react'
import { View, Text } from '@tarojs/components'
import { Gift, Voucher, Clock } from '@nutui/icons-react-taro'
export interface CouponStatsProps {
/** 可用优惠券数量 */
availableCount: number
/** 已使用优惠券数量 */
usedCount: number
/** 已过期优惠券数量 */
expiredCount: number
/** 点击统计项的回调 */
onStatsClick?: (type: 'available' | 'used' | 'expired') => void
}
const CouponStats: React.FC<CouponStatsProps> = ({
availableCount,
usedCount,
expiredCount,
onStatsClick
}) => {
const handleStatsClick = (type: 'available' | 'used' | 'expired') => {
onStatsClick?.(type)
}
return (
<View className="bg-white mx-4 my-3 rounded-xl p-4">
<Text className="font-semibold text-gray-800"></Text>
<View className="flex justify-between mt-2">
{/* 可用优惠券 */}
<View
className="flex-1 text-center py-3 mx-1 bg-red-50 rounded-lg"
onClick={() => handleStatsClick('available')}
>
<View className="flex justify-center mb-2">
<Gift size="24" className="text-red-500" />
</View>
<Text className="text-2xl font-bold text-red-500 block">{availableCount}</Text>
<Text className="text-sm text-gray-600 mt-1"></Text>
</View>
{/* 已使用优惠券 */}
<View
className="flex-1 text-center py-3 mx-1 bg-green-50 rounded-lg"
onClick={() => handleStatsClick('used')}
>
<View className="flex justify-center mb-2">
<Voucher size="24" className="text-green-500" />
</View>
<Text className="text-2xl font-bold text-green-500 block">{usedCount}</Text>
<Text className="text-sm text-gray-600 mt-1">使</Text>
</View>
{/* 已过期优惠券 */}
<View
className="flex-1 text-center py-3 mx-1 bg-gray-50 rounded-lg"
onClick={() => handleStatsClick('expired')}
>
<View className="flex justify-center mb-2">
<Clock size="24" className="text-gray-500" />
</View>
<Text className="text-2xl font-bold text-gray-500 block">{expiredCount}</Text>
<Text className="text-sm text-gray-600 mt-1"></Text>
</View>
</View>
</View>
)
}
export default CouponStats