pageNavigation.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <!-- 导航 -->
  3. <div class="navigate">
  4. <div class="partOne">
  5. <div class="inner">
  6. <!-- 导航一 -->
  7. <div class="navLeft">
  8. <div class="navIndex">
  9. <NuxtLink to="/" title="首页">
  10. 首页
  11. </NuxtLink>
  12. </div>
  13. <div class="navClass">
  14. <div>乡村资讯</div>
  15. <div>社会资讯</div>
  16. </div>
  17. </div>
  18. <ul class="navigationOne" v-if="navigation1.length > 0">
  19. <li v-for="(item, index) in navigation1" :key="index">
  20. <NuxtLink :to="getLinkPath(item)" :target="item.is_url == 1 ? '_blank' : '_self'">
  21. <span>{{ item.alias }}</span>
  22. </NuxtLink>
  23. </li>
  24. </ul>
  25. <div class="navRight" v-if="navigation2.length > 0">
  26. <div class="nav111" v-for="(item, index) in navigation2" :key="index">
  27. <NuxtLink :to="getLinkPath(item)" :target="item.is_url == 1 ? '_blank' : '_self'">
  28. <span>{{ item.alias }}</span>
  29. </NuxtLink>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="partTwo">
  35. <div class="inner">
  36. <h3>
  37. 深度服务
  38. </h3>
  39. <ul class="partTwoTitle" v-if="navigation3.length > 0">
  40. <li class="titleList" v-for="(item, index) in navigation3" :key="index">
  41. <NuxtLink :to="getLinkPath(item)" :target="item.is_url == 1 ? '_blank' : '_self'">
  42. <span>{{ item.alias }}</span>
  43. </NuxtLink>
  44. </li>
  45. </ul>
  46. <div class="searchBox">
  47. <input v-model="keywords" type="text" placeholder="请输入关键词" @keydown.enter="goToSearch">
  48. <img src="../../public/image/search.png" @keydown.enter="goToSearch" @click="goSearch">
  49. </div>
  50. </div>
  51. </div>
  52. <div class="littleNav">
  53. <div class="inner">
  54. <img src="../../public/index/hdpt.png" alt="">
  55. <ul class="leftPart" v-if="navigation4.length > 0">
  56. <li class="navList" v-for="item in navigation4" :key="index">
  57. <NuxtLink :to="getLinkPath(item)" :target="item.is_url == 1 ? '_blank' : '_self'">
  58. <span>{{ item.alias }}</span>
  59. </NuxtLink>
  60. </li>
  61. </ul>
  62. <ul class="rightPart" v-if="navigation4data2.length > 0">
  63. <li class="navList" v-for="item in navigation4data2" :key="index">
  64. <NuxtLink :to="getLinkPath(item)" :target="item.is_url == 1 ? '_blank' : '_self'">
  65. <span>{{ item.alias }}</span>
  66. </NuxtLink>
  67. </li>
  68. </ul>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script setup>
  74. //1.加载依赖 start ---------------------------------------->
  75. //1.加载依赖 end ---------------------------------------->
  76. //2.页面公用方法 start ---------------------------------------->
  77. const getLinkPath = (item) => {
  78. if (item.is_url == 1) {
  79. return `${item.web_url}`;
  80. } else if (item.children_count == 0) {
  81. //return `/newsList/${item.category_id}?page=1`;
  82. return `/${item.aLIas_pinyin}/list-1.html`;
  83. } else {
  84. //return `/primaryNavigation/${item.aLIas_pinyin}/`;
  85. return `/${item.aLIas_pinyin}/index.html`;
  86. }
  87. }
  88. //搜索跳转
  89. //点击搜索按钮
  90. let goSearch = () => {
  91. const route = `/search/search?keyword=${keywords.value}`;
  92. window.location.href = route;
  93. }
  94. //2.页面公用方法 end ---------------------------------------->
  95. //3.获取导航菜单 start ---------------------------------------->
  96. const navigation1 = ref([]);
  97. //2是那个独立的2个
  98. const navigation2 = ref([]);
  99. const navigation3 = ref([]);
  100. //下面一行是2边分开的 一边5个
  101. const navigation4 = ref([]);
  102. const navigation4data2 = ref([]);
  103. //获取导航菜单1
  104. async function getNavigation1() {
  105. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  106. method: 'GET',
  107. query: {
  108. 'pid': 0,
  109. 'num': 20,
  110. 'placeid': 1
  111. },
  112. });
  113. navigation1.value = mkdata.data;
  114. }
  115. getNavigation1();
  116. //获取导航菜单2
  117. async function getNavigation2() {
  118. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  119. method: 'GET',
  120. query: {
  121. 'pid': 0,
  122. 'num': 2,
  123. 'placeid': 21
  124. },
  125. });
  126. navigation2.value = mkdata.data;
  127. }
  128. getNavigation2();
  129. //获取导航菜单4
  130. async function getNavigation4() {
  131. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  132. method: 'GET',
  133. query: {
  134. 'pid': 0,
  135. 'num': 10,
  136. 'placeid': 23
  137. },
  138. });
  139. for (let i in mkdata.data) {
  140. if (i < 5) {
  141. navigation4.value.push(mkdata.data[i]);
  142. } else {
  143. navigation4data2.value.push(mkdata.data[i]);
  144. }
  145. }
  146. //navigation4.value = mkdata.data;
  147. //navigation4data2.value = mkdata.data;
  148. }
  149. getNavigation4();
  150. //获取导航菜单3
  151. async function getNavigation3() {
  152. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  153. method: 'GET',
  154. query: {
  155. 'pid': 0,
  156. 'num': 6,
  157. 'placeid': 33
  158. },
  159. });
  160. navigation3.value = mkdata.data;
  161. }
  162. getNavigation3();
  163. //3.获取导航菜单 end ---------------------------------------->
  164. //4.跳转到搜索页面 start ---------------------------------------->
  165. const keywords = ref("")
  166. let goToSearch = () => {
  167. const route = "/search/search?keyword=" + keywords.value;
  168. window.open(route, '_blank');
  169. }
  170. //4.跳转到搜索页面 end ---------------------------------------->
  171. </script>
  172. <style lang="less" scoped>
  173. // 导航部分
  174. .partOne .navigationOne,
  175. .partOne .navigationOne>li {
  176. float: left;
  177. }
  178. .partOne {
  179. width: 100%;
  180. height: 133px;
  181. // margin-bottom: 10px;
  182. background-color: #a01c0e;
  183. font-size: 20px;
  184. font-family: PingFang SC-Semibold;
  185. .inner {
  186. display: flex;
  187. justify-content: space-between;
  188. .navLeft {
  189. width: 160px;
  190. font-size: 16px;
  191. display: flex;
  192. }
  193. .navIndex {
  194. height: 100px;
  195. line-height: 130px;
  196. a {
  197. font-weight: bold;
  198. font-size: 16px;
  199. color: #F8ECD2;
  200. }
  201. }
  202. .navClass {
  203. padding-top: 35px;
  204. padding-left: 30px;
  205. font-weight: bold;
  206. color: #F8ECD2;
  207. div:nth-child(2) {
  208. padding-top: 17px;
  209. }
  210. }
  211. }
  212. .navigationOne {
  213. width: 1200px;
  214. color: #333;
  215. display: flex;
  216. flex-wrap: wrap;
  217. padding-top: 24px;
  218. li {
  219. width: 74px;
  220. font-family: PingFang SC;
  221. height: 42px;
  222. line-height: 42px;
  223. //font-weight: 600;
  224. font-size: 16px;
  225. text-align: left;
  226. font-style: normal;
  227. text-transform: none;
  228. margin: 0 10px;
  229. text-align: center;
  230. a {
  231. font-weight: 400;
  232. font-size: 16px;
  233. color: #FFFFFF;
  234. display: block;
  235. }
  236. }
  237. >li:hover a {
  238. color: #F8ECD2;
  239. }
  240. .active {
  241. color: #F8ECD2;
  242. }
  243. }
  244. .navRight {
  245. width: 135px;
  246. height: 75px;
  247. font-size: 16px;
  248. margin-top: 30px;
  249. background: url(https://img.bjzxtw.org.cn/master/www/xcw/nav_bg.png) no-repeat;
  250. .nav111 {
  251. width: 98px;
  252. height: 30px;
  253. line-height: 44px;
  254. text-align: center;
  255. font-family: Microsoft YaHei, Microsoft YaHei;
  256. font-weight: bold;
  257. font-size: 16px;
  258. a {
  259. font-weight: bold;
  260. background: linear-gradient(to bottom, #FFF6B1 0%, #F5BC38 100%);
  261. -webkit-background-clip: text;
  262. color: transparent;
  263. }
  264. }
  265. }
  266. }
  267. .partTwo {
  268. width: 100%;
  269. height: 60px;
  270. line-height: 60px;
  271. // border-bottom: 1px solid #e3e3e3;
  272. background-color: #fafafa;
  273. .inner {
  274. width: 1200px;
  275. height: 57px;
  276. display: flex;
  277. // justify-content: space-between;
  278. h3 {
  279. font-family: Microsoft YaHei, Microsoft YaHei;
  280. font-weight: bold;
  281. font-size: 16px;
  282. padding-left: 60px;
  283. a {
  284. color: #333333;
  285. }
  286. }
  287. .partTwoTitle {
  288. display: flex;
  289. justify-content: flex-start;
  290. width: 633px;
  291. padding-left: 30px;
  292. padding-right: 30px;
  293. .titleList {
  294. font-size: 16px;
  295. font-family: PingFang SC, PingFang SC;
  296. font-weight: 400;
  297. margin-right: 25px;
  298. a {
  299. color: #333333;
  300. }
  301. }
  302. .titleList:hover a {
  303. color: #A01C0E;
  304. }
  305. }
  306. .searchBox {
  307. width: 356px;
  308. height: 40px;
  309. line-height: 40px;
  310. background-color: #fff;
  311. margin-top: 10px;
  312. border-radius: 25px;
  313. border: 1px solid #ededed;
  314. input {
  315. width: 285px;
  316. height: 35px;
  317. line-height: 35px;
  318. margin-left: 20px;
  319. border: none;
  320. outline: none;
  321. }
  322. img {
  323. width: 32px;
  324. height: 32px;
  325. vertical-align: middle;
  326. cursor: pointer;
  327. }
  328. }
  329. }
  330. }
  331. //小导航
  332. .littleNav {
  333. width: 100%;
  334. height: 88px;
  335. margin-top: 15px;
  336. .inner {
  337. width: 1200px;
  338. height: 88px;
  339. line-height: 88px;
  340. margin: 0 auto;
  341. display: flex;
  342. border: 1px solid #D3D5D8;
  343. background-color: #fafafa;
  344. img {
  345. width: 138px;
  346. height: 28px;
  347. margin-top: 30px;
  348. margin-left: 25px;
  349. }
  350. .leftPart {
  351. margin-left: 40px;
  352. margin-right: 10px;
  353. }
  354. .leftPart,
  355. .rightPart {
  356. width: 470px;
  357. height: 78px;
  358. margin-top: 5px;
  359. display: flex;
  360. align-items: center;
  361. justify-content: space-between;
  362. padding: 0 10px;
  363. border-bottom: 3px solid #A01C0E;
  364. .navList {
  365. a {
  366. font-family: Microsoft YaHei, Microsoft YaHei;
  367. font-weight: bold;
  368. font-size: 16px;
  369. color: #333333;
  370. line-height: 19px;
  371. }
  372. }
  373. .navList:hover a {
  374. color: #A01C0E;
  375. }
  376. }
  377. }
  378. }
  379. </style>