Slider.vue 13 KB

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