Commit c351cdb7 by yanju

Merge branch 'new-func#1' into 'master'

列表页服务端渲染

See merge request pigbigbig/beyond-clouds-front!106
parents 5d9f1511 9449ed17
......@@ -70,6 +70,19 @@ import config from "../../action/config";
import EmptyCard from '../../components/pc/emptyCard';
import UserCard from '../../components/pc/userCard2';
export default {
async asyncData({$axios}){
let typeList = await $axios.$get(config.api.get.QuestionCategory.list);
let params={
page:1,
size:7
};
let articleList = await $axios.$get(config.api.get.Question.list,{params:params});
return {articleList:articleList.data.dataList, articlePages:articleList.data.totalPage,typeList:typeList.data}
},
components: {AnswerCard, Pagination, ProjectCard, CardContainer, NavWrap,UserCard,EmptyCard},
data(){
return{
......@@ -84,12 +97,14 @@ export default {
QuestionList:[],
labelTitle:'',
repliersList:[],
firstLoad:true
}
},
created() {
this.getLabelTitle();
this.dataGetQuestionCategory();
this.dataGetHotRepliersList();
this.handleArticleList();
},
watch:{
$route(){
......@@ -99,6 +114,11 @@ export default {
},
methods: {
handleArticleList(){
this.QuestionList = this.articleList;
this.pages = this.articlePages;
},
toRelease(){
this.$router.push('/answer/release');
},
......@@ -129,16 +149,12 @@ export default {
this.repliersList = response.data.dataList;
});
},
dataGetQuestionCategory(){
this.$axios.$get(config.api.get.QuestionCategory.list).then((response)=>{
response.data.map((val,index)=>{
this.list.push({
label: val.category,
address: '/answer',
type: val.categoryId
})
this.typeList.map((val,index)=>{
this.list.push({
label: val.category,
address: '/answer',
type: val.categoryId
})
})
},
......@@ -158,7 +174,11 @@ export default {
changePage(currentPage){
//返回页数 请求新的数据
this.dataGetQuestionList(currentPage)
if(this.firstLoad){
this.firstLoad = false
}else{
this.dataGetQuestionList(currentPage)
}
}
}
......
......@@ -61,7 +61,13 @@ export default {
components: {UserCard, EmptyCard, Pagination, CardContainer, NavWrap,BlogCard},
async asyncData({$axios}){
let typeList = await $axios.$get(config.api.get.BlogCategory.list);
return {typeList:typeList.data}
let params={
page:1,
size:7
};
let articleList = await $axios.$get(config.api.get.Blog.list,{params:params});
return {articleList:articleList.data.dataList, articlePages:articleList.data.totalPage,typeList:typeList.data}
},
data(){
return{
......@@ -81,6 +87,8 @@ export default {
type: 'all'
},
],
firstLoad:true
}
},
created() {
......@@ -88,6 +96,7 @@ export default {
this.getLabelTitle();
this.dataGetHotTagsList();
this.dataGetHotBloggersList();
this.handleArticleList();
},
watch: {
$route: function () {
......@@ -96,6 +105,11 @@ export default {
}
},
methods: {
handleArticleList(){
this.blogList = this.articleList;
this.pages = this.articlePages;
},
dataGetBlogCategory(){
this.typeList.map((val,index)=>{
this.list.push({
......@@ -160,7 +174,11 @@ export default {
},
changePage(currentPage){
//返回页数 请求新的数据
this.dataGetBlogList(currentPage)
if(this.firstLoad){
this.firstLoad = false
}else{
this.dataGetBlogList(currentPage)
}
}
}
}
......
......@@ -53,7 +53,13 @@ export default {
async asyncData({$axios}){
let typeList = await $axios.$get(config.api.get.ProjectCategory.list);
return {typeList:typeList.data}
let params={
page:1,
size:7
};
let articleList = await $axios.$get(config.api.get.Project.list,{params:params});
return {articleList:articleList.data.dataList, articlePages:articleList.data.totalPage,typeList:typeList.data}
},
data(){
......@@ -78,9 +84,6 @@ export default {
if(this.$route.query.type){
this.dataGetProjectCategory();
this.dataGetHotProjectList();
this.getLabelTitle();
}else{
this.$router.replace({
path: '/project',
......@@ -88,10 +91,12 @@ export default {
type: 'all'
}
});
this.dataGetProjectCategory();
this.dataGetHotProjectList();
this.getLabelTitle();
}
this.handleArticleList();
this.dataGetProjectCategory();
this.dataGetHotProjectList();
this.getLabelTitle();
},
......@@ -104,6 +109,11 @@ export default {
},
methods: {
handleArticleList(){
this.projectList = this.articleList;
this.pages = this.articlePages;
},
toRelease(){
this.$router.push('/project/release')
},
......@@ -156,7 +166,11 @@ export default {
},
changePage(currentPage){
//返回页数 请求新的数据
this.dataGetProjectList(currentPage);
if(this.firstLoad){
this.firstLoad = false
}else{
this.dataGetProjectList(currentPage)
}
},
}
}
......
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