You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

TopMenu.vue 2.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="container ui" style="padding:0 75px;">
  3. <div class="menu">
  4. <div class="menu-l">
  5. <div class="menu-item" v-for="(item, index) in listL" :key="index"
  6. :class="focusMenu == item.key ? 'focused' : ''" @click="changeMenu(item)">
  7. {{ item.title }}
  8. </div>
  9. </div>
  10. <div class="menu-r">
  11. <div class="menu-item" v-for="(item, index) in listR" :key="index"
  12. :class="focusMenu == item.key ? 'focused' : ''" @click="changeMenu(item)">
  13. {{ item.title }}
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import { getIsTechAdmin } from '~/apis/modules/tech';
  21. export default {
  22. name: "TopMenu",
  23. props: {
  24. menu: { type: String, default: '' },
  25. },
  26. components: {},
  27. data() {
  28. return {
  29. focusMenu: '',
  30. listL: [{
  31. key: 'tech_view',
  32. title: '按科技项目查看',
  33. url: '/tech/tech_view',
  34. }, {
  35. key: 'repo_view',
  36. title: '按项目成果查看',
  37. url: '/tech/repo_view',
  38. }],
  39. listR: [{
  40. key: 'my_view',
  41. title: '我申请的项目',
  42. url: '/tech/my_view',
  43. },],
  44. isTechAdmin: false,
  45. };
  46. },
  47. methods: {
  48. changeMenu(item, index) {
  49. this.focusMenu = item.key;
  50. window.location.href = item.url;
  51. }
  52. },
  53. beforeMount() {
  54. this.focusMenu = this.menu;
  55. getIsTechAdmin().then(res => {
  56. res = res.data;
  57. if (res.data && res.data.is_admin) {
  58. this.isTechAdmin = true;
  59. this.listR.push({
  60. key: 'admin_view',
  61. title: '管理展示项目',
  62. url: '/tech/admin_view',
  63. });
  64. }
  65. }).catch(err => {
  66. console.log(err);
  67. });
  68. },
  69. mounted() { },
  70. };
  71. </script>
  72. <style scoped lang="less">
  73. .menu {
  74. display: flex;
  75. align-items: center;
  76. justify-content: space-between;
  77. .menu-l {
  78. display: flex;
  79. align-items: center;
  80. justify-content: flex-start;
  81. }
  82. .menu-r {
  83. display: flex;
  84. align-items: center;
  85. justify-content: flex-end;
  86. }
  87. .menu-item {
  88. display: flex;
  89. border-color: rgb(187, 187, 187);
  90. border-width: 1px 1px 0px 0px;
  91. border-style: solid;
  92. font-size: 14px;
  93. line-height: 20px;
  94. color: rgba(255, 255, 255, 0.7);
  95. align-items: center;
  96. text-align: center;
  97. justify-content: center;
  98. background: rgba(104, 50, 165, 0.2);
  99. height: 40px;
  100. width: 178px;
  101. cursor: pointer;
  102. &:first-child {
  103. border-left-width: 1px;
  104. }
  105. &.focused {
  106. color: rgb(255, 255, 255);
  107. background: rgba(249, 249, 249, 0.2);
  108. }
  109. }
  110. }
  111. </style>