headers.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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" @click="handleMenuClick(6,'login')">登录</span>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. name: "headers",
  20. data() {
  21. return {
  22. activeIndex: sessionStorage.getItem('_activeIndex') || 0
  23. }
  24. },
  25. created() {
  26. },
  27. methods: {
  28. handleMenuClick(index, route) {
  29. this.activeIndex = index;
  30. sessionStorage.setItem('_activeIndex', index);
  31. this.$router.push(route);
  32. }
  33. },
  34. mounted() {
  35. this.$eventBus.$on('activeIndex', (index) => {
  36. this.activeIndex = index;
  37. })
  38. }
  39. }
  40. </script>
  41. <style scoped>
  42. .headerContainer {
  43. background-color: #1f2d3d;
  44. height: 80px;
  45. position: absolute;
  46. left:0;
  47. top:0;
  48. min-width: 100%
  49. }
  50. .header {
  51. width: 1200px;
  52. margin: 0 auto;
  53. height: 80px;
  54. box-sizing: content-box
  55. }
  56. .header ul {
  57. list-style:none;
  58. color:#aaa;
  59. padding: 0 20px;
  60. margin-right:160px;
  61. }
  62. .header ul li {
  63. float:left;
  64. height:80px;
  65. width:100px;
  66. line-height:80px;
  67. text-align:center;
  68. padding: 0 15px;
  69. font-size:16px;
  70. cursor:pointer;
  71. }
  72. .header ul li:hover {
  73. background:rgba(160,160,160,.24);
  74. color:#33aafe;
  75. }
  76. .header ul .li-active {
  77. color:#33aafe;
  78. }
  79. .header .btn-login {
  80. color: #fff;
  81. font-size: 14px;
  82. line-height: 44px;
  83. display: inline-block;
  84. cursor:pointer;
  85. }
  86. .center-row {
  87. display:flex;
  88. flex-direction:row;
  89. align-items:center;
  90. justify-content:space-around;
  91. }
  92. </style>