Slider.vue 13 KB

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