Commit b027b505 by yanju

Merge branch 'xue' into 'master'

问答展示分类

See merge request pigbigbig/beyond-clouds-front!61
parents 5feebf8d 557c7af9
......@@ -15,7 +15,7 @@
<answer-card card-type="2" v-for="(val,index) in QuestionList" :info="val" :key="val.questionId"></answer-card>
</card-container>
<div class="pagination">
<pagination style="margin: 0 auto;" :pages="pages" v-on:listenPageChange="changePage"></pagination>
<pagination style="margin: 0 auto;" :pages="pages" ref="pagination" v-on:listenPageChange="changePage"></pagination>
</div>
</div>
<div class="answer-container__right">
......@@ -73,43 +73,39 @@ export default {
return{
list: [
{
label: '热门推荐',
label: '全部项目',
address: '/answer',
id: '热门推荐'
type: 'all'
},
{
label: '职业生涯',
address: '/answer',
id: '职业生涯'
},
{
label: '项目讨论',
address: '/answer',
id: '项目讨论'
},
{
label: '职场经验',
address: '/answer',
id: '职场经验'
}
],
pages:1,
QuestionList:[],
labelTitle:'',
}
},
created() {
this.$router.replace({
path: '/answer',
query: {
id: '热门推荐'
type: 'all'
}
});
this.getLabelTitle();
this.dataGetQuestionCategory();
},
computed: {
/*computed: {
labelTitle: function () {
return this.$route.query.id
}
},*/
watch:{
$route(){
this.restartPagination();
this.dataGetQuestionList(1);
this.getLabelTitle()
}
},
methods: {
toRelease(){
this.$router.push('/answer/release');
......@@ -117,14 +113,40 @@ export default {
search(){
this.$router.push('/search/answer');
},
restartPagination(){
if(process.browser){
this.$refs.pagination.setCurrentPage(1)
}
},
getLabelTitle(){
let type = this.$route.query.type;
this.list.map((val,index)=>{
if(val.type===type){
this.labelTitle = val.label
}
})
},
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
})
})
})
},
dataGetQuestionList(currentPage){
this.$axios.$get(config.api.get.Question.list,{
params:{
page:currentPage,
size:10,
}
}).then((response)=>{
let params={
page:currentPage,
size:7
};
if(this.$route.query.type&&this.$route.query.type!=='all' ){
params.categoryId = this.$route.query.type
}
this.$axios.$get(config.api.get.Question.list,{params:params}).then((response)=>{
this.QuestionList=response.data.dataList;
this.pages = response.data.totalPage;
})
......
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