Slider.vue 8.7 KB

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