Navside2.vue 8.5 KB

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