| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <template>
- <div class="container news">
- <div class="banner">
- <div class="banner-content">
- <h3 class="title">NEWS</h3>
- <h3 class="title">新闻中心</h3>
- </div>
- </div>
- <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">{{ 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";
- if (process.browser) {
- var {WOW} = require('wowjs')
- }
- export default {
- name: 'news',
- data() {
- return {
- isEmpty: false,
- currentPage: 1,
- total: 0,
- cateId: '',
- newsList: [
- ]
- }
- },
- components: {
- },
- head() {
-
- },
- 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() {
- if (process.browser) {
- new WOW({
- offset: 0,
- live: true
- }).init()
- }
- 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";
- .banner {
- background: url('~assets/images/news/header.png') 100% 100% no-repeat #ffffff;
- height: 713px;
- .banner-content {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- height: 100%;
- .title {
- font-size: 80px;
- font-weight: 500;
- color: #FFFFFF;
- line-height: 112px;
- }
- }
- }
- .news {
- .news-main {
- margin-bottom: 116px;
- }
- .content {
- display: flex;
- margin-top: 138px;
- .aside {
- box-sizing: border-box;
- width: 200px;
- background: #FFFFFF;
- box-shadow: 0px 2px 9px 0px rgba(211, 213, 212, 0.5);
- border-radius: 6px;
- padding: 8px 0 36px 16px;
- margin-right: 15px;
- height: 224px;
- }
- .news-cate-item {
- display: flex;
- align-items: center;
- font-size: 0;
- .icon {
- margin-right: 18px;
- }
- .title {
- font-size: 20px;
- font-weight: 500;
- color: #959698;
- line-height: 28px;
- padding: 12px 0;
- &.active {
- font-size: 30px;
- font-weight: 500;
- color: #262626;
- line-height: 42px;
- transition: .3s;
- }
- }
- }
- .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;
- .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;
- .news-list-title {
- font-size: 22px;
- font-weight: 500;
- color: #242424;
- line-height: 44px;
- 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: 16px;
- font-weight: 400;
- color: #797979;
- line-height: 32px;
- 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;
- }
- }
- }
- }
- .empty-content {
- font-size: 28px;
- font-family: PingFangSC-Regular, PingFang SC;
- 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>
|