Menu.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <!-- 产品分类导航 -->
  3. <view class="menu-category-box" v-if="carousel">
  4. <!-- mb20 -->
  5. <!-- :style="list.length <= menu ? `height:200rpx` : `height:360rpx`" -->
  6. <swiper class="menu-swiper-box" :style="list.length <= menu ? `height:160rpx` : `height:320rpx`"
  7. @change="onSwiper" circular :autoplay="false" :interval="3000" :duration="1000">
  8. <swiper-item class="menu-swiper-item" v-for="(itemList, index) in carousel" :key="index"
  9. :style="list.length <= menu ? `height:200rpx` : `height:340rpx`">
  10. <view class="menu-tab-box">
  11. <view v-for="item in itemList">
  12. <view class="tab-list y-f" :style="{ width: 710 / menu + 'rpx' }" :key="item.name"
  13. @tap="routerTo(item)">
  14. <image class="tab-img Shop-selector-circular"
  15. :style="{ width: imgW + 'rpx', height: imgW + 'rpx' }" :src="item.pic"></image>
  16. <text class="Shop-selector-rect">{{ item.name }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. <view class="menu-category-dots" v-if="carousel.length > 1">
  23. <text :class="categoryCurrent === index ? 'category-dot-active' : 'category-dot'"
  24. v-for="(dot, index) in carousel.length" :key="index"></text>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. components: {},
  31. data() {
  32. return {
  33. categoryCurrent: 0 //分类轮播下标
  34. };
  35. },
  36. props: {
  37. list: {
  38. type: Array,
  39. default: []
  40. },
  41. menu: {
  42. default: 5
  43. },
  44. imgW: {
  45. type: Number,
  46. default: 100
  47. }
  48. },
  49. computed: {
  50. carousel() {
  51. if (this.list) {
  52. let list = this.sortData(this.list, this.menu * 2);
  53. return list;
  54. }
  55. }
  56. },
  57. created() {},
  58. methods: {
  59. // 数据分层
  60. sortData(oArr, length) {
  61. let arr = [];
  62. let minArr = [];
  63. oArr.forEach(c => {
  64. if (minArr.length === length) {
  65. minArr = [];
  66. }
  67. if (minArr.length === 0) {
  68. arr.push(minArr);
  69. }
  70. minArr.push(c);
  71. });
  72. return arr;
  73. },
  74. // 轮播
  75. onSwiper(e) {
  76. this.categoryCurrent = e.detail.current;
  77. },
  78. // 路由跳转
  79. routerTo(item) {
  80. // const token = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOjE1OTcxNTUzMDAwOTAwODUzNzgsImFjY291bnQiOiIxNTE0MTE1NTQ3NyIsInV1aWQiOiIyYjMxN2MzZC04OGMwLTQxZmEtOTFlNi00YTQ1ZDQxYzUwNGYiLCJyZW1lbWJlck1lIjp0cnVlLCJleHBpcmF0aW9uRGF0ZSI6MTY3ODA5MDE1NDYxMywiY2FUb2tlbiI6bnVsbCwib3RoZXJzIjpudWxsLCJzdWIiOiIxNTk3MTU1MzAwMDkwMDg1Mzc4IiwiaWF0IjoxNjc2MzM3MTIxLCJleHAiOjE2NzgwOTAxNTR9._b6LSaJ6gRKgR0rbwZh61K9F0DKJ4w3OjIo_yb2VfH7ynzX99RPod6MYpFnO0Naehve2AbMHd5vyNKsHkj7Oew"
  81. if (item.name == "预约洗车") {
  82. this.$yrouter.push({ path: "/pages/preCarWash/index" });
  83. }else if (item.name == "维修保养") {
  84. this.$yrouter.push({ path: "/pages/maintenance/index" });
  85. // this.$yrouter.push({ path: "/pages/maintenance/index?token="+token });
  86. }else if (item.name == "汽车商城") {
  87. this.$yrouter.push({ path: "/pages/preCarWash/washOrder/index" });
  88. }else if (item.name == "租车商城") {
  89. this.$yrouter.push({ path: "/pages/maintenance/maintainOrder/index" });
  90. }else if (item.name == "综合商城") {
  91. this.$yrouter.push({ path: "/pages/userMeal/index" });
  92. }else if (item.name == "登记过户") {
  93. this.$yrouter.push({ path: "/pages/maintenance/onlineReservation/index" });
  94. }
  95. }
  96. }
  97. };
  98. </script>
  99. <style lang="scss">
  100. button::after {
  101. border: none;
  102. }
  103. button {
  104. background-color: #fff;
  105. }
  106. // 产品分类
  107. .y-f {
  108. display: -webkit-box;
  109. display: -webkit-flex;
  110. display: flex;
  111. -webkit-box-orient: vertical;
  112. -webkit-box-direction: normal;
  113. -webkit-flex-direction: column;
  114. flex-direction: column;
  115. -webkit-box-align: center;
  116. -webkit-align-items: center;
  117. align-items: center;
  118. }
  119. .menu-category-box {
  120. // padding: 40rpx 30rpx 0 30rpx;
  121. padding: 20rpx 0rpx 0rpx;
  122. background: #fff !important;
  123. box-sizing: border-box;
  124. // border-radius: 10rpx;
  125. overflow: hidden;
  126. }
  127. .menu-category-box,
  128. .menu-swiper-box {
  129. position: relative;
  130. background: #fff;
  131. .menu-swiper-item {
  132. background: #fff;
  133. height: 100%;
  134. width: 100%;
  135. }
  136. .menu-tab-box {
  137. display: flex;
  138. flex-wrap: wrap;
  139. justify-content: space-around;
  140. .tab-list {
  141. font-size: 23rpx;
  142. font-family: PingFang SC;
  143. font-weight: 500;
  144. color: rgba(51, 51, 51, 1);
  145. padding-bottom: 30rpx;
  146. line-height: 30rpx;
  147. text {
  148. width: max-content;
  149. }
  150. .tab-img {
  151. border-radius: 25rpx;
  152. }
  153. }
  154. }
  155. .menu-category-dots {
  156. display: flex;
  157. position: absolute;
  158. left: 50%;
  159. transform: translateX(-50%);
  160. bottom: 20rpx;
  161. .category-dot {
  162. width: 40rpx;
  163. height: 3rpx;
  164. background: #eeeeee;
  165. margin-right: 10rpx;
  166. }
  167. .category-dot-active {
  168. width: 40rpx;
  169. height: 3rpx;
  170. background: #a8700d;
  171. margin-right: 10rpx;
  172. }
  173. }
  174. }
  175. </style>