headers.vue 3.2 KB

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