Slider.vue 14 KB

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