header.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import { useStore } from 'vuex'
  4. import { useRoute } from "vue-router"
  5. const store = useStore()
  6. const route = useRoute()
  7. const currentPagePath = ref(route.path)//当前页面路径
  8. const pathTemplateQuery = ref()//页面模版复用参数
  9. if(route.query && route.query.dup){
  10. pathTemplateQuery.value = route.query.dup
  11. }
  12. console.log(11111)
  13. //获取菜单列表及当前页面内容
  14. store.dispatch('getMenuList').then(()=>{
  15. const data = ref(store.state.menuList)
  16. const paramsData = ref({}) //页面主题内容请求参数
  17. console.log(3333)
  18. let str
  19. if(currentPagePath.value.indexOf("_")){
  20. console.log(currentPagePath.value)
  21. str = currentPagePath.value.split("_")[0]
  22. }
  23. for(let i=0;i<data.value.length;i++){
  24. if(currentPagePath.value == data.value[i].path || str == data.value[i].path){
  25. console.log(5,data.value[i].path)
  26. //模板 主页
  27. if(!data.value[i].sname && !route.query?.categoryid){
  28. console.log(1)
  29. paramsData.value = {
  30. params:{
  31. categoryid: data.value[i].id,
  32. pageNum:1,
  33. pageSize:100,
  34. order:"sortindex",
  35. },
  36. index:currentPagePath.value,
  37. sub:i
  38. }
  39. if(data.value[i].path == "/cases"){
  40. paramsData.value.params.categoryid = data.value[i].children[0].id
  41. }
  42. }
  43. //详情页(添加details识别参数)
  44. // console.log(route.query?.categoryid && !route.query.dup)
  45. if(route.query?.categoryid && !route.query.dup){
  46. paramsData.value = {
  47. params:{
  48. categoryid: route.query?.categoryid,
  49. pageNum:1,
  50. pageSize:1,
  51. order:"sortindex",
  52. articleid: route.query?.id,
  53. id: route.query?.id,
  54. details:true
  55. },
  56. index:currentPagePath.value,
  57. sub:i
  58. }
  59. }
  60. //复用模板页
  61. }
  62. }
  63. store.dispatch('getPageData',paramsData.value)
  64. })
  65. </script>
  66. <template>
  67. <header class="header-absolute sticky-header">
  68. <div class="custom-container-one">
  69. <div class="mainmenu-area d-flex align-items-center justify-content-center">
  70. <div class="logo">
  71. <a href="/"><img src="@/assets/img/logo-white.png" alt="uskylogo"></a>
  72. </div>
  73. <div class="d-flex align-items-center ">
  74. <nav class="main-menu">
  75. <div class="menu-items">
  76. <ul v-if="store.state.menuList.length>0">
  77. <li v-for="item in store.state.menuList" :key="item.id"
  78. :class="item.sname ? `${currentPagePath}?dup=${item.sname}` == `${item.path}?dup=${item.sname}` && pathTemplateQuery ? 'active' : ' ' : currentPagePath == item.path && !pathTemplateQuery ? 'active' : ' ' "
  79. >
  80. <a :href="item.sname ? `${item.path}?dup=${item.sname}` : item.path
  81. ">{{item.categoryName}}</a>
  82. <ul class="submenu">
  83. <li v-if="item.children" v-for="children in item.children" :key="children.id">
  84. <a :href="item.sname ? `${item.path}?dup=${item.sname}&categoryid=${children.id}&isUrlId=1` : `${item.path}?categoryid=${children.id}&isUrlId=1` ">
  85. <span style="font-weight:bold;margin-right:10px">·</span>
  86. {{children.categoryName}}
  87. </a>
  88. </li>
  89. </ul>
  90. </li>
  91. </ul>
  92. </div>
  93. </nav>
  94. <div class="apply-expre" v-if="store.state.menuList.length>0" @click="gogo()">申请体验</div>
  95. </div>
  96. </div>
  97. <div>
  98. <div class="mobile-menu"></div>
  99. </div>
  100. </div>
  101. </header>
  102. </template>
  103. <style lang="scss" scoped>
  104. </style>