index.vue 7.4 KB

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