recommendProduct.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="recommend-product" v-if="isShow">
  3. <view class="title d-c-c">
  4. <text class="line-left"></text>
  5. <text class="name">{{showName}}</text>
  6. <text class="line-right"></text>
  7. </view>
  8. <view class="recommend-product-list">
  9. <view class="item" v-for="(item, index) in listData" :key="index" @click="gotoProduct(item.product_id)">
  10. <view class="product-cover">
  11. <image :src="item.product_image" mode="aspectFill"></image>
  12. </view>
  13. <view class="product-info">
  14. <view class="product-title">{{ item.product_name }}</view>
  15. <view class="d-b-c mt20">
  16. <!-- <view class="already-sale f22 gray9">已售{{ item.product_sales }}件</view> -->
  17. <view class="price">
  18. ¥
  19. <text class="num">{{ item.product_sku.product_price }}</text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. /*数据*/
  32. listData: [],
  33. isShow: false,
  34. showName: ''
  35. };
  36. },
  37. created() {
  38. this.getData();
  39. },
  40. props: ['location'],
  41. methods: {
  42. /*获取数据*/
  43. getData() {
  44. let self = this;
  45. let page = self.page;
  46. self._post(
  47. 'product.product/recommendProduct', {
  48. location: self.location
  49. },
  50. function(res) {
  51. if (res.data.is_recommend == true) {
  52. self.isShow = true;
  53. self.showName = res.data.recommend.name;
  54. self.listData = res.data.list;
  55. }
  56. }
  57. );
  58. },
  59. /*推荐商品跳转*/
  60. gotoProduct(e) {
  61. let url = 'pages/product/detail/detail?product_id=' + e
  62. this.gotoPage(url);
  63. }
  64. }
  65. };
  66. </script>
  67. <style lang="scss">
  68. .recommend-product {
  69. margin-top: 40rpx;
  70. }
  71. .recommend-product .title {
  72. heigth: 100rpx;
  73. font-size: 30rpx;
  74. }
  75. .recommend-product .title .name {
  76. margin: 0 20rpx;
  77. font-size: 30rpx;
  78. }
  79. .recommend-product .title .line {
  80. position: relative;
  81. display: block;
  82. width: 100rpx;
  83. border-top: 1px solid red;
  84. }
  85. .recommend-product .title .line::after {
  86. position: absolute;
  87. content: '';
  88. display: block;
  89. width: 16rpx;
  90. height: 16rpx;
  91. border-radius: 50%;
  92. background: red;
  93. }
  94. .recommend-product .title .left-line::after {
  95. right: 0;
  96. top: -9rpx;
  97. }
  98. .recommend-product .title .right-line::after {
  99. left: 0;
  100. top: -9rpx;
  101. }
  102. .recommend-product-list {
  103. padding: 20rpx;
  104. display: flex;
  105. justify-content: space-between;
  106. align-items: flex-start;
  107. flex-wrap: wrap;
  108. }
  109. .recommend-product-list .item {
  110. width: 350rpx;
  111. border-radius: 20rpx;
  112. margin-right: 10rpx;
  113. margin-bottom: 20rpx;
  114. padding-bottom: 20rpx;
  115. overflow: hidden;
  116. background: #ffffff;
  117. box-shadow: 0 0 8rpx rgba(0, 0, 0, .1);
  118. margin-bottom: 10rpx;
  119. }
  120. .recommend-product-list .item:nth-child(2n+0) {
  121. margin-right: 0;
  122. }
  123. .recommend-product-list .product-cover {
  124. width: 350rpx;
  125. height: 350rpx;
  126. }
  127. .recommend-product-list image {
  128. width: 100%;
  129. height: 100%;
  130. }
  131. .recommend-product-list .product-info {
  132. padding: 0 24rpx;
  133. }
  134. .recommend-product-list .product-title {
  135. height: 80rpx;
  136. margin-top: 20rpx;
  137. display: -webkit-box;
  138. overflow: hidden;
  139. -webkit-line-clamp: 2;
  140. -webkit-box-orient: vertical;
  141. font-size: 30rpx;
  142. }
  143. .recommend-product-list .price {
  144. color: $dominant-color;
  145. }
  146. .recommend-product-list .price .num {
  147. font-size: 30rpx;
  148. font-weight: bold;
  149. }
  150. .line-left {
  151. width: 80px;
  152. height: 3px;
  153. background-image: linear-gradient(to right, #EBEBEB, #666666);
  154. }
  155. .line-right {
  156. width: 80px;
  157. height: 3px;
  158. background-image: linear-gradient(to left, #EBEBEB, #666666);
  159. }
  160. </style>