| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- <template>
- <div class="container news">
- <common-banner
- :img="bgImg"
- :height="644">
- <h2>新闻中心</h2>
- </common-banner>
- <!-- 专家团队 -->
- <section class="content w1200">
- <div class="aside">
- <ul class="news-cate-list">
- <li v-for="(item, index) in $store.state.newsNav" :key="index" class="news-cate-item">
- <div class="icon"><img :src="item.icon" alt="" srcset=""></div>
- <div :class="['title', cateId == item.id ? 'active' : '']" @click="changeCate(item, index)">{{ item.type }}</div>
- </li>
- </ul>
- </div>
- <div class="news-main">
- <section class="empty-content" v-if="isEmpty">
- <p>暂无新闻~</p>
- </section>
- <section class="news-list" v-else>
- <div class="news-list-item" v-for="(item, index) in newsList" :key="index">
- <div class="news-list-left">
- <nuxt-link :to="{ name: 'news-newsView-id', params: { id: item.id }, query: { cateId: item.typeId } }">
- <img :src="item.articleImg" alt="">
- </nuxt-link>
- </div>
- <div class="news-list-right">
- <div class="news-list-title">
- <nuxt-link :to="{ name: 'news-newsView-id', params: { id: item.id }, query: { cateId: item.typeId } }">
- {{ item.articleTitle }}
- </nuxt-link>
- </div>
- <div class="news-list-desc">{{ item.articleIntroduction }}</div>
- <div class="news-list-bottom">
- <img class="icon" :src="timeIcon" alt="" srcset="">
- {{ item.createTime }}
- </div>
- </div>
- </div>
- </section>
- <div class="news-pagination">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-sizes="[10, 20, 40]"
- :page-size="10"
- background
- layout="total, sizes, prev, pager, next, jumper"
- :total="total">
- </el-pagination>
- </div>
- </div>
- </section>
- </div>
- </template>
- <script>
- import axios from "axios";
- import CommonBanner from "@/components/common/banner";
- export default {
- name: 'news',
- data() {
- return {
- isEmpty: false,
- bgImg: require("~/assets/images/news/newsBg.png"),
- timeIcon: require("~/assets/images/news/time.png"),
- currentPage: 1,
- total: 0,
- cateId: '',
- newsList: [
- ]
- }
- },
- components: {
- CommonBanner
- },
- head() {
- return {
- title: "逻辑狗官网-中德智慧教育",
- meta: [
- {
- name: "keywords",
- hid: "keywords",
- content: `逻辑狗官网、逻辑狗教材、 幼儿园教材、逻辑狗课程、逻辑狗思维训练课程、儿童思维教育、0-12岁儿童`,
- },
- {
- name: "description",
- hid: "description",
- content: `逻辑狗官方网站,专为0-12岁儿童设计的思维训练课程,中德智慧教育,全球优质教育内容输出平台`,
- },
- ],
- };
- },
- async asyncData({ params, query, store }) {
- // 获取分类列表
- // let newsNav = [];
- // const { data } = await axios(`${store.state.wordpressAPI}/official-api/article/type`);
- // if(data.status === 200) {
- // newsNav = data.data;
- // }
- // console.log(newsNav);
- // let cateId = query.cateId || newsNav[0].id;
- // return {
- // cateId,
- // newsNav
- // }
- },
- created() {
- let cateId = this.$route.query.cateId || this.$store.state.newsNav[0].id;
- this.cateId = cateId;
- },
- mounted() {
- this.loadNewsList();
- },
- methods: {
- async loadNewsList() {
- const { data } = await axios(`${this.$store.state.wordpressAPI}/official-api/article`, {
- params: {
- typeId: this.cateId,
- page: this.currentPage
- }
- });
- if(data.status === 200) {
- this.total = data.data.total;
- this.newsList = data.data.entityList || [];
- if(this.newsList.length <= 0) {
- this.isEmpty = true;
- } else {
- this.isEmpty = false;
- }
- }
- },
- handleSizeChange() {
- },
- handleCurrentChange() {
- },
- changeCate(item, index) {
- this.cateId = item.id;
- this.currentIndex = index;
- this.currentPage = 1;
- this.loadNewsList();
- }
- },
- };
- </script>
- <style lang="scss">
- @import "~static/common/style.sass";
- .news {
- .banner {
- // background: url('~assets/images/news/header.png') 100% 100% center no-repeat #ffffff;
- background-image: url('~assets/images/news/header.png');
- background-repeat: no-repeat;
- background-size: 100% 100%;
- background-position: center;
- height: 713px;
- .banner-content {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- height: 100%;
- .title {
- font-size: 66px;
- font-family: PingFangSC-Medium, sans-serif;
- line-height: 92px;
- font-weight: 500;
- color: #FFFFFF;
- }
- }
- }
- .news-main {
- margin-bottom: 116px;
- }
- .content {
- display: flex;
- margin-top: 138px;
- .aside {
- box-sizing: border-box;
- width: 200px;
- background: #FFFFFF;
- border-radius: 20px;
- padding: 20px 0 36px 16px;
- margin-right: 15px;
- height: 224px;
- box-shadow: 6px 6px 25px 0px rgba(211, 229, 255, 0.33);
- }
- .news-cate-item {
- display: flex;
- align-items: center;
- font-size: 0;
- .icon {
- margin-right: 18px;
- }
- .title {
- font-size: 18px;
- font-weight: 500;
- color: #999999;
- line-height: 28px;
- padding: 12px 0;
- &.active {
- font-weight: 500;
- color: #262626;
- transition: .3s;
- font-size: 26px;
- font-family: PingFangSC-Semibold, PingFang SC;
- font-weight: 600;
- color: #262626;
- line-height: 37px;
- }
- }
- }
- .news-main {
- flex: 1;
- }
- .news-list {
- .news-list-item {
- padding: 20px 50px 20px 20px;
- display: flex;
- height: 212px;
- background: #FFFFFF;
- // box-shadow: 0px 2px 15px 0px rgba(206, 209, 217, 0.42);
- border-radius: 10px;
- margin-bottom: 20px;
- &:hover {
- box-shadow: 6px 6px 25px 0px rgba(211, 229, 255, 0.33);
- }
- .news-list-left {
- margin-right: 28px;
- width: 266px;
- height: 170px;
- overflow: hidden;
- img {
- width: 100%;
- height: 100%;
- border-radius: 4px;
- transition: all .5s ease;
- // &:hover {
- // transform: scale(1.2);
- // }
- }
- }
- .news-list-right {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- padding: 10px 0;
- .news-list-title {
- font-size: 18px;
- font-weight: 500;
- font-family: PingFangSC-Medium, PingFang SC;
- color: #242424;
- line-height: 27px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- :hover {
- text-decoration: underline;
- }
- }
- .news-list-desc {
- font-size: 14px;
- font-weight: 400;
- color: #787878;
- line-height: 21px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- }
- .news-list-bottom {
- font-size: 10px;
- font-weight: 400;
- color: #ABABAB;
- line-height: 14px;
- display: flex;
- align-items: center;
- .icon {
- width: 12px;
- height: 12px;
- margin-right: 10px
- }
- }
- }
- }
- }
- .empty-content {
- font-size: 28px;
- font-family: PingFangSC-Regular, sans-serif;
- font-weight: 400;
- color: #797979;
- line-height: 26px;
- margin-bottom: 300px;
- padding: 40px 0 0 90px;
- }
- .news-pagination {
- margin-top: 80px;
- .el-pagination.is-background {
- text-align: center;
- .el-pager {
- li.number {
- background: #ffffff;
- color: #2F2F2F;
- border: 1px solid #DCDFE6;
- min-width: 34px;
- &.active {
- background: $theme_color;
- color: #ffffff;
- }
- }
- }
- }
- }
- }
- }
- </style>
|