You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
5.0 KiB

4 years ago
  1. <template>
  2. <view class="mix-product-list" :class="{'is-row': listType === 'row'}">
  3. <view
  4. v-if="listType === 'row'"
  5. v-for="(item, index) in renderList"
  6. :key="index"
  7. class="list-item row b-b"
  8. @click="navTo('/pages/product/detail?id=' + item._id)"
  9. >
  10. <view class="image-wrapper lazyload lazypic" :class="{loaded: item.loaded}">
  11. <image
  12. :src="item.thumb"
  13. mode="aspectFill"
  14. lazy-load="true"
  15. @load="imageOnLoad(item)"
  16. ></image>
  17. </view>
  18. <view class="right column">
  19. <text class="title clamp">{{ item.title }}</text>
  20. <text class="sales">月销 {{ item.sales || 0 }}</text>
  21. <view class="price-wrap row">
  22. <mix-price-view :price="item.price" :size="34"></mix-price-view>
  23. <text v-if="item.market_price > item.price" class="m-price">{{ item.market_price }}</text>
  24. <view class="tags row">
  25. <view class="tag center" v-if="!item.freight_template">
  26. <text>免邮费</text>
  27. </view>
  28. <!-- <view class="tag center orange">
  29. <text>赠送75积分</text>
  30. </view> -->
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view
  36. v-if="listType === 'column'"
  37. v-for="item in renderList"
  38. :key="item._id"
  39. class="list-item column"
  40. @click="navTo('/pages/product/detail?id=' + item._id)"
  41. >
  42. <view class="image-wrapper lazyload lazypic" :class="{loaded: item.loaded}">
  43. <image
  44. :src="item.thumb"
  45. mode="aspectFill"
  46. lazy-load="true"
  47. @load="imageOnLoad(item)"
  48. ></image>
  49. </view>
  50. <text class="title clamp2">{{ item.title }}</text>
  51. <view class="price-wrap row">
  52. <mix-price-view :price="item.price"></mix-price-view>
  53. <text v-if="item.market_price > item.price" class="m-price">{{ item.market_price }}</text>
  54. <view class="fill"></view>
  55. <view class="tag center" v-if="!item.freight_template">
  56. <text>免邮费</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. name: 'MixProductList',
  65. data() {
  66. return {
  67. loadType: 'add',//标记加载还是刷新数据
  68. renderList: []
  69. };
  70. },
  71. props: {
  72. list: {
  73. type: Array,
  74. default(){
  75. return []
  76. }
  77. },
  78. listType: {
  79. type: String,
  80. default: 'column'
  81. }
  82. },
  83. watch: {
  84. list(list){
  85. if(this.loadType === 'add'){
  86. this.renderList = this.renderList.concat(list.slice(this.renderList.length));
  87. }else{
  88. this.renderList = list;
  89. }
  90. }
  91. },
  92. methods: {
  93. }
  94. }
  95. </script>
  96. <style scoped lang="scss">
  97. .mix-product-list{
  98. display:flex;
  99. justify-content: space-between;
  100. flex-wrap:wrap;
  101. width: 710rpx;
  102. margin-left: 20rpx;
  103. background-color: #f7f7f7;
  104. &.is-row{
  105. margin-top: -4rpx;
  106. border-radius: 8rpx;
  107. box-shadow: 4rpx 4rpx 20rpx rgba(0,0,0,.06);
  108. overflow: hidden;
  109. }
  110. }
  111. /* 横向列表 */
  112. .list-item.row{
  113. width: 100%;
  114. padding: 24rpx 0 24rpx 24rpx;
  115. background-color: #fff;
  116. &:after{
  117. border-color: #eaeaea;
  118. left: 6rpx;
  119. right: 6rpx;
  120. }
  121. &:last-child:after{
  122. border: 0;
  123. }
  124. .image-wrapper{
  125. flex-shrink: 0;
  126. width: 160rpx;
  127. height: 160rpx;
  128. margin-right: 20rpx;
  129. border-radius: 6rpx;
  130. overflow: hidden;
  131. image{
  132. width: 100%;
  133. height: 100%;
  134. }
  135. }
  136. .right{
  137. flex: 1;
  138. overflow: hidden;
  139. }
  140. .title{
  141. margin-right: 24rpx;
  142. font-size: 30rpx;
  143. color: #333;
  144. line-height: 40rpx;
  145. }
  146. .sales{
  147. height: 40rpx;
  148. margin: 14rpx 0 28rpx;
  149. line-height: 40rpx;
  150. font-size: 26rpx;
  151. color: #888;
  152. }
  153. .price-wrap{
  154. display: flex;
  155. align-items: baseline;
  156. padding-right: 20rpx;
  157. }
  158. .m-price{
  159. font-size: 26rpx;
  160. text-decoration: line-through;
  161. color: #999;
  162. margin-left: 10rpx;
  163. }
  164. .tags{
  165. flex: 1;
  166. justify-content: flex-end;
  167. position: relative;
  168. bottom: 4rpx;
  169. }
  170. .tag{
  171. height: 32rpx;
  172. padding: 0 10rpx;
  173. margin-left: 10rpx;
  174. font-size: 20rpx;
  175. color: #fff;
  176. border-radius: 4rpx;
  177. background-color: $base-color;
  178. &.orange{
  179. background-color: orange;
  180. }
  181. }
  182. }
  183. /* 竖向列表 */
  184. .list-item.column{
  185. width: 350rpx;
  186. padding-bottom: 16rpx;
  187. margin-bottom: 12rpx;
  188. background: #fff;
  189. border-radius: 8rpx;
  190. overflow: hidden;
  191. box-shadow: 0 0 16rpx rgba(0,0,0,.06);
  192. position: relative;
  193. .image-wrapper{
  194. width: 100%;
  195. height: 350rpx;
  196. overflow: hidden;
  197. image{
  198. width: 100%;
  199. height: 100%;
  200. }
  201. }
  202. .title{
  203. font-size: 28rpx;
  204. color: #333;
  205. line-height: 36rpx;
  206. padding: 0 16rpx;
  207. margin-top: 18rpx;
  208. height: 76rpx;
  209. }
  210. .price-wrap{
  211. padding: 0 16rpx;
  212. margin-top: 18rpx;
  213. }
  214. .m-price{
  215. font-size: 24rpx;
  216. text-decoration: line-through;
  217. color: #999;
  218. margin-left: 10rpx;
  219. &:before{
  220. content: "¥";
  221. }
  222. }
  223. .tag{
  224. height: 32rpx;
  225. padding: 0 10rpx;
  226. font-size: 20rpx;
  227. background-color: $base-color;
  228. color: #fff;
  229. border-radius: 4rpx;
  230. transform: translateY(-4rpx);
  231. }
  232. }
  233. </style>