main-navbar-user.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="navbar-user" @click="showUserFunc" v-click-outside="clickOutSide">
  3. <div class="nu-main">
  4. <div class="nu-l">
  5. <img v-if="useHeadPictureUrl" :src="useHeadPictureUrl">
  6. <i v-else class="smp-nav-icon-32 smp-ni32-userPic"></i>
  7. </div>
  8. <div class="nu-r">
  9. <div class="nu-t">{{department}}</div>
  10. <div class="nu-b">
  11. <div class="navbar-name">{{userName}}</div>
  12. <div class="navbar-open-btn">
  13. <i class="smp-nav-icon-10 smp-ni10-arrow" :class="{'on':isUserFuncOpen}"></i>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="nu-list-wraper" v-show="isUserFuncOpen">
  19. <ul class="nulw-ul">
  20. <!-- <li class="nulw-li">
  21. <i class="smp-nav-icon-16 smp-ni16-person"></i>
  22. <span>个人信息</span>
  23. </li>
  24. <li class="nulw-li">
  25. <i class="smp-nav-icon-16 smp-ni16-pass"></i>
  26. <span>修改密码</span>
  27. </li> -->
  28. <li class="nulw-li" @click="logoutHandle">
  29. <i class="smp-nav-icon-16 smp-ni16-out"></i>
  30. <span>退出</span>
  31. </li>
  32. </ul>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import { clearLoginInfo } from '@/utils'
  38. export default {
  39. data () {
  40. return {
  41. useHeadPictureUrl: '',
  42. isUserFuncOpen: false
  43. }
  44. },
  45. computed: {
  46. userName () {
  47. return this.$store.state.user.name
  48. },
  49. department () {
  50. return this.$store.state.user.organizations
  51. }
  52. },
  53. methods: {
  54. clickOutSide (e) {
  55. this.isUserFuncOpen = false
  56. },
  57. showUserFunc () {
  58. this.isUserFuncOpen = !this.isUserFuncOpen
  59. },
  60. logoutHandle () {
  61. this.$confirm(this.$t('prompt.info', { 'handle': this.$t('logout') }), this.$t('prompt.title'), {
  62. confirmButtonText: this.$t('confirm'),
  63. cancelButtonText: this.$t('cancel'),
  64. type: 'warning'
  65. }).then(() => {
  66. this.$http.post('/idaas/sso/logout').then(({ data: res }) => {
  67. if (res.code !== 0) {
  68. return this.$message.error(res.msg)
  69. }
  70. clearLoginInfo()
  71. // console.log(this.$router)
  72. this.$router.replace({ name: 'login' }, (e) => {
  73. window.location.reload()
  74. })
  75. }).catch(() => {})
  76. }).catch(() => {})
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss">
  82. .navbar-user{
  83. }
  84. </style>