product.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="diy-product" :style="{ background: itemData.style.background }">
  3. <view :class="['display__' + itemData.style.display]">
  4. <template v-if="itemData.style.display == 'list'">
  5. <view class="product-list" :class="['column__' + itemData.style.column]">
  6. <view class="product-item" v-for="(product, index) in itemData.data" :key="index" @click="gotoDetail(product.product_id)">
  7. <!-- 单列商品 -->
  8. <template v-if="itemData.style.column == 1">
  9. <view class="product-item-box">
  10. <!-- 商品图片 -->
  11. <view class="product-cover">
  12. <image :src="product.image" mode="aspectFill"></image>
  13. </view>
  14. <view class="product-info">
  15. <!-- 商品名称 -->
  16. <view v-if="itemData.style.show.productName" class="product-title">
  17. <text>{{ product.product_name }}</text>
  18. </view>
  19. <!-- 商品卖点 -->
  20. <view v-if="itemData.style.show.sellingPoint" class="selling-point gray9">
  21. <text>{{ product.selling_point }}</text>
  22. </view>
  23. <!-- 商品销量 -->
  24. <view v-if="itemData.style.show.productSales" class="already-sale">
  25. <text>已售{{ product.product_sales }}件</text>
  26. </view>
  27. <!-- 商品价格 -->
  28. <view class="price d-s-c mt10">
  29. <view v-if="itemData.style.show.productPrice" class="red">
  30. <text>¥</text>
  31. <text class="">{{ product.product_price }}</text>
  32. </view>
  33. <view class="ml10 gray9 text-d-line f28" v-if="itemData.style.show.linePrice && product.line_price > 0">
  34. <text>¥</text>
  35. <text>{{ product.line_price }}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <!-- 两列三列 -->
  42. <template v-else>
  43. <view class="product-cover">
  44. <image :src="product.image" mode="aspectFill"></image>
  45. </view>
  46. <view class="product-info">
  47. <view v-if="itemData.style.show.productName == 1" class="product-title">{{ product.product_name }}</view>
  48. <view class="price d-s-c">
  49. <view v-if="itemData.style.show.productPrice == 1" class="red">
  50. <text class="f22">¥</text>
  51. <text class="">{{ product.product_price }}</text>
  52. </view>
  53. <view class="ml20 gray9 text-d-line" v-if="itemData.style.show.linePrice == 1 && product.line_price > 0"><text
  54. class="f22">¥</text>{{ product.line_price }}</view>
  55. </view>
  56. </view>
  57. </template>
  58. </view>
  59. </view>
  60. </template>
  61. <template v-else>
  62. <scroll-view :scroll-top="scrollTop" scroll-x="true">
  63. <view class="product-list" :class="['column__' + itemData.style.column]">
  64. <view v-for="(product, index) in itemData.data" :key="index" @click="gotoDetail(product.product_id)">
  65. <view class="product-item">
  66. <view class="product-cover">
  67. <image :src="product.image" mode="aspectFill"></image>
  68. </view>
  69. <view class="product-info">
  70. <view v-if="itemData.style.show.productName == 1" class="product-title">{{ product.product_name }}</view>
  71. <view class="price d-s-c f12">
  72. <view v-if="itemData.style.show.productPrice == 1" class="orange">
  73. <text>¥</text>
  74. <text class="">{{ product.product_price }}</text>
  75. </view>
  76. <view class="ml10 gray9 text-d-line" v-if="itemData.style.show.linePrice == 1 && product.line_price > 0">¥{{ product.line_price }}</view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </scroll-view>
  83. </template>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. components: {},
  90. data() {
  91. return {};
  92. },
  93. props: ['itemData'],
  94. created() {},
  95. methods: {
  96. scroll(e) {},
  97. /*跳转产品详情*/
  98. gotoDetail(e) {
  99. let url = '/pages/product/detail/detail?product_id=' + e;
  100. this.gotoPage(url);
  101. }
  102. }
  103. };
  104. </script>
  105. <style>
  106. .diy-product {
  107. overflow-x: hidden !important;
  108. overflow-y: auto;
  109. padding: 0 20rpx;
  110. }
  111. .diy-product .product-list.column__1 .product-item {
  112. margin-bottom: 20rpx;
  113. background: #ffffff;
  114. width: 100%;
  115. }
  116. .diy-product .product-list.column__1 .product-item-box {
  117. display: flex;
  118. justify-content: flex-start;
  119. align-items: stretch;
  120. }
  121. .diy-product .product-list .product-cover image {
  122. width: 100%;
  123. height: 100%;
  124. }
  125. .diy-product .product-list.column__1 .product-cover {
  126. width: 240rpx;
  127. height: 240rpx;
  128. border-radius: 20rpx;
  129. overflow: hidden;
  130. }
  131. .diy-product .product-list.column__1 .product-info {
  132. margin: 20rpx 20rpx 20rpx 30rpx;
  133. flex: 1;
  134. display: flex;
  135. flex-direction: column;
  136. justify-content: space-between;
  137. }
  138. .diy-product .product-list .product-info .already-sale text {
  139. padding: 4rpx 8rpx;
  140. border-radius: 8rpx;
  141. background: #f2f2f7;
  142. color: #999;
  143. }
  144. .diy-product .product-list .product-title {
  145. display: -webkit-box;
  146. font-size: 32rpx;
  147. overflow: hidden;
  148. -webkit-line-clamp: 2;
  149. -webkit-box-orient: vertical;
  150. }
  151. .diy-product .product-list.column__1 .product-title {
  152. max-height: 80rpx;
  153. line-height: 40rpx;
  154. }
  155. .diy-product .product-list.column__1 .selling-point {
  156. display: -webkit-box;
  157. overflow: hidden;
  158. -webkit-line-clamp: 2;
  159. -webkit-box-orient: vertical;
  160. line-height: 30rpx;
  161. max-height: 60rpx;
  162. }
  163. .diy-product .product-list.column__1 .already-sale {
  164. margin-top: 10rpx;
  165. }
  166. .diy-product .product-list.column__2 .product-title {
  167. height: 80rpx;
  168. line-height: 40rpx;
  169. margin-top: 20rpx;
  170. }
  171. .diy-product .product-list.column__3 .product-title {
  172. margin-top: 20rpx;
  173. margin-left: 10rpx;
  174. margin-right: 10rpx;
  175. height: 72rpx;
  176. line-height: 36rpx;
  177. font-size: 30rpx;
  178. }
  179. .diy-product .product-list.column__2 .product-info {
  180. padding: 0 24rpx;
  181. }
  182. .diy-product .product-list .price {
  183. font-size: 34rpx;
  184. }
  185. .diy-product .product-list.column__2 .price {
  186. margin-top: 10rpx;
  187. font-size: 30rpx;
  188. }
  189. .diy-product .product-list.column__3 .price {
  190. margin-top: 10rpx;
  191. padding: 0 10rpx;
  192. font-size: 28rpx;
  193. }
  194. .diy-product .product-list.column__3 .price .text-d-line {
  195. font-size: 22rpx;
  196. }
  197. .diy-product .product-list.column__2,
  198. .diy-product .product-list.column__3 {
  199. display: flex;
  200. flex-wrap: wrap;
  201. justify-content: flex-start;
  202. }
  203. .diy-product .column__2 .product-item {
  204. width: 350rpx;
  205. border-radius: 20rpx;
  206. margin-right: 10rpx;
  207. margin-bottom: 10rpx;
  208. padding-bottom: 20rpx;
  209. overflow: hidden;
  210. background: #ffffff;
  211. box-shadow: 0 0 8rpx rgba(0, 0, 0, 0.1);
  212. }
  213. .diy-product .display__list .column__2 .product-item:nth-child(2n + 0) {
  214. margin-right: 0;
  215. }
  216. .diy-product .column__2 .product-cover {
  217. width: 350rpx;
  218. height: 350rpx;
  219. }
  220. .diy-product .column__3 .product-item {
  221. width: 230rpx;
  222. margin-bottom: 10rpx;
  223. margin-right: 10rpx;
  224. padding-bottom: 10rpx;
  225. border-radius: 8rpx;
  226. overflow: hidden;
  227. background: #ffffff;
  228. box-shadow: 0 0 8rpx rgba(0, 0, 0, 0.1);
  229. }
  230. .diy-product .display__list .column__3 .product-item:nth-child(3n + 0) {
  231. margin-right: 0;
  232. }
  233. .diy-product .column__3 .product-cover {
  234. width: 230rpx;
  235. height: 230rpx;
  236. }
  237. .diy-product .display__slide .product-list {
  238. flex-wrap: nowrap;
  239. }
  240. .diy-product .display__slide .column__2 .product-item {
  241. width: 300rpx;
  242. }
  243. .diy-product .display__slide .column__3 .product-item {
  244. width: 200rpx;
  245. }
  246. </style>