headers.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="headerContainer">
  3. <div class="header center-row">
  4. <img src="http://ttkt.sxedu.org:70/upload/setting/0/0.png?_=1557194799800" />
  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/reviewActivity' || activeIndex == 2? 'li-active':''" @click="handleMenuClick(2,'reviewActivity')">评审活动</li>
  9. <li :class="this.$route.path == '/main/PastReview' || activeIndex == 3? 'li-active':''" @click="handleMenuClick(3,'PastReview')">往届回顾</li>
  10. <li :class="this.$route.path == '/main/LiveBroadcast' || activeIndex == 4? 'li-active':''" @click="handleMenuClick(4,'LiveBroadcast')">天天直播</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;" size="20" 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. methods: {
  30. handleMenuClick(index, route) {
  31. this.activeIndex = index;
  32. sessionStorage.setItem('_activeIndex', index);
  33. this.$router.push(route);
  34. },
  35. loginOut() {
  36. localStorage.clear();
  37. this.isLogin = 0;
  38. }
  39. },
  40. mounted() {
  41. this.userName = localStorage.getItem("userName");
  42. this.isLogin = localStorage.getItem("isLogin");
  43. this.$eventBus.$on('activeIndex', (index) => {
  44. this.activeIndex = index;
  45. })
  46. }
  47. }
  48. </script>
  49. <style scoped>
  50. .headerContainer {
  51. background-color: #1f2d3d;
  52. height: 80px;
  53. position: absolute;
  54. left:0;
  55. top:0;
  56. min-width: 100%
  57. }
  58. .header {
  59. width: 1200px;
  60. margin: 0 auto;
  61. height: 80px;
  62. box-sizing: content-box
  63. }
  64. .header ul {
  65. list-style:none;
  66. color:#aaa;
  67. padding: 0 20px;
  68. /*margin-right:20px;*/
  69. }
  70. .header ul li {
  71. float:left;
  72. height:80px;
  73. width:100px;
  74. line-height:80px;
  75. text-align:center;
  76. padding: 0 15px;
  77. font-size:16px;
  78. cursor:pointer;
  79. }
  80. .header ul li:hover {
  81. background:rgba(160,160,160,.24);
  82. color:#33aafe;
  83. }
  84. .header ul .li-active {
  85. color:#33aafe;
  86. }
  87. .header .btn-login {
  88. color: #fff;
  89. font-size: 14px;
  90. line-height: 44px;
  91. display: inline-block;
  92. cursor:pointer;
  93. }
  94. .center-row {
  95. display:flex;
  96. flex-direction:row;
  97. align-items:center;
  98. justify-content:space-around;
  99. }
  100. </style>