header.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div class="header">
  3. <div class="label">
  4. <img src="@/assets/logo.svg" class="logo" alt="logo" @click="jumpToHome">
  5. <span class="title">NJUSE 酒店管理系统</span>
  6. </div>
  7. <a-menu v-model="current" mode="horizontal" theme="light">
  8. <a-menu-item key="1" @click="selectMenu">
  9. <router-link to="/hotel/hotelList">
  10. <a-icon type="home" />首页
  11. </router-link>
  12. </a-menu-item>
  13. <a-menu-item key="2" @click="jumpToUserInfo" v-if="userInfo.userType=='Client'">
  14. <a-icon type="user" />个人中心
  15. </a-menu-item>
  16. <a-menu-item key="3" @click="selectMenu" v-if="userInfo.userType=='HotelManager'">
  17. <router-link :to="{ name: 'manageHotel'}">
  18. <a-icon type="switcher" />酒店管理
  19. </router-link>
  20. </a-menu-item>
  21. <a-menu-item key="4" @click="selectMenu" v-if="userInfo.userType=='Admin'">
  22. <router-link :to="{ name: 'manageUser'}">
  23. <a-icon type="user" />账户管理
  24. </router-link>
  25. </a-menu-item>
  26. </a-menu>
  27. <div class="logout">
  28. <a-dropdown placement="bottomCenter">
  29. <div class="user">
  30. <a-avatar src="./defaultAvatar.png"></a-avatar>
  31. <span style="font-size: 14px">{{ userInfo.userName }}</span>
  32. <a-icon style="margin-left: 3px; font-size: 16px" type="down"></a-icon>
  33. </div>
  34. <a-menu slot="overlay">
  35. <a-menu-item @click="jumpToHome()">
  36. <a-icon type="home"></a-icon>
  37. 首页
  38. </a-menu-item>
  39. <a-menu-item @click="jumpToUserInfo()">
  40. <a-icon type="profile"></a-icon>
  41. 我的信息
  42. </a-menu-item>
  43. <a-menu-item @click="quit()">
  44. <a-icon type="poweroff"></a-icon>
  45. 退出登录
  46. </a-menu-item>
  47. </a-menu>
  48. </a-dropdown>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. import { mapGetters, mapActions, mapMutations } from 'vuex'
  54. export default {
  55. name: '',
  56. data() {
  57. return {
  58. current: ['1']
  59. }
  60. },
  61. computed: {
  62. ...mapGetters([
  63. 'userId',
  64. 'userInfo'
  65. ])
  66. },
  67. mounted() {
  68. if (this.$route.name == 'hotelList' || this.$route.name == 'hotelDetail') {
  69. this.current = ['1']
  70. }else if(this.$route.name == 'userInfo') {
  71. this.current = ['2']
  72. }else if(this.$route.name == 'manageHotel') {
  73. this.current = ['3']
  74. }else {
  75. this.current = ['4']
  76. }
  77. },
  78. methods: {
  79. ...mapMutations([
  80. ]),
  81. ...mapActions([
  82. 'logout'
  83. ]),
  84. selectMenu(v){
  85. },
  86. async quit() {
  87. await this.$store.dispatch('logout')
  88. this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  89. },
  90. jumpToUserInfo() {
  91. this.$router.push({ name: 'userInfo', params: { userId: this.userId } })
  92. },
  93. jumpToHome() {
  94. }
  95. }
  96. }
  97. </script>
  98. <style scoped lang="less">
  99. .header {
  100. display: flex;
  101. line-height: 44px;
  102. height: 44px;
  103. align-items: center;
  104. justify-content: space-between;
  105. min-width: 800px;
  106. .label{
  107. height: 44px;
  108. line-height: 44px;
  109. vertical-align: middle;
  110. min-width: 400px;
  111. .logo {
  112. height: 44px;
  113. vertical-align: top;
  114. margin-right: 16px;
  115. border-style: none;
  116. cursor: pointer;
  117. }
  118. .title {
  119. font-size: 33px;
  120. color: rgba(0, 0, 0, .85);
  121. font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif;
  122. font-weight: 600;
  123. position: relative;
  124. top: 2px;
  125. }
  126. .search {
  127. width: 300px;
  128. margin-left: 30px
  129. }
  130. }
  131. .logout {
  132. margin-right: 40px;
  133. .user {
  134. cursor: pointer;
  135. display:flex;
  136. align-items: center;
  137. span {
  138. margin-left: 5px
  139. }
  140. }
  141. }
  142. }
  143. </style>
  144. <style lang="less">
  145. .header {
  146. .ant-menu {
  147. background: none
  148. }
  149. }
  150. </style>