layout.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="layout">
  3. <div class="menu-wrapper">
  4. <left-menu :isCollapse='isFold'
  5. @changeMenu="changeMenu"
  6. @changeIsBack="changeIsBack"></left-menu>
  7. </div>
  8. <div class="content">
  9. <header :style="menuIndex==0?'justify-content: space-between;':''">
  10. <div class="back-icon"
  11. v-if="isback"
  12. @click="goBack"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/back.png"
  13. alt=""></div>
  14. <div class="left"
  15. v-if="menuIndex==0">
  16. <div class="address">{{userInfo.store_name}}</div>
  17. </div>
  18. <div class="right">
  19. <div class="news"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/home/news.png"></div>
  20. <div class="head-img"><img :src="userInfo.avatar_url"></div>
  21. <el-dropdown trigger="click"
  22. placement="top"
  23. @command="loginOut">
  24. <span class="el-dropdown-link">
  25. <img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/coupon/logOut.png"
  26. alt="">
  27. </span>
  28. <el-dropdown-menu slot="dropdown">
  29. <el-dropdown-item>退出登录</el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. </div>
  33. </header>
  34. <div class="main-wrapper">
  35. <router-view></router-view>
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script type="text/javascript">
  41. import leftMenu from './leftMenu'
  42. import api from '@/server/home'
  43. export default {
  44. data () {
  45. return {
  46. isFold: false, //导航菜单面板是否折叠
  47. userId: 0,
  48. menuIndex: 0,
  49. isback: false,
  50. userInfo: {
  51. name: '333'
  52. }
  53. }
  54. },
  55. created () {
  56. this.getUserInfo()
  57. },
  58. components: {
  59. leftMenu,
  60. },
  61. methods: {
  62. getUserInfo () {
  63. let that = this
  64. api.getUserInfo().then(res => {
  65. if (res.code == 200) {
  66. this.userInfo = res.data
  67. }
  68. })
  69. },
  70. loginOut () {
  71. localStorage.removeItem('token');
  72. location.reload();
  73. },
  74. changeMenu (index) {
  75. this.menuIndex = index
  76. },
  77. changeIsBack (isback) {
  78. this.isback = isback
  79. },
  80. goBack () {
  81. this.$router.back()
  82. }
  83. },
  84. computed: {
  85. routerItems () {
  86. let resultArr = [];
  87. let routeNow = this.$route;
  88. let RootName = routeNow.matched[0].name; //当前路由的根路由name
  89. resultArr.push({
  90. name: RootName,
  91. path: ''
  92. })
  93. if (routeNow.matched[0].path !== '' && RootName !== routeNow.name) {
  94. if (RootName !== routeNow.name) {
  95. resultArr.push({
  96. name: routeNow.matched[1].name,
  97. path: routeNow.matched[1].path
  98. })
  99. }
  100. }
  101. return resultArr;
  102. }
  103. },
  104. }
  105. </script>
  106. <style lang="less" scoped>
  107. @import url(../../../style/root.less);
  108. .layout {
  109. height: 100vh;
  110. display: flex;
  111. }
  112. .menu-wrapper {
  113. height: 100%;
  114. text-align: center;
  115. overflow: auto;
  116. background-color: #fa7d22;
  117. .el-menu {
  118. background-color: #fa7d22;
  119. .el-menu-item {
  120. color: #eee;
  121. }
  122. }
  123. }
  124. .content {
  125. background-color: #fff;
  126. flex: 1;
  127. overflow: hidden;
  128. header {
  129. line-height: 50px;
  130. font-size: 16px;
  131. color: #409eff;
  132. padding: 0 28px 0 13px;
  133. border-bottom: 1px solid #e5e5e5;
  134. height: 60px;
  135. display: flex;
  136. align-items: center;
  137. justify-content: right;
  138. position: relative;
  139. .back-icon {
  140. position: absolute;
  141. left: 19px;
  142. img {
  143. width: 16px;
  144. }
  145. }
  146. .left {
  147. font-size: 14px;
  148. font-family: SourceHanSansCN-Regular, SourceHanSansCN;
  149. font-weight: 400;
  150. color: #333333;
  151. line-height: 21px;
  152. }
  153. .right {
  154. float: right;
  155. display: flex;
  156. align-items: center;
  157. .news {
  158. width: 24px;
  159. height: 24px;
  160. img {
  161. width: 100%;
  162. display: block;
  163. }
  164. }
  165. .head-img {
  166. margin-left: 19px;
  167. width: 28px;
  168. height: 28px;
  169. border-radius: 50%;
  170. img {
  171. width: 100%;
  172. display: block;
  173. }
  174. }
  175. .el-dropdown-link {
  176. img {
  177. width: 28px;
  178. height: 28px;
  179. display: block;
  180. }
  181. }
  182. }
  183. }
  184. .main-wrapper {
  185. height: calc(100% - 51px);
  186. width: 100%;
  187. overflow: auto;
  188. padding: 20px;
  189. background-color: #f7f8fa;
  190. }
  191. }
  192. </style>