import {Image} from '@nutui/nutui-react-taro'
import {View, Text} from '@tarojs/components'
import Taro from '@tarojs/taro'
import './GoodsList.scss'
import {ShopGoods} from "@/api/shop/shopGoods/model";


const GoodsList = (props: any) => {

  return (
    <>
      <View className={'p-3'}>

        <View className="goods-grid">
          {props.data?.map((item: ShopGoods) => (
            <View key={item.goodsId} className="goods-card">
              <View className="goods-card__imgWrap">
                <Image
                  className="goods-card__img"
                  src={item.image || ''}
                  mode="aspectFill"
                  width="100%"
                  height="280rpx"
                  radius="18rpx"
                  lazyLoad={false}
                  onClick={() =>
                    Taro.navigateTo({ url: `/shop/goodsDetail/index?id=${item.goodsId}` })
                  }
                />
              </View>

              <View className="goods-card__body">
                <Text className="goods-card__title">{item.name}</Text>
                <View className="goods-card__meta">
                  <Text className="goods-card__sold">已购:{item.sales || 0}人</Text>
                  <View className="goods-card__price">
                    <Text className="goods-card__priceUnit">￥</Text>
                    <Text className="goods-card__priceValue">{item.buyingPrice}</Text>
                  </View>
                </View>

                <View className="goods-card__actions">
                  <View
                    className="goods-card__btn goods-card__btn--primary"
                    onClick={() =>
                      Taro.navigateTo({ url: `/shop/goodsDetail/index?id=${item.goodsId}` })
                    }
                  >
                    <Text className="goods-card__btnText goods-card__btnText--primary">立即购买</Text>
                  </View>
                </View>
              </View>
            </View>
          ))}
        </View>
      </View>
    </>
  )
}
export default GoodsList
