sh-menu.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class="">
  3. <!-- 产品分类导航 -->
  4. <view class="menu-category-box " v-if="carousel && flag == 0" :style="detail.length <= menu ? `height:150rpx` : `height:300rpx`">
  5. <swiper
  6. class="menu-swiper-box"
  7. :style="detail.length <= menu ? `height:150rpx` : `height:300rpx`"
  8. @change="onSwiper"
  9. circular
  10. :autoplay="false"
  11. :interval="3000"
  12. :duration="1000"
  13. >
  14. <swiper-item class="menu-swiper-item" v-for="(itemList, index) in carousel" :key="index" :style="detail.length <= menu ? `height:150rpx` : `height:300rpx`">
  15. <view class="menu-tab-box dffs">
  16. <!-- :url="item.path + '?id=' + item.id" -->
  17. <view @click="navTo(item)" class="tab-list dffd y-f" :style="{ width: 690 / menu + 'rpx' }" v-for="(item, ind) in itemList" :key="ind">
  18. <image class="tab-img shopro-selector-circular" :style="{ width: imgW + 'rpx', height: imgW + 'rpx' }" :src="item.logo"></image>
  19. <text class="shopro-selector-rect oneelli">{{ item.name }}</text>
  20. </view>
  21. </view>
  22. </swiper-item>
  23. </swiper>
  24. <view class="menu-category-dots" v-if="carousel.length > 1">
  25. <text :class="categoryCurrent === index ? 'category-dot-active' : 'category-dot'" v-for="(dot, index) in carousel.length" :key="index"></text>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. components: {},
  33. data() {
  34. return {
  35. categoryCurrent: 0 ,//分类轮播下标
  36. };
  37. },
  38. props: {
  39. detail: {
  40. type: Array,
  41. default: []
  42. },
  43. menu: {
  44. default: 5
  45. },
  46. imgW: {
  47. type: Number,
  48. default: 88
  49. },
  50. flag: {
  51. type: Number,
  52. default: 0
  53. }
  54. },
  55. computed: {
  56. carousel() {
  57. console.log('普通导航: ',this.detail);
  58. if (this.detail) {
  59. let data = this.sortData(this.detail, this.menu * 2);
  60. return data;
  61. }
  62. },
  63. },
  64. created() {},
  65. methods: {
  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. // 轮播
  82. onSwiper(e) {
  83. this.categoryCurrent = e.detail.current;
  84. },
  85. navTo(item) {
  86. //普通导航跳转方式
  87. if(item.type == 1)
  88. {
  89. if (item.url == 'notic') {
  90. uni.navigateTo({
  91. url: `/pages/news/notice?type=2&title=${item.name}`
  92. });
  93. } else if (item.url == 'vedio') {
  94. uni.navigateTo({
  95. url: `/pages/index/video/video?cat=`+item.catid
  96. });
  97. } else if (item.url == 'vacation') {
  98. uni.navigateTo({
  99. url: `/pagesA/catList/catList?cat=item.catid&title=${item.name}`
  100. });
  101. } else {
  102. uni.navigateTo({
  103. url: `/pages/index/classList?flag=2&nav_id=${item.id}&title=${item.name}`
  104. });
  105. }
  106. }
  107. //独立导航跳转方式
  108. if(item.type == 2)
  109. {
  110. uni.navigateTo({
  111. url: `/pages/index/dlClassList?flag=2&nav_id=${item.id}&title=${item.name}`
  112. });
  113. }
  114. },
  115. clickthis() {
  116. // console.log(12);
  117. }
  118. }
  119. };
  120. </script>
  121. <style lang="scss">
  122. // 产品分类
  123. .menu-category-box {
  124. width: 100%;
  125. padding: 10rpx 0rpx 0 0rpx;
  126. }
  127. .menu-category-box,
  128. .menu-swiper-box {
  129. width: 100%;
  130. position: relative;
  131. .menu-swiper-item {
  132. height: 100%;
  133. width: 100%;
  134. }
  135. .menu-tab-box {
  136. display: flex;
  137. flex-direction: row;
  138. flex-wrap: wrap;
  139. .tab-list {
  140. justify-content: flex-start;
  141. align-items: center;
  142. width: 20%;
  143. font-size: 24rpx;
  144. font-family: PingFang SC;
  145. font-weight: 500;
  146. color: rgba(51, 51, 51, 1);
  147. padding-bottom: 25rpx;
  148. .tab-img {
  149. width: 100%;
  150. border-radius: 50%;
  151. margin-bottom: 10rpx;
  152. padding: 10rpx;
  153. }
  154. text {
  155. width: 100%;
  156. text-align: center;
  157. font-size: 24rpx;
  158. }
  159. }
  160. }
  161. .menu-category-dots {
  162. display: flex;
  163. position: absolute;
  164. left: 50%;
  165. transform: translateX(-50%);
  166. bottom: 0rpx;
  167. .category-dot {
  168. width: 25rpx;
  169. height: 8rpx;
  170. background: #eeeeee;
  171. border-radius: 50%;
  172. }
  173. .category-dot-active {
  174. width: 25rpx;
  175. height: 8rpx;
  176. background: $promain;
  177. border-radius: 50%;
  178. }
  179. }
  180. }
  181. </style>