index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template>
  2. <section class="container">
  3. <NewsBanner></NewsBanner>
  4. <!-- 面包屑部分 -->
  5. <div id="bread-nav">
  6. <div class="brand-nav-box">
  7. <div class="brand-nav-content">
  8. <div class="brand-nav-title">
  9. <span>当前位置:</span>
  10. </div>
  11. <div class="brand-nav-list">
  12. <ul>
  13. <li>
  14. <nuxt-link target="_blank" to="/">首页</nuxt-link>
  15. </li>
  16. <li>></li>
  17. <li>
  18. <nuxt-link target="_blank" to="/news">新闻中心</nuxt-link>
  19. </li>
  20. </ul>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <!-- 面包屑部分结束 -->
  26. <!-- 新闻主体列表部分 -->
  27. <div id="news-list" v-if="hiddenContent()">
  28. <div class="news-list-content">
  29. <div class="news-list-content-box">
  30. <div class="news-list-container">
  31. <ul class="news-list-nav">
  32. <li
  33. class="news-list-kind"
  34. :class="{active:(index + 1) == $route.params.category}"
  35. v-for="(list,index) in $store.state.headNewsNav"
  36. :key="index"
  37. >
  38. <nuxt-link
  39. target="_blank"
  40. :to="{name: 'news-category',params: {category: list.articleCategoryId}}"
  41. >{{list.articleCategoryName}}</nuxt-link>
  42. </li>
  43. </ul>
  44. <div class="news-list-tab-content">
  45. <div class="news-list-tab-box">
  46. <ul>
  47. <li class="news-list-details" v-for="(list,index) in newsListData" :key="index">
  48. <div class="news-list-left">
  49. <nuxt-link
  50. target="_blank"
  51. :to="{name:'news-newsView-id',params:{id:list.articleId},query: {category: list.articleCategoryId}}"
  52. >
  53. <img :src="list.articleImg.articleImgSrc" :alt="list.articleImg.articleImgAlt">
  54. </nuxt-link>
  55. </div>
  56. <div class="news-list-right">
  57. <div class="news-list-title">
  58. <nuxt-link
  59. target="_blank"
  60. :to="{name:'news-newsView-id',params:{id:list.articleId},query: {category: list.articleCategoryId}}"
  61. >
  62. <h2>{{list.articleName}}</h2>
  63. </nuxt-link>
  64. </div>
  65. <div class="news-list-desc">{{getTxt(list.articleText)}}</div>
  66. <div class="news-list-bottom">
  67. <div class="news-list-tag-box">
  68. <div class="news-list-tag">
  69. <a href="javascript:viod(0);">{{list.labelList[0].articleLabelName}}</a>
  70. </div>
  71. <div class="news-list-tag">
  72. <a href="javascript:viod(0);">{{list.labelList[1].articleLabelName}}</a>
  73. </div>
  74. </div>
  75. <div class="news-list-time">
  76. <p>{{list.articleAddTime}}</p>
  77. </div>
  78. </div>
  79. </div>
  80. </li>
  81. </ul>
  82. <div class="news-list-pagination-box">
  83. <pagination
  84. :total="total"
  85. :display="display"
  86. :current-page="current"
  87. @pagechange="pagechange"
  88. ></pagination>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <!-- 新闻主体列表结束 -->
  97. <!-- Recommended Article Start-->
  98. <div id="recom-article" v-if="hiddenContent()">
  99. <div class="recom-article-box">
  100. <div class="recom-article-title">
  101. <p>推荐文章</p>
  102. </div>
  103. <div class="recom-article-list-box">
  104. <div class="recom-article-left">
  105. <ul>
  106. <template v-for="(list,index) in recomArticleData">
  107. <li
  108. class="recom-article-list"
  109. :key="list.articleId"
  110. v-if="index<4">
  111. <div class="recom-article-list-title">
  112. <nuxt-link
  113. target="_blank"
  114. :to="{name: 'news-newsView-id',params:{id:list.articleId},query: {category: list.articleCategoryId}}"
  115. >{{list.articleName}}</nuxt-link>
  116. </div>
  117. </li>
  118. </template>
  119. </ul>
  120. </div>
  121. <div class="recom-article-right">
  122. <ul>
  123. <template v-for="(list,index) in recomArticleData">
  124. <li
  125. class="recom-article-list"
  126. :key="list.articleId"
  127. v-if="index>3"
  128. >
  129. <div class="recom-article-list-title">
  130. <nuxt-link
  131. target="_blank"
  132. :to="{name: 'news-newsView-id',params:{id:list.articleId},query: {category: list.articleCategoryId}}"
  133. >{{list.articleName}}</nuxt-link>
  134. </div>
  135. </li>
  136. </template>
  137. </ul>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. <!-- Recommended Article End-->
  143. <!-- Recommended Products Start-->
  144. <div id="recom-products" v-if="hiddenContent()">
  145. <div class="recom-products-box">
  146. <div class="recom-products-title">
  147. <p>推荐产品</p>
  148. </div>
  149. <div class="recom-products-list-box">
  150. <ul>
  151. <li class="recom-products-list" v-for="list in recomProductsData" :key="list.proId">
  152. <div class="recom-products-list-img">
  153. <nuxt-link
  154. target="_blank"
  155. :to="{name:'prod-pdV-id',params:{id: list.proId},query: {typeId: list.proPositionId,classId: list.proTypeId}}"
  156. >
  157. <img :src="list.proImgs[0].proImgSrc" :alt="list.proImgs[0].proImgAlt">
  158. </nuxt-link>
  159. </div>
  160. <div class="recom-products-list-title">
  161. <nuxt-link
  162. target="_blank"
  163. :to="{name: 'prod-pdV-id',params:{id: list.proId},query: {typeId: list.proPositionId,classId: list.proTypeId}}"
  164. >{{list.proName}}</nuxt-link>
  165. </div>
  166. </li>
  167. </ul>
  168. </div>
  169. </div>
  170. </div>
  171. <!-- Recommended Products End-->
  172. <!-- <nuxt-child></nuxt-child> -->
  173. </section>
  174. </template>
  175. <script>
  176. import axios from "axios";
  177. import NewsBanner from "~/components/news/NewsBanner";
  178. import pagination from "~/components/common/pagination.vue";
  179. export default {
  180. data() {
  181. return {
  182. display: 8, // 每页显示条数
  183. current: 1, // 当前的页数
  184. };
  185. },
  186. head() {
  187. return {
  188. title: this.metaData.title,
  189. meta: [
  190. {
  191. name: "keywords",
  192. hid: "keywords",
  193. content: `${this.metaData.keyword}`,
  194. },
  195. {
  196. name: "description",
  197. hid: "description",
  198. content: `${this.metaData.description}`,
  199. },
  200. ],
  201. };
  202. },
  203. validata({ params }) {
  204. return /^\d+$/.test(params.category);
  205. },
  206. async asyncData({ store, params }) {
  207. let newsCategoryId = params.category;
  208. //新闻列表
  209. let newsListData = await axios(
  210. `${store.state.wordpressAPI}/article/getArticles/${newsCategoryId}/1/8`
  211. );
  212. //推荐文章
  213. let recomArticleData = await axios.get(
  214. `${
  215. store.state.wordpressAPI
  216. }/article/getRecommendsByCategoryId/${newsCategoryId}/8`
  217. );
  218. //推荐产品
  219. let recomProductsData = await axios.get(
  220. `${store.state.wordpressAPI}/product/getProRandom/5`
  221. );
  222. return {
  223. metaData: newsListData.data,
  224. newsListData: newsListData.data.list,
  225. total: newsListData.data.total,
  226. recomArticleData: recomArticleData.data,
  227. recomProductsData: recomProductsData.data,
  228. };
  229. },
  230. components: {
  231. NewsBanner,
  232. pagination,
  233. },
  234. methods: {
  235. hiddenContent() {
  236. return !/^\d+$/.test(this.$route.params.id);
  237. },
  238. pagechange(currentPage) {
  239. let categoryId = this.$route.params.category;
  240. // ajax请求, 向后台发送 currentPage, 来获取对应的数据
  241. axios
  242. .get(
  243. `${
  244. this.$store.state.wordpressAPI
  245. }/article/getArticles/${categoryId}/${currentPage}/8`
  246. )
  247. .then((response) => {
  248. this.newsListData = response.data.list;
  249. this.total = response.data.total;
  250. })
  251. .catch(function(error) {
  252. console.log(error);
  253. });
  254. },
  255. getTxt(str) {
  256. var txt = str
  257. .replace(/<\/?.+?>/g, "")
  258. .replace(/&nbsp;/gi, "")
  259. .replace(/(^\s+)|(\s+$)/g, "")
  260. .replace(/\s/g, "");
  261. txt = txt.length < 170 ? txt : txt.substring(0, 170).concat("...");
  262. return txt;
  263. },
  264. },
  265. };
  266. </script>
  267. <style scoped>
  268. /*面包屑部分*/
  269. div#bread-nav {
  270. width: 100%;
  271. height: auto;
  272. }
  273. #bread-nav {
  274. position: relative;
  275. }
  276. #bread-nav .brand-nav-content {
  277. float: right;
  278. }
  279. .brand-nav-box {
  280. width: 1200px;
  281. margin: 0 auto;
  282. color: #858585;
  283. font-size: 14px;
  284. text-align: left;
  285. line-height: 70px;
  286. }
  287. .brand-nav-content {
  288. float: left;
  289. }
  290. .brand-nav-title {
  291. float: left;
  292. }
  293. .brand-nav-list {
  294. float: left;
  295. overflow: hidden;
  296. }
  297. .brand-nav-list ul {
  298. overflow: hidden;
  299. }
  300. .brand-nav-list ul li {
  301. float: left;
  302. padding: 0 5px;
  303. }
  304. .brand-nav-list ul li a {
  305. display: block;
  306. width: 100%;
  307. height: 100%;
  308. color: #858585;
  309. }
  310. .brand-nav-list ul li:last-child a {
  311. color: #22202b;
  312. }
  313. .brand-nav-list ul li a:hover {
  314. color: #22202b;
  315. }
  316. /*面包屑部分结束*/
  317. /* news-list start */
  318. div#news-list {
  319. width: 100%;
  320. height: auto;
  321. }
  322. .news-list-content-box {
  323. width: 1200px;
  324. height: auto;
  325. margin: 0 auto;
  326. }
  327. .news-list-container {
  328. width: 100%;
  329. padding: 45px 0 54px;
  330. }
  331. .news-list-nav {
  332. overflow: hidden;
  333. width: 100%;
  334. height: auto;
  335. }
  336. .news-list-kind {
  337. float: left;
  338. overflow: hidden;
  339. width: 104px;
  340. height: 40px;
  341. margin-left: 20px;
  342. border: 3px solid transparent;
  343. box-sizing: border-box;
  344. color: #000;
  345. font-size: 14px;
  346. text-align: center;
  347. line-height: 34px;
  348. cursor: pointer;
  349. -webkit-transition: all 0.5s ease;
  350. -o-transition: all 0.5s ease;
  351. transition: all 0.5s ease;
  352. }
  353. .news-list-kind a {
  354. display: block;
  355. width: 100%;
  356. height: 100%;
  357. color: #000;
  358. }
  359. .news-list-nav .news-list-kind:first-child {
  360. margin-left: 0;
  361. }
  362. .news-list-kind.active,
  363. .news-list-kind:hover {
  364. border: 3px solid #000;
  365. }
  366. .news-list-tab-content {
  367. overflow: hidden;
  368. width: 100%;
  369. height: auto;
  370. }
  371. .news-list-tab-box {
  372. display: none;
  373. overflow: hidden;
  374. width: 100%;
  375. height: auto;
  376. }
  377. .news-list-tab-content .news-list-tab-box:first-child {
  378. display: block;
  379. }
  380. .news-list-tab-box ul {
  381. overflow: hidden;
  382. width: 100%;
  383. }
  384. li.news-list-details {
  385. overflow: hidden;
  386. width: 100%;
  387. height: auto;
  388. padding-top: 113px;
  389. }
  390. .news-list-tab-box ul li.news-list-details:first-child {
  391. padding-top: 65px;
  392. }
  393. .news-list-left {
  394. float: left;
  395. overflow: hidden;
  396. width: 367px;
  397. height: 254px;
  398. }
  399. .news-list-left img {
  400. width: 100%;
  401. height: 100%;
  402. -webkit-transition: all 0.5s ease;
  403. -o-transition: all 0.5s ease;
  404. transition: all 0.5s ease;
  405. }
  406. .news-list-left img:hover {
  407. -webkit-transform: scale(1.2);
  408. -ms-transform: scale(1.2);
  409. -o-transform: scale(1.2);
  410. transform: scale(1.2);
  411. }
  412. .news-list-right {
  413. float: right;
  414. width: 787px;
  415. height: auto;
  416. }
  417. .news-list-title {
  418. overflow: hidden;
  419. width: 100%;
  420. height: 56px;
  421. }
  422. .news-list-title a {
  423. display: block;
  424. overflow: hidden;
  425. width: 100%;
  426. height: 100%;
  427. color: #22202b;
  428. font-size: 22px;
  429. line-height: 56px;
  430. text-align: left;
  431. text-overflow: ellipsis;
  432. white-space: nowrap;
  433. }
  434. .news-list-title a h2 {
  435. display: block;
  436. overflow: hidden;
  437. width: 100%;
  438. height: 100%;
  439. font-weight: normal;
  440. font-size: 22px;
  441. text-overflow: ellipsis;
  442. white-space: nowrap;
  443. }
  444. .news-list-title a:hover {
  445. text-decoration: underline;
  446. }
  447. .news-list-desc {
  448. overflow: hidden;
  449. width: 100%;
  450. height: 131px;
  451. padding-top: 20px;
  452. border-bottom: 2px solid #d5d5d8;
  453. box-sizing: border-box;
  454. color: #858585;
  455. font-size: 14px;
  456. line-height: 20px;
  457. text-align: left;
  458. }
  459. .news-list-bottom {
  460. overflow: hidden;
  461. width: 100%;
  462. height: 68px;
  463. padding-top: 24px;
  464. box-sizing: border-box;
  465. }
  466. .news-list-tag-box {
  467. float: left;
  468. overflow: hidden;
  469. }
  470. .news-list-time {
  471. float: right;
  472. color: #999;
  473. font-size: 12px;
  474. line-height: 32px;
  475. text-align: center;
  476. }
  477. .news-list-tag {
  478. float: left;
  479. width: 103px;
  480. height: 32px;
  481. border: 2px solid #000;
  482. box-sizing: border-box;
  483. font-size: 12px;
  484. line-height: 28px;
  485. text-align: center;
  486. }
  487. .news-list-tag-box a {
  488. display: block;
  489. width: 100%;
  490. height: 100%;
  491. color: #000;
  492. -webkit-transition: all 0.5s ease;
  493. -o-transition: all 0.5s ease;
  494. transition: all 0.5s ease;
  495. }
  496. .news-list-tag-box a:hover {
  497. background: #000;
  498. color: #feeabd;
  499. }
  500. .news-list-tag-box .news-list-tag:first-child {
  501. margin-right: 17px;
  502. }
  503. .news-list-pagination-box {
  504. width: 100%;
  505. height: auto;
  506. padding-top: 84px;
  507. text-align: center;
  508. }
  509. /* news-list end */
  510. /*Recommended Article Start*/
  511. div#recom-article {
  512. width: 100%;
  513. height: auto;
  514. }
  515. .recom-article-box {
  516. overflow: hidden;
  517. width: 1200px;
  518. height: auto;
  519. margin: 0 auto;
  520. }
  521. .recom-article-title {
  522. width: 100%;
  523. height: 76px;
  524. border-bottom: 2px solid #d5d5d8;
  525. color: #22202b;
  526. font-size: 22px;
  527. line-height: 74px;
  528. text-align: left;
  529. box-sizing: border-box;
  530. }
  531. .recom-article-list-box {
  532. overflow: hidden;
  533. width: 100%;
  534. height: auto;
  535. padding: 71px 0 54px;
  536. }
  537. .recom-article-left {
  538. float: left;
  539. width: 600px;
  540. height: 104px;
  541. padding-left: 220px;
  542. box-sizing: border-box;
  543. background: url('~assets/images/news-list/recom-article-left-bg.png') left
  544. center no-repeat;
  545. }
  546. .recom-article-right {
  547. float: right;
  548. width: 600px;
  549. height: 104px;
  550. padding-left: 220px;
  551. box-sizing: border-box;
  552. background: url('~assets/images/news-list/recom-article-left-bg.png') left
  553. center no-repeat;
  554. }
  555. li.recom-article-list {
  556. overflow: hidden;
  557. width: 345px;
  558. height: 26px;
  559. }
  560. .recom-article-list-title {
  561. position: relative;
  562. width: 100%;
  563. height: 100%;
  564. padding-left: 6px;
  565. box-sizing: border-box;
  566. font-size: 14px;
  567. text-align: left;
  568. line-height: 26px;
  569. }
  570. .recom-article-list-title::after {
  571. position: absolute;
  572. top: 50%;
  573. left: 0;
  574. content: "";
  575. width: 2px;
  576. height: 2px;
  577. border-radius: 50%;
  578. background: #22202b;
  579. }
  580. .recom-article-list-title a {
  581. display: block;
  582. overflow: hidden;
  583. width: 100%;
  584. height: 100%;
  585. color: #999999;
  586. text-overflow: ellipsis;
  587. white-space: nowrap;
  588. }
  589. .recom-article-list-title a:hover {
  590. color: #000;
  591. }
  592. /*Recommended Article End*/
  593. /*Recommended Products Start*/
  594. div#recom-products {
  595. width: 100%;
  596. height: auto;
  597. }
  598. .recom-products-box {
  599. overflow: hidden;
  600. width: 1200px;
  601. height: auto;
  602. margin: 0 auto;
  603. }
  604. .recom-products-title {
  605. width: 100%;
  606. height: 76px;
  607. border-bottom: 2px solid #d5d5d8;
  608. color: #22202b;
  609. font-size: 22px;
  610. line-height: 74px;
  611. text-align: left;
  612. box-sizing: border-box;
  613. }
  614. .recom-products-list-box {
  615. width: 100%;
  616. height: auto;
  617. padding: 43px 0 133px;
  618. }
  619. .recom-products-list-box ul {
  620. overflow: hidden;
  621. width: 100%;
  622. }
  623. li.recom-products-list {
  624. float: left;
  625. width: 200px;
  626. height: auto;
  627. margin-left: 50px;
  628. }
  629. .recom-products-list-box ul li:first-child {
  630. margin-left: 0px;
  631. }
  632. .recom-products-list-img {
  633. overflow: hidden;
  634. width: 100%;
  635. height: 200px;
  636. }
  637. .recom-products-list-img img {
  638. width: 100%;
  639. height: 100%;
  640. -webkit-transition: all 0.5s ease;
  641. -o-transition: all 0.5s ease;
  642. transition: all 0.5s ease;
  643. }
  644. .recom-products-list-img img:hover {
  645. -webkit-transform: scale(1.2);
  646. -ms-transform: scale(1.2);
  647. -o-transform: scale(1.2);
  648. transform: scale(1.2);
  649. }
  650. .recom-products-list-title {
  651. overflow: hidden;
  652. width: 100%;
  653. height: 45px;
  654. color: #999;
  655. font-size: 14px;
  656. line-height: 45px;
  657. text-align: center;
  658. }
  659. .recom-products-list-title a {
  660. display: block;
  661. overflow: hidden;
  662. width: 100%;
  663. height: 100%;
  664. padding: 0 10px;
  665. color: #999;
  666. box-sizing: border-box;
  667. text-overflow: ellipsis;
  668. white-space: nowrap;
  669. }
  670. .recom-products-list-title a:hover {
  671. color: #000;
  672. }
  673. /*Recommended Products End*/
  674. </style>