Browse Source

新增最新资讯分页

master
liaoxinyu 2 years ago
parent
commit
b0a351a7b5
  1. 2
      src/views/college/detail.vue
  2. 30
      src/views/college/latestnews.vue

2
src/views/college/detail.vue

@ -3,6 +3,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12 my-4" v-if="article"> <div class="col-12 my-4" v-if="article">
<!-- v-if="cid == 18||cid == 21||cid == 22||cid == 32" -->
<el-breadcrumb separator-class="el-icon-arrow-right"> <el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item :to="{ path: `/college/list/18` }">{{$t('college.college')}}</el-breadcrumb-item> <el-breadcrumb-item :to="{ path: `/college/list/18` }">{{$t('college.college')}}</el-breadcrumb-item>
<el-breadcrumb-item :to="{ path: `/college/list/${cid}`}">{{article.category_name}}</el-breadcrumb-item> <el-breadcrumb-item :to="{ path: `/college/list/${cid}`}">{{article.category_name}}</el-breadcrumb-item>
@ -19,6 +20,7 @@
<div class="col-12"> <div class="col-12">
<div class="title h3 my-4">{{$t('college.recommendedCourse')}}</div> <div class="title h3 my-4">{{$t('college.recommendedCourse')}}</div>
<div class="row justify-content-between"> <div class="row justify-content-between">
<!-- v-if="cid == 18||cid == 21||cid == 22||cid == 32" -->
<div class="item col-lg-3 col-md-6 mb-4 col-xs-12" v-for="(item,index) in recommend" :key="index"> <div class="item col-lg-3 col-md-6 mb-4 col-xs-12" v-for="(item,index) in recommend" :key="index">
<router-link :to="`/college/detail/${item.category_id}/${item.id}`"> <router-link :to="`/college/detail/${item.category_id}/${item.id}`">
<div class="banner"> <div class="banner">

30
src/views/college/latestnews.vue

@ -20,10 +20,11 @@
<!-- <div class="title h3 my-4">{{title}}</div> --> <!-- <div class="title h3 my-4">{{title}}</div> -->
<div class="row justify-content-between" style="margin-top: 20px;"> <div class="row justify-content-between" style="margin-top: 20px;">
<router-link :to="`/college/detail/${cid}/${item.id}`" class="item col-lg-3 col-md-6 mb-4 col-xs-12" v-for="(item,index) in articleList" :key="index"> <router-link :to="`/college/detail/${cid}/${item.id}`" class="item col-lg-3 col-md-6 mb-4 col-xs-12"
v-for="(item,index) in articleList.slice((currentPage - 1) * pagesize,currentPage * pagesize)" :key="index">
<div class="banner"> <div class="banner">
<!-- <img src="http://iph.href.lu/260x150" alt /> --> <!-- <img src="http://iph.href.lu/260x150" alt /> -->
<img :src="item.full_cover" alt /> <img :src="item.full_cover" alt v-if="item.full_cover !== ''" />
</div> </div>
<div class="txt"> <div class="txt">
{{item.title}} {{item.title}}
@ -32,6 +33,17 @@
<div class="txt2">{{item.updated_at}}</div> <div class="txt2">{{item.updated_at}}</div>
</router-link> </router-link>
</div> </div>
<div class="p-2" style="width: 100%;">
<!--
@size-change // pageSize
@current-change // currentPage
:current-page // false,
:page-size //
:total // ,
-->
<el-pagination layout="prev, pager, next" :page-size="pagesize" :total="articleList.length"
:current-page="currentPage" @current-change="handleCurrentChange"></el-pagination>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -47,6 +59,9 @@ export default {
cid: this.$route.params.cid, cid: this.$route.params.cid,
articleList: [], articleList: [],
itemList: [],// itemList: [],//
// total:10,
pagesize:4,
currentPage:1
} }
}, },
computed: { computed: {
@ -81,7 +96,6 @@ export default {
getArticleList() { getArticleList() {
College.getArticleList(this.cid).then(data => { College.getArticleList(this.cid).then(data => {
this.articleList = data; this.articleList = data;
}).catch(); }).catch();
}, },
getCollegeLinks() { getCollegeLinks() {
@ -93,8 +107,11 @@ export default {
}) })
}) })
}).catch(err => {}); }).catch(err => {});
}, },
//
handleCurrentChange(currentPage) {
this.currentPage = currentPage;
}
}, },
watch: { watch: {
$route() { $route() {
@ -170,5 +187,8 @@ export default {
color: #fff !important; color: #fff !important;
/* 写进去,有效代码 */ /* 写进去,有效代码 */
} }
/deep/ .el-pagination{
display: flex;
justify-content: center;
}
</style> </style>

Loading…
Cancel
Save