NewProduct.vue 7.3 KB

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