Slider.vue 13 KB

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