巴青农资商城

GoodsGrid.vue 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="goods-grid">
  3. <view
  4. v-for="item in list"
  5. :key="item.goodsId"
  6. class="goods-card"
  7. @click="emit('item-click', item)"
  8. >
  9. <image-preview class="goods-card__pic" :src="item.mainPic" />
  10. <view class="goods-card__body">
  11. <text class="goods-card__name">{{ item.goodsName }}</text>
  12. <view class="goods-card__price">
  13. <text class="goods-card__symbol">¥</text>
  14. <text class="goods-card__num">{{ item.priceText }}</text>
  15. </view>
  16. <text class="goods-card__shop">{{ item.shopName || '—' }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. defineProps({
  23. list: {
  24. type: Array,
  25. default: () => []
  26. }
  27. })
  28. const emit = defineEmits(['item-click'])
  29. </script>
  30. <style lang="scss" scoped>
  31. .goods-grid {
  32. display: flex;
  33. flex-wrap: wrap;
  34. justify-content: space-between;
  35. padding: 0 24rpx;
  36. }
  37. .goods-card {
  38. width: 48%;
  39. margin-bottom: 20rpx;
  40. background: #fff;
  41. border-radius: 12rpx;
  42. overflow: hidden;
  43. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  44. }
  45. .goods-card__pic {
  46. width: 100%;
  47. height: 320rpx;
  48. background: #eee;
  49. display: block;
  50. }
  51. .goods-card__body {
  52. padding: 16rpx;
  53. }
  54. .goods-card__name {
  55. font-size: 26rpx;
  56. color: #333;
  57. line-height: 1.4;
  58. height: 72rpx;
  59. overflow: hidden;
  60. display: -webkit-box;
  61. -webkit-line-clamp: 2;
  62. -webkit-box-orient: vertical;
  63. }
  64. .goods-card__price {
  65. margin-top: 8rpx;
  66. color: #e53935;
  67. font-weight: 600;
  68. }
  69. .goods-card__symbol {
  70. font-size: 22rpx;
  71. }
  72. .goods-card__num {
  73. font-size: 34rpx;
  74. }
  75. .goods-card__shop {
  76. display: block;
  77. margin-top: 8rpx;
  78. font-size: 22rpx;
  79. color: #999;
  80. overflow: hidden;
  81. text-overflow: ellipsis;
  82. white-space: nowrap;
  83. }
  84. </style>