import React from 'react' import { View, Text } from '@tarojs/components' import { Tag } from '@nutui/nutui-react-taro' import { Voucher, Clock, Agenda } from '@nutui/icons-react-taro' import dayjs from 'dayjs' export interface CouponUsageRecordProps { /** 优惠券ID */ couponId: number /** 优惠券名称 */ couponName: string /** 优惠券类型 */ couponType: number /** 优惠券金额 */ couponAmount: string /** 使用时间 */ usedTime: string /** 订单号 */ orderNo?: string /** 订单金额 */ orderAmount?: string /** 节省金额 */ savedAmount?: string /** 使用状态:1-已使用 2-已过期 */ status: 1 | 2 /** 点击事件 */ onClick?: () => void } const CouponUsageRecord: React.FC = ({ couponName, couponType, couponAmount, usedTime, orderNo, orderAmount, savedAmount, status, onClick }) => { // 获取优惠券类型文本 const getCouponTypeText = () => { switch (couponType) { case 10: return '满减券' case 20: return '折扣券' case 30: return '免费券' default: return '优惠券' } } // 获取优惠券金额显示 const getCouponAmountDisplay = () => { switch (couponType) { case 10: // 满减券 return `¥${couponAmount}` case 20: // 折扣券 return `${couponAmount}折` case 30: // 免费券 return '免费' default: return `¥${couponAmount}` } } // 获取状态信息 const getStatusInfo = () => { switch (status) { case 1: return { text: '已使用', color: 'success' as const, icon: } case 2: return { text: '已过期', color: 'danger' as const, icon: } default: return { text: '未知', color: 'default' as const, icon: } } } const statusInfo = getStatusInfo() return ( {/* 头部信息 */} {getCouponAmountDisplay()} {couponName} {getCouponTypeText()} {statusInfo.icon} {statusInfo.text} {/* 使用详情 */} 使用时间 {dayjs(usedTime).format('YYYY-MM-DD HH:mm')} {orderNo && ( 订单号 {orderNo} )} {orderAmount && ( 订单金额 ¥{orderAmount} )} {savedAmount && ( 节省金额 ¥{savedAmount} )} {/* 底部操作 */} {orderNo && ( 查看订单 )} ) } export default CouponUsageRecord