hotComponent.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="hot-wrap" v-if="hotList && hotList.length">
  3. <view class="hot-content" :class="{'hot-border': isGardeItem}">
  4. <view class="hot-title">
  5. <view class="title-l" v-show="!isGardeItem">
  6. 好味<text class="title-color">热卖</text>
  7. </view>
  8. <view class="title-l" v-show="isGardeItem">
  9. 果园热卖
  10. </view>
  11. <view class="title-btn">
  12. 限时抢购中<up-icon size="10" name="arrow-right"></up-icon>
  13. </view>
  14. </view>
  15. <view class="hot-list">
  16. <up-scroll-list :indicator="hotList && hotList.length>2" indicatorColor="#FF770033" indicatorActiveColor="#FF7700" :indicatorWidth="30"
  17. :indicatorBarWidth="13">
  18. <view class="hot-panel">
  19. <view class="hot-item" v-for="(item, index) in hotList" :key="index">
  20. <image class="hot-img" :src="item.img" mode=""></image>
  21. <view class="item-info">
  22. <view class="info-text">
  23. <!-- <up-text :lines="2" color="#000000" size="12" text="海南妃子笑新鲜顺丰发货海南妃子笑海南妃子笑"></up-text> -->
  24. <view class="ellipsis-l2">
  25. {{ item.name }}
  26. </view>
  27. </view>
  28. <view class="info-price">
  29. <view class="price-text">
  30. <text class="price-unit">¥</text>{{ item.price }}
  31. </view>
  32. <view class="info-sold">
  33. 已售{{ item.salesVal }}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </up-scroll-list>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script setup>
  45. import { watch, ref, onMounted } from 'vue'
  46. import HOME from '@/api/home.js'
  47. const props = defineProps({
  48. isGardeItem: {
  49. type: Boolean,
  50. default: false
  51. },
  52. farmId: {
  53. type: [String, Number],
  54. default: null
  55. }
  56. })
  57. const hotList = ref([])
  58. watch(() => props.farmId, (newVal) => {
  59. getHotList()
  60. })
  61. onMounted(() => {
  62. getHotList()
  63. })
  64. const getHotList = () => {
  65. HOME.fetchHotList({
  66. farmId: props.farmId
  67. }).then(({data}) => {
  68. hotList.value = data
  69. })
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .hot-title {
  74. display: flex;
  75. align-items: center;
  76. justify-content: space-between;
  77. padding-bottom: 20rpx;
  78. .title-l {
  79. font-family: 'PangMenZhengDao';
  80. font-size: 32rpx;
  81. .title-color {
  82. color: #F3C11D;
  83. }
  84. }
  85. .title-btn {
  86. color: rgba(0, 0, 0, 0.6);
  87. font-size: 24rpx;
  88. display: inline-flex;
  89. align-items: center;
  90. }
  91. }
  92. .hot-wrap {
  93. background: linear-gradient(#FFFFFF, rgba(255, 255, 255, 0));
  94. padding: 2rpx;
  95. border-radius: 16rpx;
  96. .hot-content {
  97. background: linear-gradient(#fff1c3 4%, #FFFFFF 28%);
  98. border-radius: 16rpx;
  99. padding: 20rpx;
  100. height: 240rpx;
  101. box-sizing: border-box;
  102. &.hot-border {
  103. background: none;
  104. border: 2rpx solid #F3F3F3;
  105. }
  106. .hot-list {
  107. // 覆盖 up-scroll-list 的默认样式,实现两端对齐
  108. :deep(.u-scroll-list__scroll-view__content) {
  109. display: flex;
  110. justify-content: space-between;
  111. align-items: center;
  112. width: 100%;
  113. min-width: 100%;
  114. }
  115. .hot-panel {
  116. width: 100%;
  117. display: flex;
  118. .hot-item {
  119. // width: calc(50% - 10rpx);
  120. // width: calc(100% - 20rpx);
  121. display: flex;
  122. white-space: nowrap;
  123. flex-shrink: 0;
  124. .hot-img {
  125. flex: none;
  126. width: 116rpx;
  127. height: 116rpx;
  128. object-fit: cover;
  129. border-radius: 10rpx;
  130. }
  131. .item-info {
  132. padding-left: 10rpx;
  133. width: 200rpx;
  134. .info-text {
  135. color: #000000;
  136. font-size: 24rpx;
  137. }
  138. .info-price {
  139. padding-top: 10rpx;
  140. display: flex;
  141. align-items: baseline;
  142. justify-content: space-between;
  143. .price-text {
  144. color: #FF7700;
  145. font-size: 32rpx;
  146. .price-unit {
  147. font-size: 20rpx;
  148. }
  149. }
  150. .info-sold {
  151. font-size: 20rpx;
  152. color: #C4C4C4;
  153. }
  154. }
  155. }
  156. }
  157. .hot-item+.hot-item {
  158. margin-left: 20rpx;
  159. }
  160. }
  161. ::v-deep {
  162. .u-scroll-list__indicator {
  163. margin-top: 20rpx;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. </style>