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. :to="{ path: `/newsList/${message.cid}`}"
  7. target="_blank" v-if="message.children_count!=0" class="active">
  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">
  13. {{message.title}}
  14. </NuxtLink>
  15. </h5>
  16. <NuxtLink :to="`/newsList/${message.cid}`" target="_blank">
  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">
  26. <img :src="boxData1[0].imgurl">
  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">
  35. <img :src="boxData1[1].imgurl">
  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">
  42. <img :src="boxData1[2].imgurl">
  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">
  51. <img :src="boxData1[3].imgurl">
  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">
  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': 6
  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. img {
  236. width: 170px;
  237. height: 115px;
  238. border-radius: 4px;
  239. border-radius: 6px;
  240. }
  241. div {
  242. position: absolute;
  243. bottom: 4px;
  244. left: 7px;
  245. p {
  246. display: -webkit-box;
  247. -webkit-box-orient: vertical;
  248. -webkit-line-clamp: 2;
  249. overflow: hidden;
  250. text-overflow: ellipsis;
  251. word-break: break-all;
  252. width: 158px;
  253. height: 42px;
  254. color: #fff;
  255. }
  256. span {
  257. display:block;
  258. height: 20px;
  259. line-height: 20px;
  260. text-align: left;
  261. color: #fff;
  262. }
  263. }
  264. }
  265. }
  266. .boxBigImg {
  267. margin-bottom: 15px;
  268. a {
  269. position: relative;
  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: 42px;
  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: 20px;
  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:4px;
  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>