Slider.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <!-- 滑块 -->
  3. <div class="slider">
  4. <!-- 标题部分 -->
  5. <div class="scienceTitle">
  6. <h5>{{ navigation1[16]?.alias }}</h5>
  7. <!-- <p class="title">
  8. <span v-for="(item, index) in scienceTitleList" :key="index" @mousemove="changeUl(index)">
  9. <a href="#">{{ item.title }}</a>
  10. </span>
  11. </p> -->
  12. </div>
  13. <!-- 标题下内容列表 -->
  14. <div class="box">
  15. <ul class="scienceList">
  16. <li v-for="item in boxData1">
  17. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
  18. <img :src="item.imgurl">
  19. <p>{{ item.title }}</p>
  20. </NuxtLink>
  21. </li>
  22. </ul>
  23. <!-- <transition name="fade">
  24. <div class="scienceListBox">
  25. <ul class="scienceList">
  26. <li v-for="item in boxData1">
  27. <NuxtLink
  28. :to="{ path: `/newsDetail/${item.id}`, query: { listId: routeId, listName: routeName } }"
  29. target="_blank">
  30. <img :src="item.imgurl">
  31. <p>{{ item.title }}</p>
  32. </NuxtLink>
  33. </li>
  34. </ul>
  35. <ul class="scienceList">
  36. <li v-for="item in 6">
  37. <img src="../../static/images/sgbhsihfgisdfaasda45632113_A_Chinese_farmer_carrying_a_hoe_is_h_1ba32eee-c498-4dd7-9cd9-013568c09db7.png"
  38. alt="">
  39. <p>市农业农村局关于印发连云港市市级…</p>
  40. </li>
  41. </ul>
  42. <ul class="scienceList">
  43. <li v-for="item in 6">
  44. <img src="../../static/images/rgmezdvz_19982_On_a_vast_and_boundless_wheat_field_many_harvest_5b5cfeda-ef17-4551-a935-5f8e3f799b69.png"
  45. alt="">
  46. <p>市农业农村局关于印发连云港市市级…</p>
  47. </li>
  48. </ul>
  49. <ul class="scienceList">
  50. <li v-for="item in 6">
  51. <img src="../../static/images/rgmezdvz_19982_A_Chinese_farmer_carrying_a_hoe_is_hoeing_the_fi_a036c7b3-b05e-4d3d-a371-0bed91ec1ff8(1).png"
  52. alt="">
  53. <p>市农业农村局关于印发连云港市市级…</p>
  54. </li>
  55. </ul>
  56. </div>
  57. </transition> -->
  58. </div>
  59. </div>
  60. </template>
  61. <script setup>
  62. const nuxtApp = useNuxtApp();
  63. const axios = nuxtApp.$axios;
  64. const radio1 = ref('1')
  65. //获取导航一的栏目
  66. const navigation1 = ref("");
  67. const navigateList = async () => {
  68. try {
  69. const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${1}&pid=${0}&num=${24}`);
  70. console.log('一级导航', response.data);
  71. navigation1.value = response.data;
  72. } catch (error) {
  73. console.error(error);
  74. }
  75. }
  76. const boxData1 = ref("");
  77. const getWebsiteModelArticles = async () => {
  78. try {
  79. const response = await axios.get(`/web/getWebsiteModelArticles?catid=${16}&level=${1}&pagesize=${6}`);
  80. console.log('一级导航', response.data);
  81. boxData1.value = response.data;
  82. } catch (error) {
  83. console.error(error);
  84. }
  85. }
  86. onMounted(() => {
  87. // 一级导航
  88. navigateList()
  89. getWebsiteModelArticles()
  90. })
  91. let scienceTitleList = [
  92. {
  93. id: 1,
  94. title: "农产畅销"
  95. },
  96. {
  97. id: 2,
  98. title: "农业在线"
  99. },
  100. {
  101. id: 3,
  102. title: "农产行情"
  103. },
  104. {
  105. id: 4,
  106. title: "名优特产"
  107. }
  108. ]
  109. //鼠标移入标题时,下方内容会发生变化
  110. // let changeUl = (index) => {
  111. // // console.log(index);
  112. // if (process.browser) {
  113. // let scienceListBox = document.querySelector('.scienceListBox');
  114. // let titleList = document.querySelectorAll('.title>span>a')
  115. // for (let i = 0; i < titleList.length; i++) {
  116. // titleList[i].className = ''
  117. // }
  118. // titleList[index].setAttribute('class', 'current')
  119. // if (index == 0) {
  120. // scienceListBox.style.left = 0
  121. // } else if (index == 1) {
  122. // scienceListBox.style.left = "-790px"
  123. // } else if (index == 2) {
  124. // scienceListBox.style.left = "-1580px"
  125. // } else if (index == 3) {
  126. // scienceListBox.style.left = "-2370px"
  127. // }
  128. // }
  129. // }
  130. </script>
  131. <style lang="less" scoped>
  132. // 标题
  133. .scienceTitle {
  134. height: 37px;
  135. h5 {
  136. float: left;
  137. width: 96px;
  138. height: 34px;
  139. font-family: PingFang SC, PingFang SC;
  140. font-weight: 600;
  141. font-size: 24px;
  142. color: #000000;
  143. line-height: 28px;
  144. text-align: left;
  145. font-style: normal;
  146. text-transform: none;
  147. margin-right: 20px;
  148. }
  149. >p {
  150. float: left;
  151. height: 37px;
  152. line-height: 30px;
  153. >span {
  154. display: inline-block;
  155. height: 20px;
  156. line-height: 20px;
  157. text-align: center;
  158. margin: 4px 0px 3px;
  159. padding: 0 20px;
  160. border-right: 1px solid #ccc;
  161. >a {
  162. display: inline-block;
  163. padding-bottom: 11px;
  164. font-family: PingFang SC, PingFang SC;
  165. font-weight: 500;
  166. font-size: 20px;
  167. color: #666666;
  168. line-height: 20px;
  169. font-style: normal;
  170. text-transform: none;
  171. box-sizing: border-box;
  172. }
  173. .current {
  174. color: #139602;
  175. border-bottom: 1px solid #139602;
  176. }
  177. }
  178. >span:nth-child(4) {
  179. border-right: none;
  180. }
  181. >span:hover>a {
  182. color: #139602;
  183. border-bottom: 1px solid #139602;
  184. }
  185. }
  186. }
  187. .box {
  188. width: 790px;
  189. height: 570px;
  190. position: relative;
  191. overflow: hidden;
  192. }
  193. .fade-in {
  194. animation: fadeIn 1s ease-in-out;
  195. }
  196. .fade-enter-from,
  197. .fade-leave-to {
  198. opacity: 0;
  199. }
  200. .fade-enter-to,
  201. .fade-leave-from {
  202. opacity: 1;
  203. }
  204. .fade-enter-active,
  205. .fade-leave-active {
  206. transition: opacity 1s ease;
  207. }
  208. .scienceListBox {
  209. width: 3160px;
  210. height: 570px;
  211. position: absolute;
  212. top: 0;
  213. left: 0;
  214. transition: all 3s linear 0;
  215. }
  216. // 标题下列表
  217. .scienceList {
  218. width: 790px;
  219. height: 570px;
  220. float: left;
  221. margin-top: 17px;
  222. >li {
  223. width: 250px;
  224. height: 276px;
  225. float: left;
  226. margin-right: 20px;
  227. position: relative;
  228. img {
  229. width: 250px;
  230. height: 220px;
  231. }
  232. p {
  233. width: 254px;
  234. display: -webkit-box;
  235. -webkit-box-orient: vertical;
  236. -webkit-line-clamp: 2;
  237. overflow: hidden;
  238. text-overflow: ellipsis;
  239. word-break: break-all;
  240. height: 48px;
  241. overflow: hidden;
  242. font-family: PingFang SC, PingFang SC;
  243. font-weight: 600;
  244. font-size: 18px;
  245. color: #333333;
  246. line-height: 24px;
  247. text-align: left;
  248. font-style: normal;
  249. text-transform: none;
  250. }
  251. p:hover {
  252. color: #139602;
  253. }
  254. }
  255. >li:nth-child(3),
  256. >li:nth-child(6) {
  257. margin-right: 0;
  258. }
  259. >li::before {
  260. content: "";
  261. display: inline-block;
  262. width: 40px;
  263. height: 20px;
  264. position: absolute;
  265. top: 0;
  266. right: 0;
  267. background-image: url("../../static/images/Component 209.png");
  268. }
  269. }
  270. </style>