Navside.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <div :class="NavsideClass">
  3. <div class="logoContainer">
  4. <img src="../assets/img/nav/logo.png" height="40" width="180" />
  5. <i :class="[{ 'el-icon-s-unfold left_hide_icon': left_panel_state }, { 'el-icon-s-fold left_show_icon': !left_panel_state }]"
  6. @click="left_hide"></i>
  7. </div>
  8. <div class="userContainer">
  9. <!-- <img src="../assets/img/nav/head.png" height="51" width="51" /> -->
  10. <!-- <span>{{ ShopName }}</span>
  11. <em>{{ userLevelText }}</em>-->
  12. </div>
  13. <el-row :class="[{ 'shortnav': isCollapse }, { 'longNav': !isCollapse }]">
  14. <el-col :span="24">
  15. <el-menu :default-active="userLevelDeafult" class="el-menu-vertical-demo" @open="handleOpen"
  16. @close="handleClose" @select="handleSelect" :collapse="isCollapse" background-color="#ffffff"
  17. text-color="#777777" active-text-color="#fff"
  18. router>
  19. <el-menu-item :index="nav.clmid" :route="nav.clmurl" v-for="nav in navs"
  20. popper-append-to-body="false"
  21. v-if="nav.show == userLevel">
  22. <i :class="nav.icon"></i>
  23. <span slot="title">{{ nav.clmname }}</span>
  24. </el-menu-item>
  25. </el-menu>
  26. </el-col>
  27. </el-row>
  28. </div>
  29. </template>
  30. <script>
  31. import Navs from '../api/Navs';
  32. import {
  33. ManagerSelfQuery,
  34. ShopListQuery
  35. } from '../api/getApiRes.js'
  36. let qs = require('qs');
  37. export default {
  38. data() {
  39. return {
  40. isCollapse: document.body.clientWidth < 1366,
  41. left_panel_state: true,
  42. wildState: 0,
  43. navs: [],
  44. ShopName: '',
  45. userLevelText: '',
  46. NavsideClass: 'Navside',
  47. userLevel: 0,
  48. userLevelDeafult: "",
  49. }
  50. },
  51. // props: ['isCollapse'],
  52. mounted() {
  53. this.userLevelDeafult = this.$route.meta.clmid;
  54. this.getTableQuery();
  55. this.getManagerSelfQuery();
  56. if (document.body.clientWidth < 1024) {
  57. this.NavsideClass = 'NavsideShort'
  58. } else {
  59. this.NavsideClass = 'Navside'
  60. }
  61. },
  62. watch: {
  63. $route(to, from) {
  64. },
  65. },
  66. methods: {
  67. // 隐藏左侧和显示
  68. left_hide: function () {
  69. let that = this;
  70. that.left_panel_state = !that.left_panel_state;
  71. that.isCollapse = !that.isCollapse;
  72. this.$emit('lefthide');
  73. // if (!that.left_panel_state) {
  74. // this.$emit('left_hide_func');
  75. // } else {
  76. // this.$emit('right_hide_func');
  77. // }
  78. },
  79. handleSelect(i, s, t) {
  80. // this.$emit('TabsAdd', i);//触发事件
  81. },
  82. getTableQuery() {
  83. // 菜单
  84. this.navs = Navs;
  85. },
  86. getManagerSelfQuery() {
  87. let that = this;
  88. let param = {
  89. token: localStorage.token,
  90. };
  91. let postdata = qs.stringify(param);
  92. ManagerSelfQuery(postdata).then(res => {
  93. let json = res;
  94. if (json.Code == 0) {
  95. that.userLevelText = json.Rs.Role.Name;
  96. // 1 会员 2 系统 3 店铺 4 教练
  97. switch (parseInt(json.Rs.Role.Id)) {
  98. case 1:
  99. that.userLevel = 1;
  100. break;
  101. case 2:
  102. that.userLevel = 2;
  103. break;
  104. case 3:
  105. that.userLevel = 3;
  106. break;
  107. case 4:
  108. that.userLevel = 4;
  109. break;
  110. }
  111. localStorage.shopId = json.Rs.ShopId;
  112. this.panelSelect(json.Rs.ShopId);
  113. } else {
  114. if (json.Code == 1010) {
  115. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  116. that.$router.push({ path: '/login', query: { status: 1 } });
  117. return false
  118. } else {
  119. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  120. }
  121. }
  122. })
  123. },
  124. // 获取所属店铺
  125. panelSelect(ShopId) {
  126. let that = this;
  127. let param = {
  128. token: localStorage.token,
  129. };
  130. let postdata = qs.stringify(param);
  131. ShopListQuery(postdata).then(res => {
  132. let json = res;
  133. if (json.Code == 0) {
  134. json.Rs.map(function (item) {
  135. if (item.ShopID == ShopId) {
  136. that.ShopName = item.ShopName;
  137. }
  138. })
  139. } else {
  140. that.$message.error(json.Memo + ' 错误码:' + json.Code);
  141. }
  142. })
  143. },
  144. handleOpen(key, keyPath) {
  145. // console.log(key, keyPath);
  146. },
  147. handleClose(key, keyPath) {
  148. // console.log(key, keyPath);
  149. },
  150. },
  151. }
  152. </script>
  153. <style scoped>
  154. /*注释*/
  155. .Navside {
  156. width: 100%;
  157. /* height: 910px; */
  158. height: 100%;
  159. overflow: hidden;
  160. display: block;
  161. margin: 0 auto;
  162. overflow-y: scroll;
  163. /*overflow-y: hidden;*/
  164. background-color: #fff;
  165. z-index: 4444;
  166. }
  167. .NavsideShort {
  168. width: 100%;
  169. height: 100%;
  170. /*height: 710px;*/
  171. overflow: hidden;
  172. display: block;
  173. margin: 0 auto;
  174. /*overflow-y: scroll;*/
  175. overflow-y: scroll;
  176. background-color: #fff;
  177. z-index: 4444;
  178. }
  179. .Navside::-webkit-scrollbar {
  180. /*滚动条整体样式*/
  181. width: 3px;
  182. /*高宽分别对应横竖滚动条的尺寸*/
  183. height: 1px;
  184. }
  185. .Navside::-webkit-scrollbar-thumb {
  186. /*滚动条里面小方块*/
  187. border-radius: 3px;
  188. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  189. background: #f5f5f5;
  190. }
  191. .Navside::-webkit-scrollbar-track {
  192. /*滚动条里面轨道*/
  193. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  194. border-radius: 3px;
  195. background: #f5f5f5;
  196. }
  197. .NavsideShort::-webkit-scrollbar {
  198. /*滚动条整体样式*/
  199. width: 3px;
  200. /*高宽分别对应横竖滚动条的尺寸*/
  201. height: 1px;
  202. }
  203. .NavsideShort::-webkit-scrollbar-thumb {
  204. /*滚动条里面小方块*/
  205. border-radius: 3px;
  206. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  207. background: #f5f5f5;
  208. }
  209. .NavsideShort::-webkit-scrollbar-track {
  210. /*滚动条里面轨道*/
  211. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  212. border-radius: 3px;
  213. background: #f5f5f5;
  214. }
  215. .logoContainer {
  216. width: 256px;
  217. height: 72px;
  218. overflow: hidden;
  219. display: block;
  220. margin: 0 auto;
  221. background: #3799ff;
  222. }
  223. .logoContainer img {
  224. width: 100%;
  225. height: 100%;
  226. overflow: hidden;
  227. display: block;
  228. margin: 0 auto;
  229. margin-top: 1px;
  230. }
  231. .userContainer {
  232. width: 100%;
  233. overflow: hidden;
  234. display: block;
  235. margin: 0 auto;
  236. margin-bottom: 16px;
  237. padding-top: 19px;
  238. padding-bottom: 19px;
  239. border-bottom: 1px solid #f0f2f5;
  240. background: #fff;
  241. }
  242. .userContainer img {
  243. overflow: hidden;
  244. display: block;
  245. margin: 0 auto;
  246. margin-bottom: 16px;
  247. }
  248. .userContainer span {
  249. width: 100%;
  250. overflow: hidden;
  251. display: block;
  252. margin: 0 auto;
  253. color: #565656;
  254. font-size: 16px;
  255. }
  256. .userContainer em {
  257. width: 125px;
  258. height: 26px;
  259. line-height: 26px;
  260. text-align: center;
  261. color: #fff;
  262. overflow: hidden;
  263. display: block;
  264. margin: 0 auto;
  265. background: #e75296;
  266. border-radius: 250px;
  267. font-style: normal;
  268. margin-top: 8px;
  269. font-size: 16px;
  270. }
  271. /deep/ .el-menu {
  272. border: none;
  273. }
  274. /deep/ .el-menu-item {}
  275. /deep/ .el-menu-item span {
  276. text-align: left;
  277. float: left;
  278. margin-left: 70px;
  279. }
  280. /deep/ .el-menu-item.is-active {
  281. background-color: #3799ff !important;
  282. color: #fff !important;
  283. }
  284. /deep/ .el-menu-item:hover {
  285. background-color: #3799ff !important;
  286. color: #fff !important;
  287. }
  288. /deep/ .el-menu-item:hover i {
  289. color: #fff !important;
  290. }
  291. /deep/ .el-menu-item i {
  292. position: inherit;
  293. float: left;
  294. line-height: 25px;
  295. margin-top: 15px;
  296. left: 60px;
  297. }
  298. @media (min-width: 960px) and (max-width: 1367px) {
  299. .left_hide_icon {
  300. width: 20px;
  301. height: 20px;
  302. margin-top: 8px;
  303. float: left;
  304. margin-left: 10px;
  305. cursor: pointer;
  306. color: #badcff;
  307. font-size: 22px;
  308. /*background: url("../assets/img/header/right.png")top center no-repeat;*/
  309. }
  310. /*.left_hide_icon:hover {*/
  311. /* background: #ccc;*/
  312. /* color: #fff;*/
  313. /*}*/
  314. .left_show_icon {
  315. width: 20px;
  316. height: 20px;
  317. margin-top: 8px;
  318. float: left;
  319. margin-left: 10px;
  320. cursor: pointer;
  321. color: #badcff;
  322. font-size: 22px;
  323. /*background: url("../assets/img/header/left.png")top center no-repeat;*/
  324. }
  325. .logoContainer {
  326. height: 40px;
  327. }
  328. .el-container.is-vertical {
  329. left: 60px;
  330. }
  331. .el-menu-item span {
  332. text-align: left;
  333. float: left;
  334. margin-left: 5px;
  335. line-height: 20px;
  336. font-size: 12px;
  337. height: 30px;
  338. line-height: 30px;
  339. }
  340. .userContainer em {
  341. width: 100%;
  342. overflow: hidden;
  343. display: block;
  344. margin: 0 auto;
  345. font-size: 12px;
  346. }
  347. .el-menu-item {
  348. padding: 0 !important;
  349. margin: 0;
  350. }
  351. /deep/ .el-tooltip {
  352. padding: 0 !important;
  353. }
  354. .userContainer span {
  355. font-size: 12px;
  356. }
  357. .el-menu-item,
  358. .el-submenu__title {
  359. height: 30px;
  360. line-height: 30px;
  361. }
  362. .userContainer img {
  363. display: none;
  364. }
  365. /deep/ .el-tooltip i {
  366. float: left;
  367. left: 10px;
  368. line-height: 30px;
  369. }
  370. /deep/ .el-menu-item i {
  371. position: inherit;
  372. float: left;
  373. margin-top: 3px;
  374. left: 10px;
  375. }
  376. }
  377. </style>