HotProduct.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="group-goods" v-if="detail.length>0">
  3. <view class="title-box x-bc">
  4. <view class="row">
  5. <image class="w40 h40 mr4" src="/static/images/hot.png"></image><text class="title"><text
  6. class="color-red">热门</text>榜单</text>
  7. </view>
  8. <view class="group-people x-f row" @tap="navTo('/pages/home/productList')">
  9. <text class="tip ">更多</text>
  10. <image class='w48 h48' src="/static/images/right.png"></image>
  11. <!-- <text class="cuIcon-right"></text> -->
  12. </view>
  13. </view>
  14. <view class="goods-box swiper-box x-f">
  15. <swiper class="carousel" circular @change="swiperChange" :autoplay="true" interval="10000" duration="2000">
  16. <swiper-item v-for="(goods, index) in goodsList" :key="index" class="carousel-item">
  17. <view class="goods-list-box x-f" style="align-items: flex-start;">
  18. <block v-for="mgoods in goods" :key="mgoods.productId">
  19. <view class="min-goods" @tap="showProduct(mgoods)">
  20. <view class="img-box">
  21. <!-- <view class="tag">hot</view> -->
  22. <image class="img" :src="mgoods.image" mode="widthFix"></image>
  23. </view>
  24. <view class="price-box">
  25. <view class="y-f">
  26. <text class="seckill-current">{{ mgoods.price }}</text>
  27. <!-- <text class="original">销量{{ mgoods.sales }}{{mgoods.unitName}}</text> -->
  28. </view>
  29. </view>
  30. <view class="title">
  31. <slot name="titleText"></slot>
  32. </view>
  33. </view>
  34. </block>
  35. </view>
  36. </swiper-item>
  37. </swiper>
  38. <view class="swiper-dots" v-if="goodsList.length > 1">
  39. <text :class="swiperCurrent === index ? 'dot-active' : 'dot'" v-for="(dot, index) in goodsList.length"
  40. :key="index"></text>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. name: "HotProduct",
  48. data() {
  49. return {
  50. goodsList: [],
  51. swiperCurrent: 0
  52. };
  53. },
  54. props: {
  55. detail: Array
  56. },
  57. computed: {},
  58. created() {},
  59. watch: {
  60. detail(next) {
  61. this.goodsList = this.sortData(next, 4);
  62. }
  63. },
  64. methods: {
  65. swiperChange(e) {
  66. this.swiperCurrent = e.detail.current;
  67. },
  68. // 数据分层
  69. sortData(oArr, length) {
  70. let arr = [];
  71. let minArr = [];
  72. oArr.forEach(c => {
  73. if (minArr.length === length) {
  74. minArr = [];
  75. }
  76. if (minArr.length === 0) {
  77. arr.push(minArr);
  78. }
  79. minArr.push(c);
  80. });
  81. return arr;
  82. },
  83. navTo(url) {
  84. uni.navigateTo({
  85. url: url
  86. })
  87. },
  88. showProduct(item) {
  89. uni.navigateTo({
  90. url: '/pages/shopping/productDetails?productId=' + item.productId
  91. })
  92. },
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .group-goods {
  98. position: relative;
  99. z-index: 1;
  100. background: #FFFFFF;
  101. border-radius: 16upx;
  102. margin-bottom: 20upx;
  103. margin-top: 20upx;
  104. // padding: 20upx;
  105. }
  106. .swiper-box,
  107. .carousel {
  108. width: 700rpx;
  109. height: 240upx;
  110. position: relative;
  111. border-radius: 20rpx;
  112. .carousel-item {
  113. width: 100%;
  114. height: 100%;
  115. // padding: 0 28upx;
  116. overflow: hidden;
  117. }
  118. .swiper-image {
  119. width: 100%;
  120. height: 100%;
  121. // border-radius: 10upx;
  122. background: #ccc;
  123. }
  124. }
  125. .swiper-dots {
  126. display: flex;
  127. position: absolute;
  128. left: 50%;
  129. transform: translateX(-50%);
  130. bottom: 0rpx;
  131. z-index: 66;
  132. .dot {
  133. width: 45rpx;
  134. height: 3rpx;
  135. background: #eee;
  136. border-radius: 50%;
  137. margin-right: 10rpx;
  138. }
  139. .dot-active {
  140. width: 45rpx;
  141. height: 3rpx;
  142. background: #a8700d;
  143. border-radius: 50%;
  144. margin-right: 10rpx;
  145. }
  146. }
  147. // 今日必拼+限时抢购
  148. .group-goods {
  149. background: #fff;
  150. border-radius: 20rpx;
  151. overflow: hidden;
  152. border-radius: 16rpx 16rpx 16rpx 16rpx;
  153. .title-box {
  154. padding-bottom: 20rpx;
  155. padding: 34rpx 32rpx;
  156. background: linear-gradient(180deg, #FFDCDC 0%, #FFFFFF 100%);
  157. .title {
  158. font-size: 32rpx;
  159. font-weight: bold;
  160. }
  161. .group-people {
  162. .time-box {
  163. font-size: 26rpx;
  164. color: #edbf62;
  165. .count-text-box {
  166. width: 30rpx;
  167. height: 34rpx;
  168. background: #edbf62;
  169. text-align: center;
  170. line-height: 34rpx;
  171. font-size: 24rpx;
  172. border-radius: 6rpx;
  173. color: rgba(#fff, 0.9);
  174. margin: 0 8rpx;
  175. }
  176. }
  177. .head-box {
  178. .head-img {
  179. width: 40rpx;
  180. height: 40rpx;
  181. border-radius: 50%;
  182. background: #ccc;
  183. }
  184. }
  185. .tip {
  186. font-size: 24rpx;
  187. padding-left: 30rpx;
  188. color: #999999;
  189. }
  190. .cuIcon-right {
  191. font-size: 30rpx;
  192. line-height: 28rpx;
  193. color: #666;
  194. }
  195. }
  196. }
  197. .goods-box {
  198. padding: 0 32rpx;
  199. .goods-item {
  200. margin-right: 22rpx;
  201. &:nth-child(4n) {
  202. margin-right: 0;
  203. }
  204. }
  205. }
  206. .min-goods {
  207. margin-right: 22rpx;
  208. }
  209. }
  210. .min-goods {
  211. width: 152rpx;
  212. background: #fff;
  213. .img-box {
  214. width: 152rpx;
  215. height: 152rpx;
  216. overflow: hidden;
  217. position: relative;
  218. .tag {
  219. position: absolute;
  220. left: 0;
  221. bottom: 0rpx;
  222. z-index: 2;
  223. line-height: 35rpx;
  224. background: linear-gradient(132deg, rgba(243, 223, 177, 1), rgba(243, 223, 177, 1), rgba(236, 190, 96, 1));
  225. border-radius: 0px 18rpx 18rpx 0px;
  226. padding: 0 10rpx;
  227. font-size: 24rpx;
  228. font-family: PingFang SC;
  229. font-weight: bold;
  230. color: rgba(120, 79, 6, 1);
  231. }
  232. .img {
  233. width: 100%;
  234. background-color: #ccc;
  235. }
  236. }
  237. .price-box {
  238. width: 100%;
  239. margin-top: 24rpx;
  240. .seckill-current {
  241. font-weight: 600;
  242. font-size: 26rpx;
  243. color: #FF5030;
  244. }
  245. .original {
  246. font-size: 20rpx;
  247. font-weight: 400;
  248. // text-decoration: line-through;
  249. color: rgba(153, 153, 153, 1);
  250. margin-left: 14rpx;
  251. }
  252. }
  253. .title {
  254. font-size: 26rpx;
  255. }
  256. }
  257. </style>