headers.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="headerContainer">
  3. <div class="header center-row">
  4. <img src="../../assets/image/e_logo3.png" style="width:150px" />
  5. <ul>
  6. <li :class="this.$route.path == '/main/index' || activeIndex == 0 ? 'li-active':''" @click="handleMenuClick(0,'index')">首页</li>
  7. <li :class="this.$route.path == '/main/notice' || activeIndex == 1? 'li-active':''" @click="handleMenuClick(1,'notice')">通知公告</li>
  8. <li :class="this.$route.path == '/main/LiveBroadcast' || activeIndex == 4? 'li-active':''" @click="handleMenuClick(4,'LiveBroadcast')">天天直播</li>
  9. <li :class="this.$route.path == '/main/reviewActivity' || activeIndex == 2? 'li-active':''" @click="handleMenuClick(2,'reviewActivity')">评审活动</li>
  10. <li :class="this.$route.path == '/main/PastReview' || activeIndex == 3? 'li-active':''" @click="handleMenuClick(3,'PastReview')">往届回顾</li>
  11. <li :class="this.$route.path == '/main/Lessons' || activeIndex == 5? 'li-active':''" @click="handleMenuClick(5,'Lessons')">优课汇聚</li>
  12. </ul>
  13. <span class="btn-login" v-if="isLogin == 1" >欢迎&nbsp;{{userName}} !</span>
  14. <Icon type="md-power" v-if="isLogin == 1" @click="loginOut" style="margin-left:30px;cursor:pointer" size="20" title="退出登录" color="white" />
  15. <span class="btn-login" v-else @click="handleMenuClick(6,'/login')">登录</span>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: "headers",
  22. data() {
  23. return {
  24. userName: '',
  25. isLogin:'',
  26. activeIndex: sessionStorage.getItem('_activeIndex') || 0
  27. }
  28. },
  29. created() {
  30. },
  31. methods: {
  32. handleMenuClick(index, route) {
  33. this.activeIndex = index;
  34. sessionStorage.setItem('_activeIndex', index);
  35. this.$router.push(route);
  36. },
  37. loginOut() {
  38. localStorage.clear();
  39. this.isLogin = 0;
  40. }
  41. },
  42. mounted() {
  43. this.userName = localStorage.getItem("userName");
  44. this.isLogin = localStorage.getItem("isLogin");
  45. this.$eventBus.$on('activeIndex', (index) => {
  46. this.activeIndex = index;
  47. })
  48. }
  49. }
  50. </script>
  51. <style scoped>
  52. .headerContainer {
  53. background-color: #1f2d3d;
  54. height: 80px;
  55. position: absolute;
  56. left:0;
  57. top:0;
  58. min-width: 100%
  59. }
  60. .header {
  61. width: 1200px;
  62. margin: 0 auto;
  63. height: 80px;
  64. box-sizing: content-box
  65. }
  66. .header ul {
  67. list-style:none;
  68. color:#aaa;
  69. padding: 0 20px;
  70. /*margin-right:20px;*/
  71. }
  72. .header ul li {
  73. float:left;
  74. height:80px;
  75. width:100px;
  76. line-height:80px;
  77. text-align:center;
  78. padding: 0 15px;
  79. font-size:16px;
  80. cursor:pointer;
  81. }
  82. .header ul li:hover {
  83. background:rgba(160,160,160,.24);
  84. color:#33aafe;
  85. }
  86. .header ul .li-active {
  87. color:#33aafe;
  88. }
  89. .header .btn-login {
  90. color: #fff;
  91. font-size: 14px;
  92. line-height: 44px;
  93. display: inline-block;
  94. cursor:pointer;
  95. }
  96. .center-row {
  97. display:flex;
  98. flex-direction:row;
  99. align-items:center;
  100. justify-content:space-around;
  101. }
  102. </style>