小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 lines
3.6 KiB

  1. <template>
  2. <!-- 今日必拼 -->
  3. <view class="group-goods pa20 mx20 mb10">
  4. <view class="title-box x-bc" @tap="jump('/pages/activity/GoodsGroup/index')">
  5. <text class="title">超值拼团</text>
  6. <view class="group-people x-f">
  7. <text class="tip">更多</text>
  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" duration="2000">
  13. <swiper-item v-for="(goods, index) in goodsList" :key="index" class="carousel-item">
  14. <view class="goods-list-box x-f">
  15. <block v-for="mgoods in goods" :key="mgoods.id">
  16. <sh-activity-goods :detail="mgoods" class="goods-item">
  17. <!-- <block slot="titleText">立减8.5</block> -->
  18. </sh-activity-goods>
  19. </block>
  20. </view>
  21. </swiper-item>
  22. </swiper>
  23. <view class="swiper-dots" v-if="goodsList.length > 1">
  24. <text :class="swiperCurrent === index ? 'dot-active' : 'dot'" v-for="(dot, index) in goodsList.length"
  25. :key="index"></text>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import shActivityGoods from './sh-activity-goods.vue';
  32. export default {
  33. name: 'shGroupon',
  34. components: {
  35. shActivityGoods
  36. },
  37. data() {
  38. return {
  39. goodsList: [],
  40. swiperCurrent: 0
  41. };
  42. },
  43. props: {
  44. detail: Array
  45. },
  46. computed: {},
  47. created() {},
  48. watch: {
  49. detail(next) {
  50. this.goodsList = this.sortData(next, 4);
  51. }
  52. },
  53. methods: {
  54. swiperChange(e) {
  55. this.swiperCurrent = e.detail.current;
  56. },
  57. // 数据分层
  58. sortData(oArr, length) {
  59. let arr = [];
  60. let minArr = [];
  61. oArr.forEach(c => {
  62. if (minArr.length === length) {
  63. minArr = [];
  64. }
  65. if (minArr.length === 0) {
  66. arr.push(minArr);
  67. }
  68. minArr.push(c);
  69. });
  70. return arr;
  71. },
  72. jump(path, query) {
  73. this.$yrouter.push({
  74. path,
  75. query,
  76. });
  77. },
  78. }
  79. };
  80. </script>
  81. <style lang="scss">
  82. .swiper-box,
  83. .carousel {
  84. width: 700rpx;
  85. height: 240upx;
  86. position: relative;
  87. border-radius: 20rpx;
  88. .carousel-item {
  89. width: 100%;
  90. height: 100%;
  91. // padding: 0 28upx;
  92. overflow: hidden;
  93. }
  94. .swiper-image {
  95. width: 100%;
  96. height: 100%;
  97. // border-radius: 10upx;
  98. background: #ccc;
  99. }
  100. }
  101. .swiper-dots {
  102. display: flex;
  103. position: absolute;
  104. left: 50%;
  105. transform: translateX(-50%);
  106. bottom: 0rpx;
  107. z-index: 66;
  108. .dot {
  109. width: 45rpx;
  110. height: 3rpx;
  111. background: #eee;
  112. border-radius: 50%;
  113. margin-right: 10rpx;
  114. }
  115. .dot-active {
  116. width: 45rpx;
  117. height: 3rpx;
  118. background: #a8700d;
  119. border-radius: 50%;
  120. margin-right: 10rpx;
  121. }
  122. }
  123. // 今日必拼+限时抢购
  124. .group-goods {
  125. background: #fff;
  126. border-radius: 20rpx;
  127. overflow: hidden;
  128. .title-box {
  129. padding-bottom: 20rpx;
  130. .title {
  131. font-size: 32rpx;
  132. font-weight: bold;
  133. }
  134. .group-people {
  135. .time-box {
  136. font-size: 26rpx;
  137. color: #edbf62;
  138. .count-text-box {
  139. width: 30rpx;
  140. height: 34rpx;
  141. background: #edbf62;
  142. text-align: center;
  143. line-height: 34rpx;
  144. font-size: 24rpx;
  145. border-radius: 6rpx;
  146. color: rgba(#fff, 0.9);
  147. margin: 0 8rpx;
  148. }
  149. }
  150. .head-box {
  151. .head-img {
  152. width: 40rpx;
  153. height: 40rpx;
  154. border-radius: 50%;
  155. background: #ccc;
  156. }
  157. }
  158. .tip {
  159. font-size: 28rpx;
  160. padding-left: 30rpx;
  161. color: #666;
  162. }
  163. .cuIcon-right {
  164. font-size: 30rpx;
  165. line-height: 28rpx;
  166. color: #666;
  167. }
  168. }
  169. }
  170. .goods-box {
  171. .goods-item {
  172. margin-right: 22rpx;
  173. &:nth-child(4n) {
  174. margin-right: 0;
  175. }
  176. }
  177. }
  178. }
  179. </style>