import { View } from '@tarojs/components'
import { memo } from 'react'
import styles from './index.module.scss'
import LabAndImg from '@/components/LabAndImg'

const ProductItem = () => {
  return (
    <View>
      <View className={styles.item} key={item.id}>
        <View className={styles.item_color}>
          <LabAndImg value={{ lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }} />
        </View>
        <View className={styles.item_con}>
          <View className={styles.title}>{formatHashTag(item.code, item.name)}</View>
          <View className={styles.num}>
            <View className={styles.priceText}>
              <Text>¥</Text>
              {formatPrice(item)}
              <Text> /{selectList[selectIndex].eunit}</Text>
            </View>
          </View>
        </View>
        <View className={styles.btn_con}>
          {(!item.show && (
            <View className={styles.btn} onClick={() => onAdd(item)}>
              添加
            </View>
          )) || (
            <View className={styles.btn_count}>
              <Counter
                onBlue={e => getInputValue(e, item)}
                defaultNum={item.count}
                step={selectList[selectIndex].step}
                digits={selectList[selectIndex].digits}
                onClickBtn={e => getInputValue(e, item)}
                unit={selectList[selectIndex].unit}
                minNum={selectList[selectIndex].minNum}
                maxNum={selectList[selectIndex].maxNum}
              />
            </View>
          )}
        </View>
      </View>
    </View>
  )
}
export default memo(ProductItem)
