main-navbar.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType">
  3. <div class="site-navbar__header">
  4. <h1 class="site-navbar__brand" @click="$router.push({ name: 'home' })">
  5. <a class="site-navbar__brand-lg" href="javascript:;">木之云平台</a>
  6. <a class="site-navbar__brand-mini" href="javascript:;">木之云</a>
  7. </h1>
  8. </div>
  9. <div class="site-navbar__body clearfix">
  10. <el-menu
  11. class="site-navbar__menu"
  12. mode="horizontal">
  13. <el-menu-item class="site-navbar__switch" index="0" @click="sidebarFold = !sidebarFold">
  14. <icon-svg name="zhedie"></icon-svg>
  15. </el-menu-item>
  16. </el-menu>
  17. <el-menu
  18. class="site-navbar__menu site-navbar__menu--right"
  19. mode="horizontal">
  20. <el-menu-item index="0" @click="$router.push({ name: 'msgCenter' })">
  21. <template slot="title">
  22. <el-badge :value="cnt" :hidden="cnt < 1">
  23. <icon-svg name="lingdang" class="el-icon-lingdang"></icon-svg>
  24. </el-badge>
  25. </template>
  26. </el-menu-item>
  27. <el-menu-item index="1" @click="previewPic">
  28. <template slot="title">
  29. <el-badge value="">
  30. <icon-svg name="minprogram" class="el-icon-setting"></icon-svg>
  31. </el-badge>
  32. </template>
  33. </el-menu-item>
  34. <el-menu-item index="2" @click="previewPic">
  35. <template slot="title">
  36. <el-badge value="">
  37. <icon-svg name="minprogram" class="el-icon-setting"></icon-svg>
  38. </el-badge>
  39. </template>
  40. </el-menu-item>
  41. <el-menu-item index="0" @click="$router.push({ name: 'msgWork' })">
  42. <template slot="title">
  43. <el-badge value="">
  44. <icon-svg name="gongyimg" class="el-icon-lingdang"></icon-svg>
  45. </el-badge>
  46. </template>
  47. </el-menu-item>
  48. <el-menu-item class="site-navbar__avatar" index="4">
  49. <el-dropdown :show-timeout="0" placement="bottom">
  50. <span class="el-dropdown-link">
  51. <img src="~@/assets/img/avatar.png" :alt="userName">{{ userName }}
  52. </span>
  53. <el-dropdown-menu slot="dropdown">
  54. <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item>
  55. <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item>
  56. </el-dropdown-menu>
  57. </el-dropdown>
  58. </el-menu-item>
  59. </el-menu>
  60. </div>
  61. <!-- 弹窗, 修改密码 -->
  62. <update-password v-if="updatePasswordVisible" ref="updatePassowrd"></update-password>
  63. <Msg ref="msgDialog" @noticeAdded="noticeAdded"/>
  64. <youli-component v-if="previewVisible" ref="preview"/>
  65. </nav>
  66. </template>
  67. <script>
  68. import UpdatePassword from './main-navbar-update-password'
  69. import Msg from './common/msg'
  70. import { clearLoginInfo } from '@/utils'
  71. import PreviewComponent from '@/views/modules/common/preview-component'
  72. import YouliComponent from '@/views/modules/common/youli-component'
  73. import Vue from 'vue'
  74. export default {
  75. data () {
  76. return {
  77. updatePasswordVisible: false,
  78. cnt: 0,
  79. previewVisible: false
  80. }
  81. },
  82. components: {
  83. YouliComponent,
  84. PreviewComponent,
  85. UpdatePassword,
  86. Msg
  87. },
  88. computed: {
  89. navbarLayoutType: {
  90. get () { return this.$store.state.common.navbarLayoutType }
  91. },
  92. sidebarFold: {
  93. get () { return this.$store.state.common.sidebarFold },
  94. set (val) { this.$store.commit('common/updateSidebarFold', val) }
  95. },
  96. mainTabs: {
  97. get () { return this.$store.state.common.mainTabs },
  98. set (val) { this.$store.commit('common/updateMainTabs', val) }
  99. },
  100. userName: {
  101. get () {
  102. // return this.$store.state.user.name
  103. return Vue.cookie.get('name')
  104. }
  105. }
  106. },
  107. methods: {
  108. // 修改密码
  109. updatePasswordHandle () {
  110. this.updatePasswordVisible = true
  111. this.$nextTick(() => {
  112. this.$refs.updatePassowrd.init()
  113. })
  114. },
  115. // 退出
  116. logoutHandle () {
  117. this.$confirm(`确定进行[退出]操作?`, '提示', {
  118. confirmButtonText: '确定',
  119. cancelButtonText: '取消',
  120. type: 'warning'
  121. }).then(() => {
  122. clearLoginInfo()
  123. this.$router.push({ name: 'login' })
  124. // this.$http({
  125. // url: this.$http.adornUrl('/sys/logout'),
  126. // method: 'post',
  127. // data: this.$http.adornData()
  128. // }).then(({data}) => {
  129. // if (data && data.code === 0) {
  130. // clearLoginInfo()
  131. // this.$router.push({ name: 'login' })
  132. // }
  133. // })
  134. }).catch(() => {})
  135. },
  136. // 通知数量变化
  137. noticeAdded (num) {
  138. this.cnt = num
  139. },
  140. // 小程序图片预览
  141. previewPic () {
  142. this.previewVisible = true
  143. this.$nextTick(() => {
  144. this.$refs.preview.init()
  145. })
  146. }
  147. }
  148. }
  149. </script>