TopBar.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="top-bar">
  3. <div class="top-box">
  4. <span>移动安全保卫管理平台</span>
  5. <van-icon name="setting-o" size="26" @click="clickOutLogin" />
  6. </div>
  7. <div class="bottom-box">
  8. <div>
  9. <p class="user-name">{{userName}}</p>
  10. <p class="introduce-info" v-for="item in rolesList" :key="item.roleId">{{orgName}} · {{item.roleName}}</p>
  11. </div>
  12. <van-icon name="arrow" size="20" />
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { Icon } from 'vant';
  18. import {mapGetters} from "vuex";
  19. import {logout} from "@/api/public";
  20. export default {
  21. components: {
  22. [Icon.name]: Icon,
  23. },
  24. data() {
  25. return {
  26. active: this.defaultActive,
  27. rolesList:[]
  28. }
  29. },
  30. computed: {
  31. ...mapGetters(['userName','orgName'])
  32. },
  33. created(){
  34. this.rolesList=JSON.parse(window.sessionStorage.getItem('SET_USER_ROLELIST'))
  35. console.log(this.rolesList);
  36. },
  37. methods: {
  38. clickOutLogin(){
  39. logout().then(res=>{
  40. sessionStorage.clear();
  41. this.$router.replace('/login');
  42. this.$toast('退出登录');
  43. })
  44. },
  45. }
  46. }
  47. </script>
  48. <style scoped lang="scss">
  49. .top-bar{
  50. height: 300px;
  51. width: 100%;
  52. background: url("../assets/img/banner.png") no-repeat center;
  53. background-size: 100% 100%;
  54. padding: 40px;
  55. box-shadow: 0 1px 8px #ccc;
  56. >div{
  57. width: 100%;
  58. display: flex;
  59. justify-content: space-between;
  60. align-items: center;
  61. color: #fff;
  62. }
  63. }
  64. .top-box{
  65. >span{
  66. font-size: 40px;
  67. }
  68. }
  69. .bottom-box{
  70. padding-top:50px;
  71. >div{
  72. .user-name{
  73. font-size: 30px;
  74. margin-bottom: 20px;
  75. }
  76. .introduce-info{
  77. font-size: 20px;
  78. }
  79. }
  80. }
  81. </style>