NewProduct.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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">
  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,
  103. .carousel {
  104. width: 700rpx;
  105. height: 240upx;
  106. position: relative;
  107. border-radius: 20rpx;
  108. .carousel-item {
  109. width: 100%;
  110. height: 100%;
  111. // padding: 0 28upx;
  112. overflow: hidden;
  113. }
  114. .swiper-image {
  115. width: 100%;
  116. height: 100%;
  117. // border-radius: 10upx;
  118. background: #ccc;
  119. }
  120. }
  121. .swiper-dots {
  122. display: flex;
  123. position: absolute;
  124. left: 50%;
  125. transform: translateX(-50%);
  126. bottom: 0rpx;
  127. z-index: 66;
  128. .dot {
  129. width: 45rpx;
  130. height: 3rpx;
  131. background: #eee;
  132. border-radius: 50%;
  133. margin-right: 10rpx;
  134. }
  135. .dot-active {
  136. width: 45rpx;
  137. height: 3rpx;
  138. background: #a8700d;
  139. border-radius: 50%;
  140. margin-right: 10rpx;
  141. }
  142. }
  143. // 今日必拼+限时抢购
  144. .group-goods {
  145. background: #fff;
  146. border-radius: 20rpx;
  147. overflow: hidden;
  148. .title-box {
  149. padding-bottom: 20rpx;
  150. .title {
  151. font-size: 32rpx;
  152. font-weight: bold;
  153. }
  154. .group-people {
  155. .time-box {
  156. font-size: 26rpx;
  157. color: #edbf62;
  158. .count-text-box {
  159. width: 30rpx;
  160. height: 34rpx;
  161. background: #edbf62;
  162. text-align: center;
  163. line-height: 34rpx;
  164. font-size: 24rpx;
  165. border-radius: 6rpx;
  166. color: rgba(#fff, 0.9);
  167. margin: 0 8rpx;
  168. }
  169. }
  170. .head-box {
  171. .head-img {
  172. width: 40rpx;
  173. height: 40rpx;
  174. border-radius: 50%;
  175. background: #ccc;
  176. }
  177. }
  178. .tip {
  179. font-size: 24rpx;
  180. padding-left: 30rpx;
  181. color: #999999;
  182. }
  183. .cuIcon-right {
  184. font-size: 30rpx;
  185. line-height: 28rpx;
  186. color: #666;
  187. }
  188. }
  189. }
  190. .goods-box {
  191. .goods-item {
  192. margin-right: 22rpx;
  193. &:nth-child(4n) {
  194. margin-right: 0;
  195. }
  196. }
  197. }
  198. .min-goods{
  199. margin-right: 22rpx;
  200. }
  201. }
  202. .min-goods {
  203. width: 152rpx;
  204. background: #fff;
  205. .img-box {
  206. width: 152rpx;
  207. height: 152rpx;
  208. overflow: hidden;
  209. position: relative;
  210. .tag {
  211. position: absolute;
  212. left: 0;
  213. bottom: 0rpx;
  214. z-index: 2;
  215. line-height: 35rpx;
  216. background: linear-gradient(132deg, rgba(243, 223, 177, 1), rgba(243, 223, 177, 1), rgba(236, 190, 96, 1));
  217. border-radius: 0px 18rpx 18rpx 0px;
  218. padding: 0 10rpx;
  219. font-size: 24rpx;
  220. font-family: PingFang SC;
  221. font-weight: bold;
  222. color: rgba(120, 79, 6, 1);
  223. }
  224. .img {
  225. width: 100%;
  226. background-color: #ccc;
  227. }
  228. }
  229. .price-box {
  230. width: 100%;
  231. margin-top: 10rpx;
  232. .seckill-current {
  233. font-size: 30rpx;
  234. font-weight: 500;
  235. color: rgba(225, 33, 43, 1);
  236. }
  237. .original {
  238. font-size: 20rpx;
  239. font-weight: 400;
  240. // text-decoration: line-through;
  241. color: rgba(153, 153, 153, 1);
  242. margin-left: 14rpx;
  243. }
  244. }
  245. .title {
  246. font-size: 26rpx;
  247. }
  248. }
  249. </style>