index.vue 8.7 KB

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