RouterBanner.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. @click="showLink(index)"
  11. :class="{ selectStyle: isShowLink[index] }"
  12. @mouseenter="enterDiv(index)"
  13. @mouseleave="leaveDiv(index)"
  14. >
  15. <div class="first_level" @click="getNavTitle(routerObj)">
  16. <router-link :to="routerObj.path" tag="li" class="title">
  17. <div
  18. class="icon"
  19. :style="{ backgroundImage: 'url(' + routerObj.img1 + ')' }"
  20. v-if="!isShowLink[index] && 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="!isShowLink[index]" />
  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="isShowLink[index]">
  39. <div
  40. v-for="(list, index) in routerObj.list"
  41. :key="index"
  42. @click="getNavTitle(routerObj, list)"
  43. >
  44. <router-link
  45. :to="list.path"
  46. tag="li"
  47. :class="{ blueColor: list.path === routerPath }"
  48. >- {{ list.title }}
  49. </router-link>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. export default {
  58. props: {
  59. isManufacturer: {
  60. type: String,
  61. default: "distributor",
  62. },
  63. },
  64. data() {
  65. return {
  66. isShowLink: [true, true, false, false, false], // 五个大模块
  67. isHover: [true, true, true, true, true],
  68. routerList: [
  69. {
  70. title: "数据管理", // 厂商数据管理
  71. path: "/uploadInfor", // 默认展示的路由
  72. img1: require("../img/edit-manage1.png"), // 没点击的背景图
  73. img2: require("../img/edit-manage2.png"), // 点击了的背景图
  74. role: "manufacturer", // 厂商和经销商都有权限
  75. list: [
  76. {
  77. title: "上传记录",
  78. path: "/uploadRecord",
  79. },
  80. {
  81. title: "链接上传", // 厂商的链接上传
  82. path: "/uploadLinks",
  83. },
  84. {
  85. title: "上传资料",
  86. path: "/uploadInfor",
  87. },
  88. ],
  89. },
  90. {
  91. title: "数据管理", // 进销商数据管理
  92. path: "/inforList", // 默认展示的路由
  93. img1: require("../img/edit-manage1.png"), // 没点击的背景图
  94. img2: require("../img/edit-manage2.png"), // 点击了的背景图
  95. role: "distributor", // 厂商和经销商都有权限
  96. list: [
  97. {
  98. title: "资料下载",
  99. path: "/inforList",
  100. },
  101. {
  102. title: "传播反馈", // 经销商链接上传
  103. path: "/uploadLink",
  104. },
  105. ],
  106. },
  107. {
  108. title: "账号管理", // 厂商的账号管理
  109. path: "/accountIndex",
  110. img1: require("../img/User-Settings1.png"),
  111. img2: require("../img/User-Settings2.png"),
  112. list: [],
  113. role: "manufacturer", // 厂商有权限
  114. },
  115. {
  116. title: "账号管理",
  117. path: "/accountManage",
  118. img1: require("../img/User-Settings1.png"),
  119. img2: require("../img/User-Settings2.png"),
  120. list: [],
  121. role: "distributor", // 经销商有权限
  122. },
  123. {
  124. title: "参数设置",
  125. path: "/parameterIndex",
  126. img1: require("../img/Setting1.png"),
  127. img2: require("../img/Setting2.png"),
  128. list: [],
  129. role: "manufacturer", // 只有厂商有权限
  130. },
  131. ],
  132. };
  133. },
  134. computed: {
  135. routerPath: function () {
  136. return this.$route.path;
  137. },
  138. },
  139. methods: {
  140. getNavTitle: function (navTitle, list) {
  141. // 点击路由的时候,修改导航栏、
  142. if (list) {
  143. const nav = [
  144. {
  145. title: navTitle.title,
  146. url: navTitle.path,
  147. },
  148. {
  149. title: list.title,
  150. url: list.path,
  151. },
  152. ];
  153. this.$emit("change_nav", nav);
  154. } else {
  155. const nav = [
  156. {
  157. title: navTitle.title,
  158. url: navTitle.path,
  159. },
  160. ];
  161. this.$emit("change_nav", nav);
  162. }
  163. },
  164. // 展开、关闭router栏
  165. showLink: function (i) {
  166. let flag = this.isShowLink[i];
  167. this.isShowLink = [false, false, false, false, false];
  168. this.isShowLink.splice(i, 1, !flag);
  169. },
  170. // 鼠标移入变白色背景
  171. enterDiv: function (i) {
  172. this.isHover.splice(i, 1, false);
  173. },
  174. // 鼠标移出变蓝色背景
  175. leaveDiv: function (i) {
  176. this.isHover.splice(i, 1, true);
  177. },
  178. },
  179. mounted() {},
  180. };
  181. </script>
  182. <style scoped lang="less">
  183. .router_banner {
  184. width: 100%;
  185. border-top: 10px solid #eee;
  186. .router_management {
  187. width: 100%;
  188. .first_level {
  189. display: flex;
  190. height: 35px;
  191. align-items: center;
  192. &:hover {
  193. cursor: pointer;
  194. background-color: rgb(0, 86, 160);
  195. color: #fff;
  196. .title {
  197. color: #fff;
  198. }
  199. p {
  200. color: #fff;
  201. }
  202. }
  203. .title {
  204. font-size: 14px;
  205. display: flex;
  206. padding: 0 10px;
  207. justify-content: space-around;
  208. .icon {
  209. width: 26px;
  210. height: 26px;
  211. background-size: contain;
  212. background-repeat: no-repeat;
  213. img {
  214. width: 26px;
  215. height: 26px;
  216. }
  217. }
  218. .switch {
  219. width: 11px;
  220. height: 11px;
  221. margin-left: 20px;
  222. img {
  223. width: 11px;
  224. height: 11px;
  225. transform: translateY(-5px);
  226. }
  227. }
  228. p {
  229. font-size: 14px;
  230. margin-left: 9px;
  231. }
  232. }
  233. li {
  234. width: 100%;
  235. height: 100%;
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. }
  240. }
  241. .second_level {
  242. li {
  243. width: 100%;
  244. height: 38px;
  245. line-height: 38px;
  246. text-align: center;
  247. p {
  248. &:hover {
  249. cursor: pointer;
  250. color: rgb(0, 86, 160);
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. // 选中变色
  258. /* .blueColor {
  259. color: #0056a0;
  260. } */
  261. .router-link-active {
  262. color: #0056a0;
  263. }
  264. .selectStyle {
  265. background-color: rgb(0, 86, 160);
  266. color: #fff;
  267. .title {
  268. color: #fff;
  269. }
  270. p {
  271. color: #fff;
  272. }
  273. }
  274. </style>