index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. .news {
  138. .banner {
  139. // background: url('~assets/images/news/header.png') 100% 100% center no-repeat #ffffff;
  140. background-image: url('~assets/images/news/header.png');
  141. background-repeat: no-repeat;
  142. background-size: 100% 100%;
  143. background-position: center;
  144. height: 713px;
  145. .banner-content {
  146. display: flex;
  147. flex-direction: column;
  148. justify-content: center;
  149. align-items: center;
  150. height: 100%;
  151. .title {
  152. font-size: 80px;
  153. font-weight: 500;
  154. color: #FFFFFF;
  155. line-height: 112px;
  156. }
  157. }
  158. }
  159. .news-main {
  160. margin-bottom: 116px;
  161. }
  162. .content {
  163. display: flex;
  164. margin-top: 138px;
  165. .aside {
  166. box-sizing: border-box;
  167. width: 200px;
  168. background: #FFFFFF;
  169. box-shadow: 0px 2px 9px 0px rgba(211, 213, 212, 0.5);
  170. border-radius: 6px;
  171. padding: 8px 0 36px 16px;
  172. margin-right: 15px;
  173. height: 224px;
  174. }
  175. .news-cate-item {
  176. display: flex;
  177. align-items: center;
  178. font-size: 0;
  179. .icon {
  180. margin-right: 18px;
  181. }
  182. .title {
  183. font-size: 20px;
  184. font-weight: 500;
  185. color: #959698;
  186. line-height: 28px;
  187. padding: 12px 0;
  188. &.active {
  189. font-size: 30px;
  190. font-weight: 500;
  191. color: #262626;
  192. line-height: 42px;
  193. transition: .3s;
  194. }
  195. }
  196. }
  197. .news-main {
  198. flex: 1;
  199. }
  200. .news-list {
  201. .news-list-item {
  202. padding: 20px 50px 20px 20px;
  203. display: flex;
  204. height: 212px;
  205. background: #FFFFFF;
  206. box-shadow: 0px 2px 15px 0px rgba(206, 209, 217, 0.42);
  207. border-radius: 10px;
  208. margin-bottom: 20px;
  209. .news-list-left {
  210. margin-right: 28px;
  211. width: 266px;
  212. height: 170px;
  213. overflow: hidden;
  214. img {
  215. width: 100%;
  216. height: 100%;
  217. border-radius: 4px;
  218. transition: all .5s ease;
  219. &:hover {
  220. transform: scale(1.2);
  221. }
  222. }
  223. }
  224. .news-list-right {
  225. flex: 1;
  226. display: flex;
  227. flex-direction: column;
  228. justify-content: space-between;
  229. .news-list-title {
  230. font-size: 22px;
  231. font-weight: 500;
  232. color: #242424;
  233. line-height: 44px;
  234. overflow: hidden;
  235. text-overflow: ellipsis;
  236. display: -webkit-box;
  237. -webkit-box-orient: vertical;
  238. -webkit-line-clamp: 2;
  239. :hover {
  240. text-decoration: underline;
  241. }
  242. }
  243. .news-list-desc {
  244. font-size: 16px;
  245. font-weight: 400;
  246. color: #797979;
  247. line-height: 32px;
  248. overflow: hidden;
  249. text-overflow: ellipsis;
  250. display: -webkit-box;
  251. -webkit-box-orient: vertical;
  252. -webkit-line-clamp: 2;
  253. }
  254. .news-list-bottom {
  255. font-size: 10px;
  256. font-weight: 400;
  257. color: #ABABAB;
  258. line-height: 14px;
  259. }
  260. }
  261. }
  262. }
  263. .empty-content {
  264. font-size: 28px;
  265. font-family: PingFangSC-Regular, sans-serif;
  266. font-weight: 400;
  267. color: #797979;
  268. line-height: 26px;
  269. margin-bottom: 300px;
  270. padding: 40px 0 0 90px;
  271. }
  272. .news-pagination {
  273. margin-top: 80px;
  274. .el-pagination.is-background {
  275. text-align: center;
  276. .el-pager {
  277. li.number {
  278. background: #ffffff;
  279. color: #2F2F2F;
  280. border: 1px solid #DCDFE6;
  281. min-width: 34px;
  282. &.active {
  283. background: $theme_color;
  284. color: #ffffff;
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. </style>