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