Commit 386cdac8 by yanju

Merge branch 'yoona' into 'master'

资讯列表页对接完成

See merge request !25
parents 969158ed d49584ce
<template>
<yun-div>
<Nav :path="path" :nav-list="navList"></Nav>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<project-card></project-card>
<Nav :show-right="false" :path="path" :nav-list="navList"></Nav>
<project-card v-for="(val,index) in newsList" :info="val" :key="val.contentId"></project-card>
<scroll-loading ref="pagination" :pages="pages" v-on:changePage="changePage"></scroll-loading>
</yun-div>
</template>
<script>
import Nav from "../../components/moblie/nav";
import ProjectCard from "../../components/moblie/projectCard";
import ScrollLoading from "../../components/moblie/scrollLoading";
import config from "../../action/config";
export default {
components: {ProjectCard, Nav},
components: {ProjectCard, Nav, ScrollLoading},
data() {
return {
path: '/news',
navList: [
{
label: '新闻速递',
id: 'all'
id: '13'
},
{
label: '行业资讯',
id: '10'
id: '14'
},
{
label: '软件更新',
id: '11'
id: '17'
}
]
],
newsList:[],
pages:1,
}
},
watch: {
$route(val){
this.restartPagination();
},
},
created() {
if (this.$route.query.type) {
return
......@@ -46,9 +48,52 @@ export default {
this.$router.replace({
path: '/news',
query: {
type: 'all'
type: '13'
}
})
},
methods: {
restartPagination(){
if(process.browser){
this.newsList = [];
this.pages = 1 ;
this.$refs.pagination.setCurrentPage(1)
}
},
handleResponse(currentPage,response){
if(currentPage===1){
this.newsList=response.data.dataList;
this.pages = response.data.totalPage;
}else{
response.data.dataList.map((val,index)=>{
this.newsList.push(val)
});
this.pages = response.data.totalPage;
}
},
dataGetNewsList(currentPage){
let params={
page:currentPage,
size:12,
type: 1
};
if(this.$route.query.type){
let id = this.$route.query.type
this.$axios.$get(config.api.get.Content.list + `${id}/contents`, {params:params})
.then((response)=>{
console.log(response);
this.handleResponse(currentPage,response)
})
}
},
changePage(currentPage){
//返回页数 请求新的数据
this.dataGetNewsList(currentPage)
},
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment