NewProduct.vue 6.0 KB

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