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">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. return {
  77. title: "逻辑狗官网-中德智慧教育",
  78. meta: [
  79. {
  80. name: "keywords",
  81. hid: "keywords",
  82. content: `逻辑狗官网、逻辑狗教材、 幼儿园教材、逻辑狗课程、逻辑狗思维训练课程、儿童思维教育、0-12岁儿童`,
  83. },
  84. {
  85. name: "description",
  86. hid: "description",
  87. content: `逻辑狗官方网站,专为0-12岁儿童设计的思维训练课程,中德智慧教育,全球优质教育内容输出平台`,
  88. },
  89. ],
  90. };
  91. },
  92. async asyncData({ params, query, store }) {
  93. // 获取分类列表
  94. // let newsNav = [];
  95. // const { data } = await axios(`${store.state.wordpressAPI}/official-api/article/type`);
  96. // if(data.status === 200) {
  97. // newsNav = data.data;
  98. // }
  99. // console.log(newsNav);
  100. // let cateId = query.cateId || newsNav[0].id;
  101. // return {
  102. // cateId,
  103. // newsNav
  104. // }
  105. },
  106. created() {
  107. let cateId = this.$route.query.cateId || this.$store.state.newsNav[0].id;
  108. this.cateId = cateId;
  109. },
  110. mounted() {
  111. if (process.browser) {
  112. new WOW({
  113. offset: 0,
  114. live: true
  115. }).init()
  116. }
  117. this.loadNewsList();
  118. },
  119. methods: {
  120. async loadNewsList() {
  121. const { data } = await axios(`${this.$store.state.wordpressAPI}/official-api/article`, {
  122. params: {
  123. typeId: this.cateId,
  124. page: this.currentPage
  125. }
  126. });
  127. if(data.status === 200) {
  128. this.total = data.data.total;
  129. this.newsList = data.data.entityList || [];
  130. if(this.newsList.length <= 0) {
  131. this.isEmpty = true;
  132. } else {
  133. this.isEmpty = false;
  134. }
  135. }
  136. },
  137. handleSizeChange() {
  138. },
  139. handleCurrentChange() {
  140. },
  141. changeCate(item, index) {
  142. this.cateId = item.id;
  143. this.currentIndex = index;
  144. this.currentPage = 1;
  145. this.loadNewsList();
  146. }
  147. },
  148. };
  149. </script>
  150. <style lang="scss">
  151. @import "~static/common/style.sass";
  152. .news {
  153. .banner {
  154. // background: url('~assets/images/news/header.png') 100% 100% center no-repeat #ffffff;
  155. background-image: url('~assets/images/news/header.png');
  156. background-repeat: no-repeat;
  157. background-size: 100% 100%;
  158. background-position: center;
  159. height: 713px;
  160. .banner-content {
  161. display: flex;
  162. flex-direction: column;
  163. justify-content: center;
  164. align-items: center;
  165. height: 100%;
  166. .title {
  167. font-size: 80px;
  168. font-weight: 500;
  169. color: #FFFFFF;
  170. line-height: 112px;
  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>