Slider.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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></span>
  30. <!-- <span>{{getTime(boxData1[0].updated_at,'month',1)}}</span> -->
  31. </div>
  32. </NuxtLink>
  33. </div>
  34. <div class="boxMainImg">
  35. <NuxtLink :to="`/newsDetail/${boxData1[1].id}`" target="_blank" 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. <span></span>
  40. <!-- <span>{{getTime(boxData1[1].updated_at,'month',1)}}</span> -->
  41. </div>
  42. </NuxtLink>
  43. <NuxtLink :to="`/newsDetail/${boxData1[2].id}`" target="_blank" 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></span>
  48. <!-- <span>{{getTime(boxData1[2].updated_at,'month',1)}}</span> -->
  49. </div>
  50. </NuxtLink>
  51. </div>
  52. <div class="boxBigImg">
  53. <NuxtLink :to="`/newsDetail/${boxData1[3].id}`" target="_blank" class="imgbg" :title="boxData1[3].title">
  54. <img :src="boxData1[3].imgurl" :alt="boxData1[3].title">
  55. <div>
  56. <p>{{boxData1[3].title}}</p>
  57. <span></span>
  58. <!-- <span>{{getTime(boxData1[3].updated_at,'month',1)}}</span> -->
  59. </div>
  60. </NuxtLink>
  61. </div>
  62. </div>
  63. <div class="boxright">
  64. <ul>
  65. <li v-for="item in boxData2">
  66. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank" :title="item.title">
  67. <p class="title">{{item.title}}</p>
  68. <p class="time">&nbsp;</p>
  69. <!-- <p class="time">{{getTime(boxData1[3].updated_at,'month',1)}}</p> -->
  70. </NuxtLink>
  71. </li>
  72. </ul>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script setup>
  79. //1.获得传入的数据 start---------------------------------------->
  80. const props = defineProps({
  81. message: Array,
  82. });
  83. //1.获得传入的数据 end---------------------------------------->
  84. //2.获得本页的数据 start---------------------------------------->
  85. const boxData1 = ref([]);
  86. const boxData2 = ref([]);
  87. if(props.message){
  88. getPageData3()
  89. getPageData1_data3()
  90. }
  91. //模块3 该模块是一个组件
  92. async function getPageData3() {
  93. const { data: mkdata, error: mkdataError } = requestData('/web/getWebsiteModelArticles', {
  94. method: 'GET',
  95. query: {
  96. 'catid': props.message.cid,
  97. 'level': 1,
  98. 'pagesize': 4
  99. },
  100. });
  101. if (mkdataError.value) {
  102. //console.error('模块1数据上部分请求失败!', mkdataError.value);
  103. } else {
  104. console.log(props.message.cid)
  105. if (mkdata.value) {
  106. //console.log('模块1数据上部分请求成功!', mkdata.value.data);
  107. boxData1.value = mkdata.value.data;
  108. }
  109. }
  110. }
  111. async function getPageData1_data3() {
  112. const { data: mkdata, error: mkdataError } = requestData('/web/getWebsiteModelArticles', {
  113. method: 'GET',
  114. query: {
  115. 'catid': props.message.cid,
  116. 'level': 3,
  117. 'pagesize': 6
  118. },
  119. });
  120. if (mkdataError.value) {
  121. //console.log()
  122. } else {
  123. if (mkdata.value) {
  124. //console.log()
  125. boxData2.value = mkdata.value.data;
  126. }
  127. }
  128. }
  129. //2.获得本页的数据 end---------------------------------------->
  130. </script>
  131. <style lang="less" scoped>
  132. .slider {
  133. width: 720px;
  134. }
  135. // 标题
  136. .scienceTitle {
  137. height: 50px;
  138. line-height: 50px;
  139. border-bottom: 1px solid #D9D9D9;
  140. display: flex;
  141. justify-content: space-between;
  142. h5 {
  143. float: left;
  144. width: 96px;
  145. height: 34px;
  146. font-family: PingFang SC, PingFang SC;
  147. font-weight: 600;
  148. font-size: 24px;
  149. color: #000000;
  150. line-height: 28px;
  151. text-align: left;
  152. font-style: normal;
  153. text-transform: none;
  154. margin-right: 20px;
  155. // border-bottom: 2px solid #139602;
  156. height: 50px;
  157. line-height: 50px;
  158. a {
  159. font-size: 22px;
  160. color: #139602;
  161. border-bottom: 3px solid #139602;
  162. height: 50px;
  163. line-height: 50px;
  164. display: inline-block;
  165. box-sizing: border-box;
  166. width: auto;
  167. font-weight: bold;
  168. }
  169. }
  170. a {
  171. width: 65px;
  172. height: 50px;
  173. line-height: 50px;
  174. font-weight: 400;
  175. font-size: 16px;
  176. color: #333333;
  177. font-style: normal;
  178. text-transform: none;
  179. display: inline-block;
  180. }
  181. >p {
  182. float: left;
  183. height: 37px;
  184. line-height: 30px;
  185. >span {
  186. display: inline-block;
  187. height: 20px;
  188. line-height: 20px;
  189. text-align: center;
  190. margin: 4px 0px 3px;
  191. padding: 0 20px;
  192. border-right: 1px solid #ccc;
  193. >a {
  194. display: inline-block;
  195. padding-bottom: 11px;
  196. font-family: PingFang SC, PingFang SC;
  197. font-weight: 500;
  198. font-size: 20px;
  199. color: #666666;
  200. line-height: 20px;
  201. font-style: normal;
  202. text-transform: none;
  203. box-sizing: border-box;
  204. }
  205. .current {
  206. color: #139602;
  207. border-bottom: 1px solid #139602;
  208. }
  209. }
  210. >span:nth-child(4) {
  211. border-right: none;
  212. }
  213. >span:hover>a {
  214. color: #139602;
  215. border-bottom: 1px solid #139602;
  216. }
  217. }
  218. }
  219. .box {
  220. width: 720px;
  221. height: 700px;
  222. position: relative;
  223. overflow: hidden;
  224. .boxcontent {
  225. display: flex;
  226. justify-content: space-between;
  227. padding-top: 30px;
  228. .boxleft {
  229. width: 349px;
  230. height: 700px;
  231. padding-bottom: 30px;
  232. }
  233. }
  234. .boxMainImg {
  235. display: flex;
  236. justify-content: space-between;
  237. margin-bottom: 15px;
  238. a {
  239. position: relative;
  240. width: 170px;
  241. height: 115px;
  242. display: block;
  243. img {
  244. width: 170px;
  245. height: 115px;
  246. border-radius: 4px;
  247. border-radius: 6px;
  248. }
  249. div {
  250. position: absolute;
  251. bottom: 4px;
  252. left: 7px;
  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: 42px;
  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: 20px;
  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:4px;
  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>