pageNavigation1.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div class="navigate">
  3. <div class="partOne">
  4. <div class="inner">
  5. <div class="navLeft">
  6. <div class="navIndex">
  7. <NuxtLink :to="'/'" title="首页">首页</NuxtLink>
  8. </div>
  9. <div class="navClass">
  10. <div>
  11. 商城类
  12. </div>
  13. <div>
  14. 资讯类
  15. </div>
  16. </div>
  17. </div>
  18. <ul class="navigationOne">
  19. <li v-for="(item, index) in navigation1" :key="index">
  20. <NuxtLink :href="getLinkPath(item)" :title="item.alias" v-if="index<=23" :target="item.is_url == 1 ? '_blank' : '_self'">
  21. {{ item.alias }}
  22. </NuxtLink>
  23. </li>
  24. </ul>
  25. </div>
  26. </div>
  27. <!-- 深度服务 -->
  28. <div class="deepServer">
  29. <div class="inner">
  30. <div class="deepServer_left">
  31. <div class="serverTitle">
  32. 深度服务
  33. </div>
  34. <ul class="contentList">
  35. <li v-for="(item, index) in navigation2" :key="index">
  36. <NuxtLink :href="getLinkPath(item)" :title="item.alias" :target="item.is_url == 1 ? '_blank' : '_self'">
  37. {{ item.alias }}
  38. </NuxtLink>
  39. </li>
  40. </ul>
  41. </div>
  42. <!-- <div class="deepServer_right">
  43. <div class="serverTitle_right">
  44. 站内搜索:
  45. </div>
  46. <div class="searchRole">
  47. <el-select v-model="depValue" placeholder="资讯" size="large" style="width: 100px">
  48. <el-option v-for="(item, index) in department" :key="index" :label="item.name"
  49. :value="item.id" />
  50. </el-select>
  51. <i></i>
  52. <input type="text" v-model="typeValue" placeholder="输入关键词" class="ipt">
  53. <em @click="goToPrimary"></em>
  54. </div>
  55. </div> -->
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script setup>
  61. //1.获取导航菜单 start ---------------------------------------->
  62. //第一行导航菜单 10个
  63. const navigation1 = ref([]);
  64. //两行的导航菜单 20个
  65. const navigation2 = ref([]);
  66. //获取导航菜单1
  67. async function getNavigation1() {
  68. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  69. method: 'GET',
  70. query: {
  71. 'pid': 0,
  72. 'num': 20,
  73. 'placeid': 1
  74. },
  75. });
  76. navigation1.value = mkdata.data;
  77. }
  78. getNavigation1();
  79. //获取导航菜单2
  80. async function getNavigation2() {
  81. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  82. method: 'GET',
  83. query: {
  84. 'pid': 0,
  85. 'num': 3,
  86. 'placeid': 11
  87. },
  88. });
  89. navigation2.value = mkdata.data;
  90. }
  91. getNavigation2();
  92. //1.获取导航菜单 end ---------------------------------------->
  93. //2.搜索 start ---------------------------------------->
  94. import { ElSelect, ElOption, ElMessage } from 'element-plus'
  95. let department = ref("") //下拉框选项
  96. const depValue = ref("") //搜索左侧下拉选择的值
  97. const typeValue = ref("") //搜索右侧框输入的值
  98. //2.1跳转到搜索页面
  99. let goToPrimary = async () => {
  100. if (depValue.value == "" || typeValue.value=="") {
  101. ElMessage.error('搜索项不能为空!')
  102. }else{
  103. const route = `/search/search?depValue=${depValue.value}&typeValue=${typeValue.value}`;
  104. window.location.href = route;
  105. }
  106. }
  107. onMounted(async () => {
  108. //2.2 获得搜索选项
  109. try {
  110. const { $webUrl, $CwebUrl } = useNuxtApp();
  111. const response = await fetch($webUrl + '/web/selectWebsiteDepartment', {
  112. headers: {
  113. 'Content-Type': 'application/json',
  114. 'Userurl': $CwebUrl,
  115. 'Origin': $CwebUrl
  116. }
  117. });
  118. const result = await response.json();
  119. department.value = result.data;
  120. } catch (error) {
  121. console.error('获取部门数据失败:', error);
  122. }
  123. })
  124. //2.搜索 end ---------------------------------------->
  125. </script>
  126. <style lang="less" scoped>
  127. @import url('@/assets/css/public/nav.less');
  128. </style>