App.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div id="app">
  3. <el-container>
  4. <el-header>
  5. <div class="flex flex-auto flex-center">
  6. <div class="logo mr12">
  7. <img src="./assets/img/common-logo.png" alt />
  8. </div>
  9. <el-menu :default-active="defaultActive"
  10. class="el-menu-demo"
  11. mode="horizontal"
  12. menu-trigger="hover"
  13. @select="handleSelect"
  14. :router="router">
  15. <el-menu-item index="/">首页</el-menu-item>
  16. <el-menu-item index="/introduce">中心介绍</el-menu-item>
  17. <el-menu-item index="/news">新闻动态</el-menu-item>
  18. <el-submenu index="/appointment" popper-class="custom-submenu">
  19. <template slot="title">
  20. 预约管理
  21. </template>
  22. <el-menu-item index="/appointment/equipment">
  23. 仪器设备
  24. </el-menu-item>
  25. <el-menu-item index="/appointment/equipment-details" v-if="false">
  26. 仪器设备详情
  27. </el-menu-item>
  28. <el-menu-item index="2-2">中心平台</el-menu-item>
  29. <el-menu-item index="2-3">技术服务</el-menu-item>
  30. </el-submenu>
  31. <el-menu-item index="/product">教育培训</el-menu-item>
  32. <el-menu-item index="/case">资料下载</el-menu-item>
  33. <el-menu-item index="/contact-us">联系我们</el-menu-item>
  34. </el-menu>
  35. </div>
  36. <div class="user" v-if="$route.path != '/login'">
  37. <template v-if="!userInfo.id">
  38. <el-button type="text" @click="toLogin">登录</el-button>
  39. <el-button type="text" @click="onRegister">注册</el-button>
  40. </template>
  41. <template v-else>
  42. <el-button
  43. type="primary"
  44. size="mini"
  45. color="#386AFE"
  46. @click="toCenter"
  47. >
  48. 个人中心
  49. </el-button>
  50. <el-dropdown class="ml12" size="medium" @command="handleCommand">
  51. <span class="flex flex-center">
  52. <img v-if="userInfo.avatar" :src="userInfo.avatar" />
  53. <img v-else src="./assets/img/default-avatar.png">
  54. <i class="el-icon-arrow-down el-icon--right"></i>
  55. </span>
  56. <el-dropdown-menu slot="dropdown">
  57. <el-dropdown-item command="logOut">注销</el-dropdown-item>
  58. </el-dropdown-menu>
  59. </el-dropdown>
  60. </template>
  61. </div>
  62. </el-header>
  63. <el-main>
  64. <router-view />
  65. </el-main>
  66. <div class="footer">
  67. 版权所有©遵义医科大学附属医院 贵ICP备17033796号-1
  68. </div>
  69. </el-container>
  70. </div>
  71. </template>
  72. <script>
  73. import { mapGetters } from "vuex";
  74. export default {
  75. computed: {
  76. ...mapGetters(["userInfo"]),
  77. },
  78. watch: {
  79. $route(val) {
  80. this.defaultActive = val.path;
  81. },
  82. },
  83. data() {
  84. return {
  85. router: true,
  86. defaultActive: "/",
  87. isShow: false,
  88. };
  89. },
  90. methods: {
  91. handleSelect(key) {
  92. this.isShow = this.defaultActive != key;
  93. window.console.log(this.isShow);
  94. },
  95. onRegister() {
  96. this.$router.push("/register");
  97. },
  98. toLogin() {
  99. this.$router.push("/login");
  100. },
  101. toCenter() {
  102. this.$router.push("/personal-center");
  103. },
  104. handleCommand(command) {
  105. if (command == "logOut") {
  106. this.$confirm("确定注销吗?", "提示", {
  107. confirmButtonText: "确定",
  108. cancelButtonText: "取消",
  109. type: "warning"
  110. }).then(() => {
  111. this.$store.dispatch('logOut').then(() => this.$router.push('/'))
  112. })
  113. }
  114. }
  115. },
  116. };
  117. </script>
  118. <style lang="scss">
  119. * {
  120. padding: 0;
  121. margin: 0;
  122. }
  123. html,
  124. body {
  125. height: 100%;
  126. }
  127. #app {
  128. font-family: "Avenir", Helvetica, Arial, sans-serif;
  129. -webkit-font-smoothing: antialiased;
  130. -moz-osx-font-smoothing: grayscale;
  131. color: #2c3e50;
  132. }
  133. .el-header {
  134. display: flex;
  135. justify-content: space-between;
  136. align-content: center;
  137. align-items: center;
  138. width: 100%;
  139. margin: 0 auto;
  140. height: 84px !important;
  141. .el-menu,
  142. .el-submenu,
  143. .el-submenu__title,
  144. .el-menu-item {
  145. height: 40px !important;
  146. line-height: 40px !important;
  147. }
  148. .el-menu.el-menu--horizontal,
  149. .el-menu-demo .el-menu-item,
  150. .el-submenu .el-submenu__title {
  151. border-bottom: none;
  152. font-weight: 400;
  153. font-size: 16px;
  154. color: #323232;
  155. padding: 0;
  156. margin: 0 20px;
  157. }
  158. .el-menu.el-menu--horizontal,
  159. .el-submenu .el-submenu__title {
  160. font-weight: 400;
  161. font-size: 16px;
  162. color: #323232 !important;
  163. }
  164. .logo {
  165. width: 280px;
  166. padding: 10px;
  167. img {
  168. width: 100%;
  169. line-height: 60px;
  170. }
  171. }
  172. .user {
  173. display: flex;
  174. align-items: center;
  175. img {
  176. width: 36px;
  177. height: 36px;
  178. border-radius: 50%;
  179. }
  180. }
  181. }
  182. .el-main {
  183. padding: 0 !important;
  184. }
  185. .footer {
  186. width: 100%;
  187. height: 32px;
  188. overflow: hidden;
  189. background-color: #386afe;
  190. font-weight: 400;
  191. font-size: 18px;
  192. color: #ffffff;
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. }
  197. </style>