Slider.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <!-- 滑块 -->
  3. <!-- v-if="navigation1[2]" -->
  4. <div class="slider" v-if="navigation1[2]">
  5. <!-- 标题部分 -->
  6. <div class="scienceTitle" v-if="navigation1[2]">
  7. <h5>
  8. <span>{{ navigation1[2].alias }}</span>
  9. </h5>
  10. <NuxtLink :to="`/newsList/${navigation1[2].category_id}`" target="_blank">
  11. 查看更多
  12. </NuxtLink>
  13. <!-- <span>查看更多</span> -->
  14. <!-- <p class="title">
  15. <span v-for="(item, index) in scienceTitleList" :key="index" @mousemove="changeUl(index)">
  16. <a href="#">{{ item.title }}</a>
  17. </span>
  18. </p> -->
  19. </div>
  20. <!-- 标题下内容列表 -->
  21. <div class="box">
  22. <div class="boxcontent">
  23. <div class="boxleft" v-if="boxData1[0]">
  24. <div class="boxBigImg">
  25. <NuxtLink :to="`/newsDetail/${boxData1[0].id}`" target="_blank">
  26. <img :src="boxData1[0].imgurl">
  27. <div>
  28. <p>{{ boxData1[0].title }}</p>
  29. <span>{{ boxData1[0].created_at }}</span>
  30. </div>
  31. </NuxtLink>
  32. </div>
  33. <div class="boxMainImg">
  34. <NuxtLink :to="`/newsDetail/${boxData1[1].id}`" target="_blank">
  35. <img :src="boxData1[1].imgurl">
  36. <div>
  37. <p>{{ boxData1[1].title }}</p>
  38. <span>{{ boxData1[1].created_at }}</span>
  39. </div>
  40. </NuxtLink>
  41. <NuxtLink :to="`/newsDetail/${boxData1[2].id}`" target="_blank">
  42. <img :src="boxData1[2].imgurl">
  43. <div>
  44. <p>{{ boxData1[2].title }}</p>
  45. <span>{{ boxData1[2].created_at }}</span>
  46. </div>
  47. </NuxtLink>
  48. </div>
  49. <div class="boxBigImg">
  50. <NuxtLink :to="`/newsDetail/${boxData1[3].id}`" target="_blank">
  51. <img :src="boxData1[3].imgurl">
  52. <div>
  53. <p>{{ boxData1[3].title }}</p>
  54. <span>{{ boxData1[3].created_at }}</span>
  55. </div>
  56. </NuxtLink>
  57. </div>
  58. </div>
  59. <div class="boxright">
  60. <ul>
  61. <li v-for="item in boxData2">
  62. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
  63. <p class="title">{{ item.title }}</p>
  64. <p class="time">{{ item.created_at }}</p>
  65. </NuxtLink>
  66. </li>
  67. </ul>
  68. </div>
  69. </div>
  70. <!-- <ul class="scienceList">
  71. <li v-for="item in boxData2">
  72. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
  73. <img :src="item.imgurl">
  74. <p>{{ item.title }}</p>
  75. </NuxtLink>
  76. </li>
  77. </ul> -->
  78. <!-- <transition name="fade">
  79. <div class="scienceListBox">
  80. <ul class="scienceList">
  81. <li v-for="item in boxData1">
  82. <NuxtLink
  83. :to="{ path: `/newsDetail/${item.id}`, query: { listId: routeId, listName: routeName } }"
  84. target="_blank">
  85. <img :src="item.imgurl">
  86. <p>{{ item.title }}</p>
  87. </NuxtLink>
  88. </li>
  89. </ul>
  90. <ul class="scienceList">
  91. <li v-for="item in 6">
  92. <img src="../../static/images/sgbhsihfgisdfaasda45632113_A_Chinese_farmer_carrying_a_hoe_is_h_1ba32eee-c498-4dd7-9cd9-013568c09db7.png"
  93. alt="">
  94. <p>市农业农村局关于印发连云港市市级…</p>
  95. </li>
  96. </ul>
  97. <ul class="scienceList">
  98. <li v-for="item in 6">
  99. <img src="../../static/images/rgmezdvz_19982_On_a_vast_and_boundless_wheat_field_many_harvest_5b5cfeda-ef17-4551-a935-5f8e3f799b69.png"
  100. alt="">
  101. <p>市农业农村局关于印发连云港市市级…</p>
  102. </li>
  103. </ul>
  104. <ul class="scienceList">
  105. <li v-for="item in 6">
  106. <img src="../../static/images/rgmezdvz_19982_A_Chinese_farmer_carrying_a_hoe_is_hoeing_the_fi_a036c7b3-b05e-4d3d-a371-0bed91ec1ff8(1).png"
  107. alt="">
  108. <p>市农业农村局关于印发连云港市市级…</p>
  109. </li>
  110. </ul>
  111. </div>
  112. </transition> -->
  113. </div>
  114. </div>
  115. </template>
  116. <script setup>
  117. const nuxtApp = useNuxtApp();
  118. const axios = nuxtApp.$axios;
  119. const radio1 = ref('1')
  120. const props = defineProps({
  121. message: Array,
  122. });
  123. //获取导航一的栏目
  124. const navigation1 = ref("");
  125. const navigateList = async () => {
  126. try {
  127. const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${1}&pid=${0}&num=${24}`);
  128. console.log('一级导航', response.data);
  129. navigation1.value = response.data;
  130. getWebsiteModelArticles()
  131. getWebsiteModelArticles2()
  132. } catch (error) {
  133. console.error(error);
  134. }
  135. }
  136. const boxData1 = ref("");
  137. const getWebsiteModelArticles = async () => {
  138. try {
  139. // console.log(99999999);
  140. // console.log(navigation1.value[2].category_id)
  141. let cid = navigation1.value[2].category_id
  142. const response = await axios.get(`/web/getWebsiteModelArticles?catid=${cid}&level=${1}&pagesize=${4}`);
  143. boxData1.value = response.data;
  144. } catch (error) {
  145. console.error(error);
  146. }
  147. }
  148. const boxData2 = ref("");
  149. const getWebsiteModelArticles2 = async () => {
  150. try {
  151. // console.log(99999999);
  152. // console.log(navigation1.value[2].category_id)
  153. let cid = navigation1.value[2].category_id
  154. const response = await axios.get(`/web/getWebsiteModelArticles?catid=${cid}&level=${3}&pagesize=${6}`);
  155. boxData2.value = response.data;
  156. } catch (error) {
  157. console.error(error);
  158. }
  159. }
  160. onMounted(() => {
  161. // 一级导航
  162. navigateList()
  163. })
  164. let scienceTitleList = [
  165. {
  166. id: 1,
  167. title: "农产畅销"
  168. },
  169. {
  170. id: 2,
  171. title: "农业在线"
  172. },
  173. {
  174. id: 3,
  175. title: "农产行情"
  176. },
  177. {
  178. id: 4,
  179. title: "名优特产"
  180. }
  181. ]
  182. //鼠标移入标题时,下方内容会发生变化
  183. // let changeUl = (index) => {
  184. // // console.log(index);
  185. // if (process.browser) {
  186. // let scienceListBox = document.querySelector('.scienceListBox');
  187. // let titleList = document.querySelectorAll('.title>span>a')
  188. // for (let i = 0; i < titleList.length; i++) {
  189. // titleList[i].className = ''
  190. // }
  191. // titleList[index].setAttribute('class', 'current')
  192. // if (index == 0) {
  193. // scienceListBox.style.left = 0
  194. // } else if (index == 1) {
  195. // scienceListBox.style.left = "-790px"
  196. // } else if (index == 2) {
  197. // scienceListBox.style.left = "-1580px"
  198. // } else if (index == 3) {
  199. // scienceListBox.style.left = "-2370px"
  200. // }
  201. // }
  202. // }
  203. </script>
  204. <style lang="less" scoped>
  205. .slider {
  206. width: 720px;
  207. }
  208. // 标题
  209. .scienceTitle {
  210. height: 50px;
  211. line-height: 50px;
  212. border-bottom: 1px solid #D9D9D9;
  213. display: flex;
  214. justify-content: space-between;
  215. h5 {
  216. float: left;
  217. width: 96px;
  218. height: 34px;
  219. font-family: PingFang SC, PingFang SC;
  220. font-weight: 600;
  221. font-size: 24px;
  222. color: #000000;
  223. line-height: 28px;
  224. text-align: left;
  225. font-style: normal;
  226. text-transform: none;
  227. margin-right: 20px;
  228. // border-bottom: 2px solid #139602;
  229. height: 50px;
  230. line-height: 50px;
  231. span {
  232. color: #139602;
  233. border-bottom: 3px solid #139602;
  234. height: 50px;
  235. line-height: 50px;
  236. display: inline-block;
  237. box-sizing: border-box;
  238. }
  239. }
  240. a {
  241. width: 65px;
  242. height: 50px;
  243. line-height: 50px;
  244. font-weight: 400;
  245. font-size: 16px;
  246. color: #333333;
  247. font-style: normal;
  248. text-transform: none;
  249. display: inline-block;
  250. }
  251. >p {
  252. float: left;
  253. height: 37px;
  254. line-height: 30px;
  255. >span {
  256. display: inline-block;
  257. height: 20px;
  258. line-height: 20px;
  259. text-align: center;
  260. margin: 4px 0px 3px;
  261. padding: 0 20px;
  262. border-right: 1px solid #ccc;
  263. >a {
  264. display: inline-block;
  265. padding-bottom: 11px;
  266. font-family: PingFang SC, PingFang SC;
  267. font-weight: 500;
  268. font-size: 20px;
  269. color: #666666;
  270. line-height: 20px;
  271. font-style: normal;
  272. text-transform: none;
  273. box-sizing: border-box;
  274. }
  275. .current {
  276. color: #139602;
  277. border-bottom: 1px solid #139602;
  278. }
  279. }
  280. >span:nth-child(4) {
  281. border-right: none;
  282. }
  283. >span:hover>a {
  284. color: #139602;
  285. border-bottom: 1px solid #139602;
  286. }
  287. }
  288. }
  289. .box {
  290. width: 720px;
  291. height: 700px;
  292. position: relative;
  293. overflow: hidden;
  294. .boxcontent {
  295. display: flex;
  296. justify-content: space-between;
  297. padding-top: 30px;
  298. .boxleft {
  299. width: 349px;
  300. height: 700px;
  301. padding-bottom: 30px;
  302. }
  303. }
  304. .boxMainImg {
  305. display: flex;
  306. justify-content: space-between;
  307. margin-bottom: 15px;
  308. a {
  309. position: relative;
  310. img {
  311. width: 170px;
  312. height: 115px;
  313. border-radius: 4px;
  314. border-radius: 6px;
  315. }
  316. div {
  317. position: absolute;
  318. bottom: 4px;
  319. left: 7px;
  320. p {
  321. display: -webkit-box;
  322. -webkit-box-orient: vertical;
  323. -webkit-line-clamp: 2;
  324. overflow: hidden;
  325. text-overflow: ellipsis;
  326. word-break: break-all;
  327. width: 158px;
  328. height: 42px;
  329. color: #fff;
  330. }
  331. span {
  332. display:block;
  333. height: 20px;
  334. line-height: 20px;
  335. text-align: left;
  336. color: #fff;
  337. }
  338. }
  339. }
  340. }
  341. .boxBigImg {
  342. margin-bottom: 15px;
  343. a {
  344. position: relative;
  345. img {
  346. width: 349px;
  347. height: 236px;
  348. border-radius: 6px;
  349. }
  350. div {
  351. position: absolute;
  352. bottom: 7px;
  353. left: 20px;
  354. p{
  355. display: -webkit-box;
  356. -webkit-box-orient: vertical;
  357. -webkit-line-clamp: 2;
  358. overflow: hidden;
  359. text-overflow: ellipsis;
  360. word-break: break-all;
  361. width: 320px;
  362. height: 42px;
  363. color: #fff;
  364. }
  365. span {
  366. display:block;
  367. height: 20px;
  368. line-height: 20px;
  369. text-align: left;
  370. color: #fff;
  371. }
  372. }
  373. }
  374. }
  375. }
  376. .fade-in {
  377. animation: fadeIn 1s ease-in-out;
  378. }
  379. .fade-enter-from,
  380. .fade-leave-to {
  381. opacity: 0;
  382. }
  383. .fade-enter-to,
  384. .fade-leave-from {
  385. opacity: 1;
  386. }
  387. .fade-enter-active,
  388. .fade-leave-active {
  389. transition: opacity 1s ease;
  390. }
  391. .scienceListBox {
  392. width: 3160px;
  393. height: 570px;
  394. position: absolute;
  395. top: 0;
  396. left: 0;
  397. transition: all 3s linear 0;
  398. }
  399. // 标题下列表
  400. .scienceList {
  401. width: 790px;
  402. height: 570px;
  403. float: left;
  404. margin-top: 17px;
  405. >li {
  406. width: 250px;
  407. height: 276px;
  408. float: left;
  409. margin-right: 20px;
  410. position: relative;
  411. img {
  412. width: 250px;
  413. height: 220px;
  414. border-radius: 40px 4px 40px 4px;
  415. }
  416. p {
  417. width: 254px;
  418. display: -webkit-box;
  419. -webkit-box-orient: vertical;
  420. -webkit-line-clamp: 2;
  421. overflow: hidden;
  422. text-overflow: ellipsis;
  423. word-break: break-all;
  424. height: 48px;
  425. overflow: hidden;
  426. font-family: PingFang SC, PingFang SC;
  427. font-weight: 600;
  428. font-size: 18px;
  429. color: #333333;
  430. line-height: 24px;
  431. text-align: left;
  432. font-style: normal;
  433. text-transform: none;
  434. }
  435. p:hover {
  436. color: #139602;
  437. }
  438. }
  439. >li:nth-child(3),
  440. >li:nth-child(6) {
  441. margin-right: 0;
  442. }
  443. >li::before {
  444. content: "";
  445. display: inline-block;
  446. width: 40px;
  447. height: 20px;
  448. position: absolute;
  449. top: 0;
  450. right: 0;
  451. background-image: url("../../static/images/Component 209.png");
  452. }
  453. }
  454. .boxright {
  455. ul {
  456. li {
  457. width: 349px;
  458. box-sizing: border-box;
  459. border-bottom: 1px solid #E6E6E6;
  460. margin-bottom: 20px;
  461. padding-bottom: 10px;
  462. .title {
  463. height: 42px;
  464. display: -webkit-box;
  465. -webkit-box-orient: vertical;
  466. -webkit-line-clamp: 2;
  467. overflow: hidden;
  468. text-overflow: ellipsis;
  469. word-break: break-all;
  470. height: 42px;
  471. width: 100%;
  472. font-size: 16px;
  473. color: #333333;
  474. margin-bottom: 5px;
  475. }
  476. .time {
  477. font-size: 14px;
  478. color: #999999;
  479. margin-bottom: 10px;
  480. }
  481. }
  482. }
  483. }
  484. </style>