index.vue 8.1 KB

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