Slider.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <div class="slider" v-if="message">
  3. <div class="scienceTitle" v-if="message">
  4. <h5 v-if="message.cid">
  5. <NuxtLink
  6. v-if="message.cid"
  7. :href="getLinkPath(message)"
  8. class="active"
  9. :title="message.alias"
  10. >
  11. {{message.title}}
  12. </NuxtLink>
  13. </h5>
  14. <NuxtLink
  15. v-if="message.cid"
  16. :href="getLinkPath(message)"
  17. :title="message.alias"
  18. >
  19. 查看更多
  20. </NuxtLink>
  21. </div>
  22. <!-- 标题下内容列表 -->
  23. <div class="box">
  24. <div class="boxcontent">
  25. <div class="boxleft" v-if="boxData1[0]">
  26. <div class="boxBigImg">
  27. <NuxtLink :to="`/newsDetail/${boxData1[0].id}`" class="imgbg" :title="boxData1[0].title">
  28. <img :src="boxData1[0].imgurl" :alt="boxData1[0].title">
  29. <div>
  30. <p><span>专题</span>{{ boxData1[0].title }}</p>
  31. </div>
  32. </NuxtLink>
  33. </div>
  34. <div class="boxMainImg">
  35. <NuxtLink :to="`/newsDetail/${boxData1[1].id}`" class="imgbg" :title="boxData1[1].title">
  36. <img :src="boxData1[1].imgurl" :alt="boxData1[1].title">
  37. <div>
  38. <p>{{boxData1[1].title}}</p>
  39. </div>
  40. </NuxtLink>
  41. <NuxtLink :to="`/newsDetail/${boxData1[2].id}`" class="imgbg" :title="boxData1[2].title">
  42. <img :src="boxData1[2].imgurl" :alt="boxData1[2].title">
  43. <div>
  44. <p>{{boxData1[2].title}}</p>
  45. </div>
  46. </NuxtLink>
  47. </div>
  48. <div class="boxBigImg">
  49. <NuxtLink :to="`/newsDetail/${boxData1[3].id}`" class="imgbg" :title="boxData1[3].title">
  50. <img :src="boxData1[3].imgurl" :alt="boxData1[3].title">
  51. <div>
  52. <p>{{boxData1[3].title}}</p>
  53. </div>
  54. </NuxtLink>
  55. </div>
  56. </div>
  57. <div class="boxright">
  58. <ul>
  59. <li v-for="item in boxData2">
  60. <NuxtLink :to="`/newsDetail/${item.id}`" :title="item.title">
  61. <p class="title">{{item.title}}</p>
  62. </NuxtLink>
  63. </li>
  64. </ul>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <script setup>
  71. //1.获得传入的数据 start---------------------------------------->
  72. const props = defineProps({
  73. message: Array,
  74. });
  75. //1.获得传入的数据 end---------------------------------------->
  76. //2.获得本页的数据 start---------------------------------------->
  77. const boxData1 = ref([]);
  78. const boxData2 = ref([]);
  79. if(props.message){
  80. //政策法规 导航池1 图文4 文字6 模块1
  81. await getPageData(1,4,8,3);
  82. }
  83. //注意,政策法规下面还有一个政策法规
  84. //当前这个是二级分类页面,你进去以后显示的是他的子导航
  85. async function getPageData(catid,img_num,text_num,modulesNum){
  86. const mkdata = await requestDataPromise('/web/getWebsiteCatidArticle', {
  87. method: 'GET',
  88. query: {
  89. 'catid': catid, //catid
  90. 'img_num': img_num, //图片数量
  91. 'text_num': text_num //文字数量
  92. },
  93. });
  94. //模块1新农村
  95. if(modulesNum == 3){
  96. boxData1.value = mkdata.data.img;
  97. boxData2.value = mkdata.data.text;
  98. }
  99. }
  100. //格式化跳转路径 - 标题
  101. const getLinkPath = (item) => {
  102. if (item.children_count == 0) {
  103. return `/newsList/${item.cid}`;
  104. } else {
  105. return `/${item.url}/`;
  106. }
  107. }
  108. //格式化跳转路径 - 到详情
  109. const getLinkPathDetail = (item) => {
  110. if (item.islink == 1) {
  111. return `${item.linkurl}`;
  112. } else {
  113. return `/newsDetail/${item.id}`;
  114. }
  115. }
  116. //2.获得本页的数据 end---------------------------------------->
  117. </script>
  118. <style lang="less" scoped>
  119. .slider {
  120. width: 720px;
  121. }
  122. // 标题
  123. .scienceTitle {
  124. height: 50px;
  125. line-height: 50px;
  126. border-bottom: 1px solid #D9D9D9;
  127. display: flex;
  128. justify-content: space-between;
  129. h5 {
  130. float: left;
  131. width: 96px;
  132. height: 34px;
  133. font-family: PingFang SC, PingFang SC;
  134. font-weight: 600;
  135. font-size: 24px;
  136. color: #000000;
  137. line-height: 28px;
  138. text-align: left;
  139. font-style: normal;
  140. text-transform: none;
  141. margin-right: 20px;
  142. // border-bottom: 2px solid #139602;
  143. height: 50px;
  144. line-height: 50px;
  145. a {
  146. font-size: 22px;
  147. color: #139602;
  148. border-bottom: 3px solid #139602;
  149. height: 50px;
  150. line-height: 50px;
  151. display: inline-block;
  152. box-sizing: border-box;
  153. width: auto;
  154. font-weight: bold;
  155. }
  156. }
  157. a {
  158. width: 65px;
  159. height: 50px;
  160. line-height: 50px;
  161. font-weight: 400;
  162. font-size: 16px;
  163. color: #333333;
  164. font-style: normal;
  165. text-transform: none;
  166. display: inline-block;
  167. }
  168. >p {
  169. float: left;
  170. height: 37px;
  171. line-height: 30px;
  172. >span {
  173. display: inline-block;
  174. height: 20px;
  175. line-height: 20px;
  176. text-align: center;
  177. margin: 4px 0px 3px;
  178. padding: 0 20px;
  179. border-right: 1px solid #ccc;
  180. >a {
  181. display: inline-block;
  182. padding-bottom: 11px;
  183. font-family: PingFang SC, PingFang SC;
  184. font-weight: 500;
  185. font-size: 20px;
  186. color: #666666;
  187. line-height: 20px;
  188. font-style: normal;
  189. text-transform: none;
  190. box-sizing: border-box;
  191. }
  192. .current {
  193. color: #139602;
  194. border-bottom: 1px solid #139602;
  195. }
  196. }
  197. >span:nth-child(4) {
  198. border-right: none;
  199. }
  200. >span:hover>a {
  201. color: #139602;
  202. border-bottom: 1px solid #139602;
  203. }
  204. }
  205. }
  206. .box {
  207. width: 720px;
  208. height: 700px;
  209. position: relative;
  210. overflow: hidden;
  211. .boxcontent {
  212. display: flex;
  213. justify-content: space-between;
  214. padding-top: 30px;
  215. .boxleft {
  216. width: 349px;
  217. height: 700px;
  218. padding-bottom: 30px;
  219. }
  220. }
  221. .boxMainImg {
  222. display: flex;
  223. justify-content: space-between;
  224. margin-bottom: 15px;
  225. a {
  226. position: relative;
  227. width: 170px;
  228. height: 115px;
  229. display: block;
  230. img {
  231. width: 170px;
  232. height: 115px;
  233. border-radius: 4px;
  234. border-radius: 6px;
  235. }
  236. div {
  237. position: absolute;
  238. bottom: 0;
  239. left: 7px;
  240. z-index: 99;
  241. p {
  242. display: -webkit-box;
  243. -webkit-box-orient: vertical;
  244. -webkit-line-clamp: 2;
  245. overflow: hidden;
  246. text-overflow: ellipsis;
  247. word-break: break-all;
  248. width: 158px;
  249. height: 23px;
  250. color: #fff;
  251. }
  252. span {
  253. display:block;
  254. height: 20px;
  255. line-height: 20px;
  256. text-align: left;
  257. color: #fff;
  258. }
  259. }
  260. }
  261. }
  262. .boxBigImg {
  263. margin-bottom: 15px;
  264. a {
  265. position: relative;
  266. width: 349px;
  267. height: 236px;
  268. border-radius: 6px;
  269. display: block;
  270. img {
  271. width: 349px;
  272. height: 236px;
  273. border-radius: 6px;
  274. }
  275. div {
  276. position: absolute;
  277. bottom: 7px;
  278. left: 20px;
  279. z-index: 99;
  280. p{
  281. display: -webkit-box;
  282. -webkit-box-orient: vertical;
  283. -webkit-line-clamp: 2;
  284. overflow: hidden;
  285. text-overflow: ellipsis;
  286. word-break: break-all;
  287. width: 320px;
  288. height: 24px;
  289. color: #fff;
  290. font-size: 16px;
  291. margin-bottom: 5px;
  292. span {
  293. display: inline-block;
  294. background: #9CD26B;
  295. font-size: 14px;
  296. color: #fff;
  297. padding: 0 6px;
  298. border-radius: 4px;
  299. margin-right: 5px;
  300. }
  301. }
  302. span {
  303. display:block;
  304. height: 20px;
  305. line-height: 20px;
  306. text-align: left;
  307. color: #fff;
  308. }
  309. }
  310. }
  311. }
  312. }
  313. .fade-in {
  314. animation: fadeIn 1s ease-in-out;
  315. }
  316. .fade-enter-from,
  317. .fade-leave-to {
  318. opacity: 0;
  319. }
  320. .fade-enter-to,
  321. .fade-leave-from {
  322. opacity: 1;
  323. }
  324. .fade-enter-active,
  325. .fade-leave-active {
  326. transition: opacity 1s ease;
  327. }
  328. .scienceListBox {
  329. width: 3160px;
  330. height: 570px;
  331. position: absolute;
  332. top: 0;
  333. left: 0;
  334. transition: all 3s linear 0;
  335. z-index: 99;
  336. }
  337. // 标题下列表
  338. .scienceList {
  339. width: 790px;
  340. height: 570px;
  341. float: left;
  342. margin-top: 17px;
  343. >li {
  344. width: 250px;
  345. height: 276px;
  346. float: left;
  347. margin-right: 20px;
  348. position: relative;
  349. img {
  350. width: 250px;
  351. height: 220px;
  352. border-radius: 40px 4px 40px 4px;
  353. }
  354. p {
  355. width: 254px;
  356. display: -webkit-box;
  357. -webkit-box-orient: vertical;
  358. -webkit-line-clamp: 2;
  359. overflow: hidden;
  360. text-overflow: ellipsis;
  361. word-break: break-all;
  362. height: 48px;
  363. overflow: hidden;
  364. font-family: PingFang SC, PingFang SC;
  365. font-weight: 600;
  366. font-size: 18px;
  367. color: #333333;
  368. line-height: 24px;
  369. text-align: left;
  370. font-style: normal;
  371. text-transform: none;
  372. }
  373. p:hover {
  374. color: #139602;
  375. }
  376. }
  377. >li:nth-child(3),
  378. >li:nth-child(6) {
  379. margin-right: 0;
  380. }
  381. >li::before {
  382. content: "";
  383. display: inline-block;
  384. width: 40px;
  385. height: 20px;
  386. position: absolute;
  387. z-index: 99;
  388. top: 0;
  389. right: 0;
  390. background-image: url("../../static/images/Component 209.png");
  391. }
  392. }
  393. .boxright {
  394. ul {
  395. li {
  396. width: 349px;
  397. box-sizing: border-box;
  398. border-bottom: 1px solid #E6E6E6;
  399. margin-bottom: 21px;
  400. padding-bottom: 10px;
  401. .title {
  402. height: 42px;
  403. display: -webkit-box;
  404. -webkit-box-orient: vertical;
  405. -webkit-line-clamp: 2;
  406. overflow: hidden;
  407. text-overflow: ellipsis;
  408. word-break: break-all;
  409. height: 42px;
  410. width: 100%;
  411. font-size: 16px;
  412. color: #333333;
  413. margin-bottom: 5px;
  414. }
  415. .title:hover {
  416. color: #49A769;
  417. }
  418. .time {
  419. font-size: 14px;
  420. color: #999999;
  421. margin-bottom: 10px;
  422. }
  423. }
  424. }
  425. }
  426. .imgbg::after{
  427. content: '';
  428. display: block;
  429. width:100%;
  430. height:68px;
  431. z-index:44;
  432. left:0px;
  433. bottom:0;
  434. position:absolute;
  435. background:linear-gradient(to bottom,rgba(0,0,0,0),black);
  436. opacity:.3;
  437. border-radius: 6px;
  438. }
  439. </style>