index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="container news">
  3. <div class="banner">
  4. <div class="banner-content">
  5. <h3 class="title">NEWS</h3>
  6. <h3 class="title">新闻中心</h3>
  7. </div>
  8. </div>
  9. <section class="content w1200">
  10. <div class="aside">
  11. <ul class="news-cate-list">
  12. <li v-for="(item, index) in newsNav" :key="index" class="news-cate-item">
  13. <div class="icon"><img :src="item.icon" alt="" srcset=""></div>
  14. <div :class="['title', cateId == item.id ? 'active' : '']" @click="changeCate(item, index)">{{ item.type }}</div>
  15. </li>
  16. </ul>
  17. </div>
  18. <div class="news-main">
  19. <section class="news-list">
  20. <div class="news-list-item" v-for="(item, index) in newsList" :key="index">
  21. <div class="news-list-left">
  22. <nuxt-link :to="{ name: 'news-newsView-id', params: { id: cateId }, query: { cateId: cateId } }">
  23. <img :src="item.articleImg" alt="">
  24. </nuxt-link>
  25. </div>
  26. <div class="news-list-right">
  27. <div class="news-list-title">
  28. <nuxt-link :to="{ name: 'news-newsView-id', params: { id: cateId }, query: { cateId: cateId } }">
  29. {{ item.articleTitle }}
  30. </nuxt-link>
  31. </div>
  32. <div class="news-list-desc">{{ item.articleIntroduction }}</div>
  33. <div class="news-list-bottom">{{ item.createTime }}</div>
  34. </div>
  35. </div>
  36. </section>
  37. <div class="news-pagination">
  38. <el-pagination
  39. @size-change="handleSizeChange"
  40. @current-change="handleCurrentChange"
  41. :current-page="currentPage"
  42. :page-sizes="[10, 20, 40]"
  43. :page-size="10"
  44. background
  45. layout="total, sizes, prev, pager, next, jumper"
  46. :total="total">
  47. </el-pagination>
  48. </div>
  49. </div>
  50. </section>
  51. </div>
  52. </template>
  53. <script>
  54. import axios from "axios";
  55. if (process.browser) {
  56. var {WOW} = require('wowjs')
  57. }
  58. export default {
  59. name: 'news',
  60. data() {
  61. return {
  62. currentPage: 1,
  63. total: 0,
  64. newsList: [
  65. {
  66. title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 迁标题中德智迁标题中德智慧乔迁……..',
  67. time: '2020-6-29',
  68. content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
  69. imgUrl: require('~/assets/images/news/img.png'),
  70. id: '1',
  71. cateId: '1',
  72. },
  73. {
  74. title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 慧乔迁……..',
  75. time: '2020-6-29',
  76. content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
  77. imgUrl: require('~/assets/images/news/img.png'),
  78. id: '1'
  79. },
  80. {
  81. title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 慧乔迁……..',
  82. time: '2020-6-29',
  83. content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
  84. imgUrl: require('~/assets/images/news/img.png'),
  85. id: '1'
  86. },
  87. {
  88. title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 慧乔迁……..',
  89. time: '2020-6-29',
  90. content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
  91. imgUrl: require('~/assets/images/news/img.png'),
  92. id: '1'
  93. }
  94. ]
  95. }
  96. },
  97. components: {
  98. },
  99. head() {
  100. },
  101. async asyncData({ params, query, store }) {
  102. // 获取分类列表
  103. let newsNav = [];
  104. const { data } = await axios(`${store.state.wordpressAPI}/official-api/article/type`);
  105. if(data.status === 200) {
  106. newsNav = data.data;
  107. }
  108. console.log(newsNav);
  109. let cateId = query.cateId || newsNav[0].id;
  110. return {
  111. cateId,
  112. newsNav
  113. }
  114. },
  115. created() {
  116. },
  117. mounted() {
  118. if (process.browser) {
  119. new WOW({
  120. offset: 0,
  121. live: true
  122. }).init()
  123. }
  124. this.loadNewsList();
  125. },
  126. methods: {
  127. async loadNewsList() {
  128. const { data } = await axios(`${this.$store.state.wordpressAPI}/official-api/article`, {
  129. params: {
  130. typeId: this.cateId,
  131. page: this.currentPage
  132. }
  133. });
  134. if(data.status === 200) {
  135. this.total = data.data.total;
  136. this.newsList = data.data.entityList || [];
  137. }
  138. },
  139. handleSizeChange() {
  140. },
  141. handleCurrentChange() {
  142. },
  143. changeCate(item, index) {
  144. this.cateId = item.id;
  145. this.currentIndex = index;
  146. this.currentPage = 1;
  147. this.loadNewsList();
  148. }
  149. },
  150. };
  151. </script>
  152. <style lang="scss">
  153. @import "~static/common/style.sass";
  154. .banner {
  155. background: url('~assets/images/news/header.png') 100% 100% no-repeat #ffffff;
  156. height: 713px;
  157. .banner-content {
  158. display: flex;
  159. flex-direction: column;
  160. justify-content: center;
  161. align-items: center;
  162. height: 100%;
  163. .title {
  164. font-size: 80px;
  165. font-weight: 500;
  166. color: #FFFFFF;
  167. line-height: 112px;
  168. }
  169. }
  170. }
  171. .news {
  172. .news-main {
  173. margin-bottom: 116px;
  174. }
  175. .content {
  176. display: flex;
  177. margin-top: 138px;
  178. .aside {
  179. box-sizing: border-box;
  180. width: 200px;
  181. background: #FFFFFF;
  182. box-shadow: 0px 2px 9px 0px rgba(211, 213, 212, 0.5);
  183. border-radius: 6px;
  184. padding: 8px 0 36px 16px;
  185. margin-right: 15px;
  186. height: 224px;
  187. }
  188. .news-cate-item {
  189. display: flex;
  190. align-items: center;
  191. font-size: 0;
  192. .icon {
  193. margin-right: 18px;
  194. }
  195. .title {
  196. font-size: 20px;
  197. font-weight: 500;
  198. color: #959698;
  199. line-height: 28px;
  200. padding: 12px 0;
  201. &.active {
  202. font-size: 30px;
  203. font-weight: 500;
  204. color: #262626;
  205. line-height: 42px;
  206. transition: .3s;
  207. }
  208. }
  209. }
  210. .news-main {
  211. flex: 1;
  212. }
  213. .news-list {
  214. .news-list-item {
  215. padding: 20px 50px 20px 20px;
  216. display: flex;
  217. height: 212px;
  218. background: #FFFFFF;
  219. box-shadow: 0px 2px 15px 0px rgba(206, 209, 217, 0.42);
  220. border-radius: 10px;
  221. margin-bottom: 20px;
  222. .news-list-left {
  223. margin-right: 28px;
  224. width: 266px;
  225. height: 170px;
  226. overflow: hidden;
  227. img {
  228. width: 100%;
  229. height: 100%;
  230. border-radius: 4px;
  231. transition: all .5s ease;
  232. &:hover {
  233. transform: scale(1.2);
  234. }
  235. }
  236. }
  237. .news-list-right {
  238. flex: 1;
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: space-between;
  242. .news-list-title {
  243. font-size: 22px;
  244. font-weight: 500;
  245. color: #242424;
  246. line-height: 44px;
  247. overflow: hidden;
  248. text-overflow: ellipsis;
  249. display: -webkit-box;
  250. -webkit-box-orient: vertical;
  251. -webkit-line-clamp: 2;
  252. :hover {
  253. text-decoration: underline;
  254. }
  255. }
  256. .news-list-desc {
  257. font-size: 16px;
  258. font-weight: 400;
  259. color: #797979;
  260. line-height: 32px;
  261. overflow: hidden;
  262. text-overflow: ellipsis;
  263. display: -webkit-box;
  264. -webkit-box-orient: vertical;
  265. -webkit-line-clamp: 2;
  266. }
  267. .news-list-bottom {
  268. font-size: 10px;
  269. font-weight: 400;
  270. color: #ABABAB;
  271. line-height: 14px;
  272. }
  273. }
  274. }
  275. }
  276. .news-pagination {
  277. margin-top: 80px;
  278. .el-pagination.is-background {
  279. text-align: center;
  280. .el-pager {
  281. li.number {
  282. background: #ffffff;
  283. color: #2F2F2F;
  284. border: 1px solid #DCDFE6;
  285. min-width: 34px;
  286. &.active {
  287. background: $theme_color;
  288. color: #ffffff;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. </style>