sx.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="content">
  3. <view class="hotgoods">
  4. <view class="hotgoods-item" v-for="item in firstList" :key="item.id" @click="navToDetailPage(item)">
  5. <view class="image-wrapper">
  6. <image class="image" :src="item.image" mode="scaleToFill"></image>
  7. </view>
  8. <view class="hotgoods-box">
  9. <view class="title clamp2">{{ item.store_name }}</view>
  10. <!-- <view class="titlee">{{ item.store_name }}</view> -->
  11. </view>
  12. <view class="hot-price">
  13. <view class="price">
  14. <text class="font-size-sm">¥</text>
  15. {{ item.price * 1 }}
  16. </view>
  17. <view class="yuanPrice">原价{{ item.price }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. loadIndexs,
  26. } from '@/api/index.js';
  27. export default {
  28. data() {
  29. return {
  30. firstList: []
  31. }
  32. },
  33. onLoad() {
  34. },
  35. onShow() {
  36. this.loadData()
  37. },
  38. onReachBottom() {
  39. },
  40. onReady() {
  41. },
  42. methods: {
  43. async loadData() {
  44. loadIndexs({})
  45. .then(({
  46. data
  47. }) => {
  48. let goods = data.info;
  49. data.info.firstList.forEach(e => {
  50. e.isVip = e.store_type ? "3" : "0"
  51. })
  52. this.firstList = data.info.firstList //首页商品
  53. })
  54. .catch(e => {
  55. });
  56. },
  57. //详情页
  58. navToDetailPage(item) {
  59. let id = item.id;
  60. uni.navigateTo({
  61. url: '/pages/product/product?id=' + id + '&isVip=' + 0
  62. });
  63. },
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. .hotgoods {
  69. margin-top: 38rpx;
  70. width: 100%;
  71. display: flex;
  72. flex-wrap: wrap;
  73. padding: 0 0 30rpx;
  74. .hotgoods-item {
  75. width: 44%;
  76. background: #FFFFFF;
  77. margin: 20rpx;
  78. box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
  79. border-radius: 10px;
  80. .image-wrapper {
  81. width: 100%;
  82. height: 330rpx;
  83. border-radius: 3px;
  84. overflow: hidden;
  85. position: relative;
  86. .image-bg {
  87. position: absolute;
  88. top: 0;
  89. left: 0;
  90. right: 0;
  91. bottom: 0;
  92. width: 100%;
  93. height: 100%;
  94. opacity: 1;
  95. border-radius: 12rpx 12rpx 0 0;
  96. z-index: 2;
  97. }
  98. .image {
  99. width: 100%;
  100. height: 100%;
  101. opacity: 1;
  102. border-radius: 12rpx 12rpx 0 0;
  103. }
  104. }
  105. .title {
  106. margin-top: 20rpx;
  107. font-size: 28rpx;
  108. font-family: PingFang SC;
  109. font-weight: 500;
  110. color: #333333;
  111. }
  112. .hotgoods-box {
  113. height: 75rpx;
  114. }
  115. .titlee {
  116. margin-left: 15rpx;
  117. font-size: 26rpx;
  118. font-weight: 500;
  119. color: #666666;
  120. white-space: nowrap;
  121. overflow: hidden;
  122. text-overflow: ellipsis;
  123. }
  124. .hot-price {
  125. display: flex;
  126. justify-content: flex-start;
  127. align-items: center;
  128. padding: 14rpx 0 30rpx;
  129. .hotPrice-box {
  130. width: 70rpx;
  131. height: 28rpx;
  132. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  133. border-radius: 5rpx;
  134. text-align: center;
  135. line-height: 28rpx;
  136. font-size: 20rpx;
  137. font-weight: 400;
  138. color: #ffffff;
  139. }
  140. .price {
  141. margin-left: 10rpx;
  142. font-size: 36rpx;
  143. color: #ff0000;
  144. font-weight: 500;
  145. }
  146. .yuanPrice {
  147. margin-left: 10rpx;
  148. font-size: 20rpx;
  149. font-family: PingFang SC;
  150. font-weight: 500;
  151. text-decoration: line-through;
  152. color: #999999;
  153. }
  154. .cart-icon {
  155. image {
  156. width: 44rpx;
  157. height: 44rpx;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. </style>