Slider.vue 8.8 KB

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