hotComponent.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="hot-wrap">
  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 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. console.log('newVal', newVal)
  60. getHotList()
  61. })
  62. onMounted(() => {
  63. getHotList()
  64. })
  65. const getHotList = () => {
  66. HOME.fetchHotList({
  67. farmId: props.farmId
  68. }).then(({data}) => {
  69. console.log('data', data)
  70. hotList.value = data
  71. })
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .hot-title {
  76. display: flex;
  77. align-items: center;
  78. justify-content: space-between;
  79. padding-bottom: 20rpx;
  80. .title-l {
  81. font-family: 'PangMenZhengDao';
  82. font-size: 32rpx;
  83. .title-color {
  84. color: #F3C11D;
  85. }
  86. }
  87. .title-btn {
  88. color: rgba(0, 0, 0, 0.6);
  89. font-size: 24rpx;
  90. display: inline-flex;
  91. align-items: center;
  92. }
  93. }
  94. .hot-wrap {
  95. background: linear-gradient(#FFFFFF, rgba(255, 255, 255, 0));
  96. padding: 2rpx;
  97. border-radius: 16rpx;
  98. .hot-content {
  99. background: linear-gradient(#fff1c3 4%, #FFFFFF 28%);
  100. border-radius: 16rpx;
  101. padding: 20rpx;
  102. height: 240rpx;
  103. box-sizing: border-box;
  104. &.hot-border {
  105. background: none;
  106. border: 2rpx solid #F3F3F3;
  107. }
  108. .hot-list {
  109. .hot-panel {
  110. width: 100%;
  111. display: flex;
  112. .hot-item {
  113. // width: calc(50% - 10rpx);
  114. // width: calc(100% - 20rpx);
  115. display: flex;
  116. white-space: nowrap;
  117. .hot-img {
  118. flex: none;
  119. width: 116rpx;
  120. height: 116rpx;
  121. object-fit: cover;
  122. border-radius: 10rpx;
  123. }
  124. .item-info {
  125. padding-left: 10rpx;
  126. width: 200rpx;
  127. .info-text {
  128. color: #000000;
  129. font-size: 24rpx;
  130. }
  131. .info-price {
  132. padding-top: 10rpx;
  133. display: flex;
  134. align-items: baseline;
  135. justify-content: space-between;
  136. .price-text {
  137. color: #FF7700;
  138. font-size: 32rpx;
  139. .price-unit {
  140. font-size: 20rpx;
  141. }
  142. }
  143. .info-sold {
  144. font-size: 20rpx;
  145. color: #C4C4C4;
  146. }
  147. }
  148. }
  149. }
  150. .hot-item+.hot-item {
  151. margin-left: 20rpx;
  152. }
  153. }
  154. ::v-deep {
  155. .u-scroll-list__indicator {
  156. margin-top: 20rpx;
  157. }
  158. }
  159. }
  160. }
  161. }
  162. </style>