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