RouterBanner.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="router_banner">
  3. <div
  4. class="router_management"
  5. v-for="(routerObj, index) in routerList"
  6. :key="index"
  7. >
  8. <div v-if="routerObj.role === isManufacturer">
  9. <!-- <div> -->
  10. <div
  11. :class="{ selectStyle: routerObj.path === routerPath }"
  12. @mouseenter="enterDiv(index)"
  13. @mouseleave="leaveDiv(index)"
  14. >
  15. <div class="first_level">
  16. <router-link :to="routerObj.path" tag="li" class="title">
  17. <div
  18. class="icon"
  19. :style="{ backgroundImage: 'url(' + routerObj.img1 + ')' }"
  20. v-if="routerObj.path !== routerPath && isHover[index]"
  21. ></div>
  22. <div
  23. class="icon"
  24. :style="{ backgroundImage: 'url(' + routerObj.img2 + ')' }"
  25. v-else
  26. ></div>
  27. <p>
  28. {{ routerObj.title }}
  29. </p>
  30. <div class="switch">
  31. <img src="../img/switch2.png" v-if="routerObj.path !== routerPath" />
  32. <img src="../img/switch1.png" v-else />
  33. </div>
  34. </router-link>
  35. </div>
  36. </div>
  37. <!-- 模块的子路由 -->
  38. <div class="second_level" v-show="(routerObj.pathList || []).indexOf(routerPath) > -1">
  39. <div
  40. v-for="(list, index) in routerObj.list"
  41. :key="index"
  42. >
  43. <router-link
  44. :to="list.path"
  45. tag="li"
  46. :class="{ blueColor: list.path === routerPath }"
  47. >- {{ list.title }}
  48. </router-link>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. import { ROUTER } from '../config/router';
  57. export default {
  58. props: {
  59. isManufacturer: {
  60. type: String,
  61. default: "distributor",
  62. },
  63. },
  64. data() {
  65. return {
  66. isHover: [true, true, true, true, true],
  67. routerList: ROUTER
  68. };
  69. },
  70. computed: {
  71. routerPath: function () {
  72. return this.$route.path;
  73. },
  74. },
  75. // watch: {
  76. // routerPath: function(newpath, oldPath) {
  77. // console.log(newpath, 'new');
  78. // console.log(oldPath);
  79. // console.log()
  80. // }
  81. // },
  82. methods: {
  83. enterDiv: function (i) {
  84. this.isHover.splice(i, 1, false);
  85. },
  86. // 鼠标移出变蓝色背景
  87. leaveDiv: function (i) {
  88. this.isHover.splice(i, 1, true);
  89. },
  90. },
  91. mounted() {},
  92. };
  93. </script>
  94. <style scoped lang="less">
  95. .router_banner {
  96. width: 100%;
  97. border-top: 10px solid #eee;
  98. .router_management {
  99. width: 100%;
  100. .first_level {
  101. display: flex;
  102. height: 35px;
  103. align-items: center;
  104. &:hover {
  105. cursor: pointer;
  106. background-color: rgb(0, 86, 160);
  107. color: #fff;
  108. .title {
  109. color: #fff;
  110. }
  111. p {
  112. color: #fff;
  113. }
  114. }
  115. .title {
  116. font-size: 14px;
  117. display: flex;
  118. padding: 0 10px;
  119. justify-content: space-around;
  120. .icon {
  121. width: 26px;
  122. height: 26px;
  123. background-size: contain;
  124. background-repeat: no-repeat;
  125. img {
  126. width: 26px;
  127. height: 26px;
  128. }
  129. }
  130. .switch {
  131. width: 11px;
  132. height: 11px;
  133. margin-left: 20px;
  134. img {
  135. width: 11px;
  136. height: 11px;
  137. transform: translateY(-5px);
  138. }
  139. }
  140. p {
  141. font-size: 14px;
  142. margin-left: 9px;
  143. }
  144. }
  145. li {
  146. width: 100%;
  147. height: 100%;
  148. display: flex;
  149. justify-content: center;
  150. align-items: center;
  151. }
  152. }
  153. .second_level {
  154. li {
  155. width: 100%;
  156. height: 38px;
  157. line-height: 38px;
  158. text-align: center;
  159. &:hover {
  160. cursor: pointer;
  161. color: rgb(0, 86, 160);
  162. }
  163. }
  164. }
  165. }
  166. }
  167. // 选中变色
  168. /* .blueColor {
  169. color: #0056a0;
  170. } */
  171. .router-link-active {
  172. color: #0056a0;
  173. }
  174. .selectStyle {
  175. background-color: rgb(0, 86, 160);
  176. color: #fff;
  177. .title {
  178. color: #fff;
  179. }
  180. p {
  181. color: #fff;
  182. }
  183. }
  184. </style>