yd-product-box.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view>
  3. <view v-if="showType === 'normal'">
  4. <u-gap height="180" bgColor="#398ade"></u-gap>
  5. <view class="prod-block">
  6. <view class="bloc-header">
  7. <text class="bloc-title">{{title}}</text>
  8. <text class="see-more">查看更多</text>
  9. </view>
  10. <view class="prod-grid">
  11. <view class="prod-item" v-for="(item, index) in productList" :key="item.id" @click="handleProdItemClick(item.id)">
  12. <image class="prod-image" :src="item.image"></image>
  13. <view class="item-info">
  14. <view class="info-text">
  15. <u--text :lines="2" size="14px" color="#333333" :text="item.title"></u--text>
  16. </view>
  17. <view class="price-and-cart">
  18. <yd-text-price color="red" size="12" intSize="18" :price="item.price"></yd-text-price>
  19. <u-icon name="shopping-cart" color="#2979ff" size="28"></u-icon>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view v-if="showType === 'half'">
  27. <view class="prod-block half">
  28. <view class="bloc-header">
  29. <text class="bloc-title">{{title}}</text>
  30. <text class="more">更多 &gt;</text>
  31. </view>
  32. <view class="prod-grid half">
  33. <view class="prod-item" v-for="(item, index) in productList" :key="item.id" @click="handleProdItemClick(item.id)">
  34. <image class="prod-image" :src="item.image"></image>
  35. <view class="item-info">
  36. <view class="info-text">
  37. <u--text :lines="1" size="14px" color="#333333" :text="item.title"></u--text>
  38. <u--text :lines="1" size="12px" color="#939393" :text="item.desc"></u--text>
  39. </view>
  40. <view class="price-and-cart">
  41. <yd-text-price color="red" size="12" intSize="18" :price="item.price"></yd-text-price>
  42. <u-icon name="shopping-cart" color="#2979ff" size="28"></u-icon>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. /**
  53. * 商品列表
  54. */
  55. export default {
  56. name: 'yd-product-box',
  57. components: {},
  58. props: {
  59. showType: {
  60. type: String,
  61. default: 'normal'
  62. },
  63. title: {
  64. type: String,
  65. default: '商品推荐'
  66. },
  67. productList: {
  68. type: Array,
  69. default: () => []
  70. }
  71. },
  72. computed: {},
  73. methods: {
  74. handleProdItemClick(productId) {
  75. uni.$u.route('/pages/product/product', {
  76. id: productId
  77. })
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .prod-block {
  84. margin-top: -160px;
  85. .bloc-header {
  86. @include flex-space-between;
  87. padding: 10rpx 20rpx;
  88. .bloc-title {
  89. color: $custom-bg-color;
  90. font-size: 34rpx;
  91. }
  92. .see-more {
  93. color: $custom-bg-color;
  94. background: $u-primary;
  95. padding: 0 30rpx;
  96. height: 50rpx;
  97. line-height: 50rpx;
  98. border-radius: 50rpx;
  99. font-size: 24rpx;
  100. }
  101. }
  102. &.half {
  103. margin-top: 0;
  104. .bloc-header {
  105. margin-top: 50rpx;
  106. margin-bottom: 20rpx;
  107. .bloc-title {
  108. color: #333333;
  109. }
  110. .more {
  111. font-size: 24rpx;
  112. }
  113. }
  114. }
  115. .prod-grid {
  116. width: 730rpx;
  117. margin: 0 auto;
  118. @include flex;
  119. flex-wrap: wrap;
  120. justify-content: left;
  121. &.half {
  122. .prod-item {
  123. width: 345rpx;
  124. margin: 10rpx;
  125. .prod-image {
  126. width: 345rpx;
  127. height: 345rpx;
  128. }
  129. }
  130. }
  131. .prod-item {
  132. width: 223rpx;
  133. margin: 10rpx;
  134. background: #ffffff;
  135. border-radius: 10rpx;
  136. box-shadow: 0rpx 6rpx 8rpx rgba(58, 134, 185, 0.2);
  137. .prod-image {
  138. width: 223rpx;
  139. height: 223rpx;
  140. border-radius: 10rpx 10rpx 0 0;
  141. }
  142. .item-info {
  143. padding: 15rpx;
  144. .info-text {
  145. height: 70rpx;
  146. padding-bottom: 10rpx;
  147. }
  148. .price-and-cart {
  149. @include flex-space-between;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. </style>