HotRecommend.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="hot">
  3. <view
  4. class="head-item"
  5. @click="goDetail('/pages/tabtar/goodsType', false, true)"
  6. :style="{ backgroundImage: `url(${bgImage || ''})` }"
  7. >
  8. <view class="top-left">
  9. <view class="top-left-title">热门推荐</view>
  10. <view class="top-left-tip">精选好物推荐</view>
  11. </view>
  12. <view class="top-right" style="color: #db7d75">
  13. 查看更多
  14. <!-- <text class="iconfont u-font24">&#xe6c7;</text> -->
  15. <uv-icon name="arrow-right" size="24rpx" color="#db7d75"></uv-icon>
  16. </view>
  17. </view>
  18. <view
  19. class="hot-item u-skeleton-fillet"
  20. v-if="(recommendList && recommendList.length > 0) || skeletonShow"
  21. >
  22. <view
  23. class="item"
  24. v-for="item in recommendList.length > 0 ? recommendList : 2"
  25. :key="item.id"
  26. @click="
  27. goProductDetails('/pages/shop/goodsDetails?id=' + item.productId)
  28. "
  29. >
  30. <!-- ?x-oss-process=style/w_350 -->
  31. <image
  32. v-if="item && item.coverImage"
  33. :src="`${item.coverImage}`"
  34. mode="aspectFill"
  35. ></image>
  36. <div class="title-price">
  37. <view class="hot-introduce" v-if="item && item.title">{{
  38. item.title
  39. }}</view>
  40. <view class="hot-number">
  41. <view class="hot-large">
  42. <rich-text
  43. :nodes="$mUtil.priceBigSmall(item.minSalePrice)"
  44. ></rich-text>
  45. </view>
  46. <view class="hot-small">¥{{ item.maxSalePrice }}</view>
  47. </view>
  48. </div>
  49. </view>
  50. </view>
  51. <noData v-else :config="{ top: 1, content: '暂无商品~' }"></noData>
  52. </view>
  53. </template>
  54. <script setup>
  55. import { ref, onMounted } from "vue";
  56. import { shopProductList_Api } from "@/api/shop";
  57. const props = defineProps({
  58. skeletonShow: {
  59. type: Boolean,
  60. default: false
  61. },
  62. bgImage: {
  63. type: String,
  64. default: ''
  65. }
  66. });
  67. const emit = defineEmits(['goDetail', 'goProductDetails']);
  68. const recommendList = ref([]); //推荐
  69. const goDetail = (url, isNeedLogin, tabShow) => {
  70. emit('goDetail', url, isNeedLogin, tabShow);
  71. };
  72. const goProductDetails = (url) => {
  73. emit('goProductDetails', url);
  74. };
  75. /**热门推荐 */
  76. const recommend = () => {
  77. shopProductList_Api({
  78. limit: 6,
  79. recommendStatus: 1,
  80. }).then((res) => {
  81. if (res && res.code == 200) {
  82. recommendList.value = res.data;
  83. }
  84. });
  85. };
  86. onMounted(() => {
  87. recommend();
  88. });
  89. defineExpose({
  90. init: recommend,
  91. });
  92. </script>
  93. <style scoped lang="scss">
  94. .hot {
  95. background: #ffe7e7;
  96. box-sizing: border-box;
  97. border-radius: 10rpx;
  98. overflow: hidden;
  99. .hot-item {
  100. display: flex;
  101. overflow: scroll;
  102. white-space: nowrap;
  103. padding: 0 30rpx 40rpx 30rpx;
  104. box-sizing: border-box;
  105. margin-top: 27rpx;
  106. .hot-number {
  107. display: flex;
  108. align-items: flex-end;
  109. margin-top: 20rpx;
  110. }
  111. .hot-large {
  112. color: #00bf5a;
  113. font-size: 36rpx;
  114. font-weight: Bold;
  115. line-height: 24rpx;
  116. }
  117. .hot-small {
  118. font-size: 22rpx;
  119. font-weight: Medium;
  120. line-height: 24rpx;
  121. color: #cccccc;
  122. margin-left: 16rpx;
  123. text-decoration: line-through;
  124. }
  125. .title-price {
  126. display: flex;
  127. flex-direction: column;
  128. justify-content: space-between;
  129. height: 140rpx;
  130. }
  131. .hot-introduce {
  132. overflow: hidden;
  133. word-break: break-all;
  134. margin-top: 24rpx;
  135. font-size: 24rpx;
  136. font-weight: Regular;
  137. line-height: 34rpx;
  138. color: #333333;
  139. text-overflow: ellipsis;
  140. display: -webkit-box;
  141. -webkit-line-clamp: 2;
  142. -webkit-box-orient: vertical;
  143. word-wrap: break-word;
  144. white-space: normal !important;
  145. width: 252rpx;
  146. }
  147. .item {
  148. padding: 20rpx;
  149. background-color: #ffffff;
  150. border-radius: 16rpx;
  151. margin-right: 20rpx;
  152. image {
  153. width: 252rpx;
  154. height: 252rpx;
  155. border-radius: 16rpx;
  156. }
  157. }
  158. }
  159. }
  160. .head-item {
  161. display: flex;
  162. align-items: center;
  163. justify-content: space-between;
  164. padding: 27rpx 30rpx;
  165. box-sizing: border-box;
  166. overflow: hidden;
  167. background-size: 100% 100%;
  168. background-repeat: no-repeat;
  169. .top-left {
  170. .top-left-title {
  171. font-size: 36rpx;
  172. font-family: PingFang SC, PingFang SC-Bold;
  173. font-weight: 700;
  174. }
  175. .top-left-tip {
  176. font-size: 24rpx;
  177. font-family: PingFang SC, PingFang SC-Regular;
  178. font-weight: 400;
  179. margin-top: 5rpx;
  180. }
  181. }
  182. .top-right {
  183. width: 165rpx;
  184. height: 67rpx;
  185. line-height: 67rpx;
  186. background: #ffffff;
  187. border-radius: 34rpx;
  188. box-sizing: border-box;
  189. font-size: 24rpx;
  190. font-family: PingFang SC, PingFang SC-Regular;
  191. font-weight: 400;
  192. text-align: center;
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. }
  197. }
  198. </style>