index.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { View, Text } from '@tarojs/components'
  2. import TDesignCellGroup from '../cell-group'
  3. import TDesignCell from '../cell'
  4. import TDesignIcon from '../icon'
  5. import TDesignBadge from '../badge'
  6. import './index.css'
  7. interface OrderTagInfo {
  8. title: string
  9. iconName: string
  10. orderNum?: number
  11. status?: string
  12. }
  13. interface OrderGroupProps {
  14. orderTagInfos?: OrderTagInfo[]
  15. title?: string
  16. desc?: string
  17. isTop?: boolean
  18. onItemClick?: (item: OrderTagInfo) => void
  19. onTopClick?: () => void
  20. className?: string
  21. }
  22. export default function TDesignOrderGroup({
  23. orderTagInfos = [
  24. { title: '待付款', iconName: 'clock', orderNum: 0 },
  25. { title: '待发货', iconName: 'package', orderNum: 0 },
  26. { title: '待收货', iconName: 'truck', orderNum: 0 },
  27. { title: '待评价', iconName: 'star', orderNum: 0 }
  28. ],
  29. title = '我的订单',
  30. desc = '全部订单',
  31. isTop = true,
  32. onItemClick,
  33. onTopClick,
  34. className = ''
  35. }: OrderGroupProps) {
  36. const handleItemClick = (item: OrderTagInfo) => {
  37. onItemClick?.(item)
  38. }
  39. const handleTopClick = () => {
  40. onTopClick?.()
  41. }
  42. return (
  43. <View className={`tdesign-order-group ${className}`}>
  44. {/* 顶部单元格 */}
  45. {isTop && (
  46. <TDesignCellGroup>
  47. <TDesignCell
  48. title={title}
  49. note={desc}
  50. bordered={false}
  51. arrow
  52. onClick={handleTopClick}
  53. className="tdesign-order-group__top"
  54. />
  55. </TDesignCellGroup>
  56. )}
  57. {/* 订单状态内容 */}
  58. <View className="tdesign-order-group__content">
  59. {orderTagInfos.map((item, index) => (
  60. <View
  61. key={index}
  62. className="tdesign-order-group__item"
  63. onClick={() => handleItemClick(item)}
  64. >
  65. {/* 图标和徽章 */}
  66. <View className="tdesign-order-group__item__icon">
  67. <TDesignBadge
  68. count={item.orderNum}
  69. maxCount={99}
  70. color="#FF4646"
  71. offset={[8, -8]}
  72. />
  73. <TDesignIcon
  74. name={item.iconName}
  75. size="56rpx"
  76. color="#6a6a6a"
  77. className="tdesign-order-group__item__icon-image"
  78. />
  79. </View>
  80. {/* 标题 */}
  81. <Text className="tdesign-order-group__item__title">
  82. {item.title}
  83. </Text>
  84. </View>
  85. ))}
  86. </View>
  87. </View>
  88. )
  89. }