header.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 mobilelistboolean = ref(false)
  9. if(route.path.indexOf("_")){
  10. currentPagePath.value = route.path.split("_")[0]
  11. }
  12. const pathTemplateQuery = ref()//页面模版复用参数
  13. if(route.query && route.query.dup){
  14. pathTemplateQuery.value = route.query.dup
  15. }
  16. function mobileIconClick(){
  17. mobilelistboolean.value = !mobilelistboolean.value
  18. }
  19. function handleOpen(){
  20. }
  21. function handleClose(){
  22. }
  23. function dialogPersona(){
  24. store.commit("setDialogPersonalStatus",true)
  25. }
  26. if(typeof window !== 'undefined' && typeof window.globalThis.addEventListener === 'function') {
  27. globalThis.addEventListener('scroll', function() {
  28. var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  29. var element:any = document.getElementById("scroll-up")
  30. var stickyHeader:any = document.getElementsByClassName("sticky-header")[0]
  31. if(scrollTop > 770){
  32. element.style.opacity = 1
  33. }else{
  34. element.style.opacity = 0
  35. }
  36. if(scrollTop > 110){
  37. stickyHeader.classList.add("sticky")
  38. }else{
  39. stickyHeader.classList.remove("sticky")
  40. }
  41. });
  42. }
  43. </script>
  44. <template>
  45. <header class="header-absolute sticky-header">
  46. <div class="custom-container-one">
  47. <div class="mainmenu-area d-flex align-items-center justify-content-center">
  48. <div class="logo">
  49. <a href="/"><img src="@/assets/img/logo-white.png" alt="uskylogo"></a>
  50. </div>
  51. <div class="d-flex align-items-center ">
  52. <nav class="main-menu">
  53. <div class="menu-items">
  54. <ul v-if="store.state.menuList.length>0">
  55. <li v-for="item in store.state.menuList" :key="item.id"
  56. :class="item.sname ? `${currentPagePath}?dup=${item.sname}` == `${item.path}?dup=${item.sname}` && pathTemplateQuery ? 'active' : ' ' : currentPagePath == item.path && !pathTemplateQuery ? 'active' : ' ' "
  57. >
  58. <a :href="item.sname ? `${item.path}?dup=${item.sname}` : item.path
  59. ">{{item.categoryName}}</a>
  60. <ul class="submenu">
  61. <li v-if="item.children" v-for="children in item.children" :key="children.id">
  62. <a :href="item.sname ? `${item.path}?dup=${item.sname}&categoryid=${children.id}&isUrlId=1` : `${item.path}?categoryid=${children.id}&isUrlId=1` ">
  63. <span style="font-weight:bold;margin-right:10px">·</span>
  64. {{children.categoryName}}
  65. </a>
  66. </li>
  67. </ul>
  68. </li>
  69. </ul>
  70. </div>
  71. </nav>
  72. <div class="apply-expre" v-if="store.state.menuList.length>0" @click="dialogPersona()">申请体验</div>
  73. </div>
  74. </div>
  75. <div class="mobile-menu mean-container mobileIcon">
  76. <div class="mean-bar">
  77. <a href="#nav" @click="mobileIconClick" class="meanmenu-reveal"
  78. style="right: 0px; left: auto; text-align: center; text-indent: 0px; font-size: 18px;">
  79. <span></span><span></span><span></span>
  80. </a>
  81. </div>
  82. </div>
  83. <el-row class="tac mobileMenuBox" :class="[mobilelistboolean?'active':'']" v-if="mobilelistboolean">
  84. <el-col :span="24">
  85. <el-menu active-text-color="#ffd04b" background-color="#0c1923" class="el-menu-vertical-demo"
  86. default-active="2" text-color="#fff" @open="handleOpen" @close="handleClose">
  87. <template v-for="item in store.state.menuList" :key="item.id">
  88. <el-sub-menu :index="item.id" v-if="item.children.length>0">
  89. <template #title>
  90. <location />
  91. <span>
  92. <a :href="item.sname ? `${item.path}?dup=${item.sname}&categoryid=${item.id}&isUrlId=1` : `${item.path}?categoryid=${item.id}&isUrlId=1` ">
  93. {{item.categoryName}}
  94. </a>
  95. </span>
  96. </template>
  97. <el-menu-item-group title="" v-for="aa in item.children" :key="aa.id">
  98. <el-menu-item :index="item.id+'-'+aa.id">
  99. <a :href="item.sname ? `${item.path}?dup=${item.sname}&categoryid=${aa.id}&isUrlId=1` : `${item.path}?categoryid=${aa.id}&isUrlId=1` ">
  100. <span style="font-weight:bold;margin-right:10px">·</span>{{aa.categoryName}}
  101. </a>
  102. </el-menu-item>
  103. </el-menu-item-group>
  104. </el-sub-menu>
  105. <el-menu-item v-else :index="item.index" >
  106. <icon-menu />
  107. <span>
  108. <a style="color:#fff" :href="item.sname ? `${item.path}?dup=${item.sname}&categoryid=${item.id}&isUrlId=1` : `${item.path}?categoryid=${item.id}&isUrlId=1` ">
  109. {{item.categoryName}}
  110. </a>
  111. </span>
  112. </el-menu-item>
  113. </template>
  114. </el-menu>
  115. </el-col>
  116. </el-row>
  117. </div>
  118. </header>
  119. </template>
  120. <style lang="scss" scoped>
  121. </style>