sider.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <el-aside style="width: 254px;">
  3. <div class="sidebar">
  4. <div class="side-logo">
  5. <img @click="$router.push({path:'/'})" src="../../static/image/logo.png" class="logo" />
  6. </div>
  7. <el-menu class="sidebar-el-menu" :default-active="$route.path" :collapse="collapse" background-color="#00152A" text-color="#bfcbd9" active-text-color="#20a0ff" router>
  8. <template v-for="item in items">
  9. <template v-if="item.children">
  10. <el-submenu :index="item.path" :key="item.path">
  11. <template slot="title">
  12. <!-- <i :class="[item.icon,'aliFamily']"></i> -->
  13. <img v-if="item.icon" class="side-bar-icon" :src="item.icon" />
  14. <span slot="title">{{ item.title }}</span>
  15. </template>
  16. <template v-for="subItem in item.children">
  17. <el-submenu v-if="subItem.children" :index="subItem.path" :key="subItem.path">
  18. <template slot="title">{{ subItem.title }}</template>
  19. <el-menu-item v-for="(threeItem,i) in subItem.children" :key="i" :index="threeItem.path">
  20. {{ threeItem.title }}</el-menu-item>
  21. </el-submenu>
  22. <el-menu-item v-else :index="subItem.path" :key="subItem.path">{{ subItem.title }}</el-menu-item>
  23. </template>
  24. </el-submenu>
  25. </template>
  26. <template v-else>
  27. <el-menu-item :index="item.path" :key="item.path">
  28. <!-- <i :class="[item.icon,'aliFamily']"></i> -->
  29. <img :src="item.icon" class="side-bar-icon" v-if="item.icon" />
  30. <span slot="title">{{ item.title }}</span>
  31. </el-menu-item>
  32. </template>
  33. </template>
  34. </el-menu>
  35. </div>
  36. </el-aside>
  37. </template>
  38. <script>
  39. import bus from "../common/bus";
  40. import router from "../router/index.js";
  41. export default {
  42. data() {
  43. return {
  44. collapse: false,
  45. //items: []
  46. items: [
  47. {
  48. path: "/",
  49. name: "home",
  50. title: "一键发单",
  51. icon: require("../../static/image/order-icon.png"),
  52. children: [
  53. {
  54. path: "/",
  55. name: "HomeIndex",
  56. title: "订单列表",
  57. },
  58. {
  59. path: "/orderSearch",
  60. name: "orderSearch",
  61. title: "订单查询",
  62. },
  63. {
  64. path: "/manualCreate",
  65. name: "manualCreate",
  66. title: "手动发单",
  67. },
  68. ],
  69. },
  70. {
  71. path: "/shopInfo",
  72. name: "shopInfo",
  73. title: "商户信息",
  74. icon: require("../../static/image/shop-icon.png"),
  75. children: [
  76. {
  77. path: "/shopInfo/shopInfos",
  78. name: "shopInfos",
  79. title: "门店管理",
  80. },
  81. {
  82. path: "/shopInfo/shopAccount",
  83. name: "shopInfos",
  84. title: "我的账户",
  85. },
  86. ],
  87. },
  88. {
  89. path: "/setUp",
  90. name: "setUp",
  91. title: "设置",
  92. icon: require("../../static/image/setting-icon.png"),
  93. children: [
  94. {
  95. path: "/setUp/set",
  96. name: "set",
  97. title: "外卖设置",
  98. },
  99. {
  100. path: "/setUp/addressManagement",
  101. name: "addressManagement",
  102. title: "常用地址",
  103. },
  104. {
  105. path: "/setUp/pictureManagement",
  106. name: "pictureManagement",
  107. title: "商品管理",
  108. },
  109. ],
  110. },
  111. {
  112. path: "/help",
  113. name: "help",
  114. title: "帮助中心",
  115. icon: require("../../static/image/help-icon.png"),
  116. },
  117. {
  118. path: '/download',
  119. name: 'download',
  120. title: '下载中心',
  121. icon: require("../../static/image/download-icon.png"),
  122. },
  123. {
  124. path: "/about",
  125. name: "about",
  126. title: "关于我们",
  127. icon: require("../../static/image/about-icon.png"),
  128. },
  129. ],
  130. };
  131. },
  132. created() {
  133. // console.log(router.options.routes);
  134. //this.items = [...router.options.routes];
  135. // 通过 Event Bus 进行组件间通信,来折叠侧边栏
  136. bus.$on("collapse", (msg) => {
  137. this.collapse = msg;
  138. bus.$emit("collapse-content", msg);
  139. });
  140. },
  141. };
  142. </script>
  143. <style lang='scss' scoped='scoped'>
  144. /deep/ .el-submenu .el-menu-item {
  145. padding-left: 76px !important;
  146. }
  147. /deep/ .el-menu-item.is-active {
  148. color: #fff !important;
  149. background-color: #0c2b47 !important;
  150. border-right: 6px solid #009cff;
  151. }
  152. .sidebar {
  153. display: block;
  154. position: absolute;
  155. left: 0;
  156. top: 0;
  157. bottom: 0;
  158. box-sizing: border-box;
  159. padding-top: 80px;
  160. }
  161. .side-logo {
  162. width: 100%;
  163. height: 80px;
  164. box-sizing: border-box;
  165. padding-top: 18px;
  166. position: absolute;
  167. top: 0;
  168. left: 0;
  169. z-index: 400;
  170. background-color: #fff;
  171. font-size: 0;
  172. padding-left: 32px;
  173. cursor: pointer;
  174. }
  175. .logo {
  176. width: 204px;
  177. height: 44px;
  178. }
  179. .side-bar-icon {
  180. width: 21px;
  181. height: 21px;
  182. margin-right: 18px;
  183. margin-left: 14px;
  184. }
  185. .aliFamily {
  186. font-size: 24px;
  187. margin-right: 10px;
  188. }
  189. .sidebar::-webkit-scrollbar {
  190. width: 0;
  191. }
  192. .sidebar-el-menu:not(.el-menu--collapse) {
  193. width: 254px;
  194. box-sizing: border-box;
  195. }
  196. .sidebar > ul {
  197. height: 100%;
  198. }
  199. </style>