Commit a583634b by yanju

完善首页 修复项目 博客 问答页多次请求数据

parent ebb9a65c
...@@ -48,6 +48,8 @@ export default { ...@@ -48,6 +48,8 @@ export default {
otherFollowing: '/api/user/', //获取ta的关注(列表) +{userId}/follower otherFollowing: '/api/user/', //获取ta的关注(列表) +{userId}/follower
blacklist: '/api/my/blacklist/', //获取黑名单 +{userId} blacklist: '/api/my/blacklist/', //获取黑名单 +{userId}
hotBloggers:'/api/user/hotBloggers',//热门博主 hotBloggers:'/api/user/hotBloggers',//热门博主
elites:'/api/user/elites',//社区精英
active:'/api/user/actives',//活跃用户
}, },
Authentication:{ Authentication:{
......
...@@ -95,15 +95,9 @@ export default { ...@@ -95,15 +95,9 @@ export default {
this.getLabelTitle(); this.getLabelTitle();
this.dataGetQuestionCategory(); this.dataGetQuestionCategory();
}, },
/*computed: {
labelTitle: function () {
return this.$route.query.id
}
},*/
watch:{ watch:{
$route(){ $route(){
this.restartPagination(); this.restartPagination();
this.dataGetQuestionList(1);
this.getLabelTitle() this.getLabelTitle()
} }
}, },
......
...@@ -100,7 +100,6 @@ export default { ...@@ -100,7 +100,6 @@ export default {
watch: { watch: {
$route: function () { $route: function () {
this.restartPagination(); this.restartPagination();
this.dataGetBlogList(1);
this.getLabelTitle(); this.getLabelTitle();
} }
}, },
......
...@@ -10,18 +10,29 @@ ...@@ -10,18 +10,29 @@
</card-container> </card-container>
</div> </div>
<div class="home-container__r"> <div class="home-container__r">
<card-container style="margin-top: 40px" title="最新资讯" label="换一换" more="更多" :clickToGetMore="()=>changeRoute('/blog')"> <card-container style="margin-top: 40px" title="最新资讯" label="换一换" more="更多" @listenCardConMore="changeRoute('/news')">
<div class="information-wrap" v-for="(val,index) in newsList" :key="val.contentId">
<p class="information-time">{{dateConvert(val.createTime)}}</p>
<p class="information-content">{{val.title}}</p>
</div>
</card-container> </card-container>
<card-container style="margin-top: 16px" title="话题热搜榜" label="实时更新" more="更多"> <card-container style="margin-top: 16px" title="话题热搜榜" label="实时更新" more="更多" @listenCardConMore="changeRoute('/topic')">
<nuxt-link tag="div" :to="'/topic/detail/'+val.topicName" class="topic-content__c" v-for="(val,index) in topicList" :key="val.topicId" >
<p>#{{val.topicName}}#</p>
<h6>{{val.referenceCount}}</h6>
</nuxt-link>
</card-container> </card-container>
<card-container style="margin-top: 16px" title="社区精英" label="换一换" more="更多">
</card-container>
<card-container style="margin-top: 16px" title="推荐问答" label="换一换" more="更多"> <card-container style="margin-top: 16px" title="社区精英" label="换一换" >
<user-card style="padding-bottom: 2px;padding-top: 2px" v-for="(val,index) in elitesList" :key="val.userId" :info="val"></user-card>
</card-container>
<card-container style="margin-top: 16px" title="热门问答" label="换一换" more="更多" @listenCardConMore="changeRoute('/answer')">
<nuxt-link tag="div" :to="'/topic/detail/'+val.questionId" class="topic-content__c" v-for="(val,index) in answerList" :key="val.questionId" >
<p>{{val.questionTitle}}</p>
<h6>{{val.replyNumber}}</h6>
</nuxt-link>
</card-container> </card-container>
</div> </div>
...@@ -35,6 +46,8 @@ ...@@ -35,6 +46,8 @@
import CardContainer from '../components/pc/cardContainer'; import CardContainer from '../components/pc/cardContainer';
import ProjectCard from '../components/pc/projectCard'; import ProjectCard from '../components/pc/projectCard';
import config from '../action/config'; import config from '../action/config';
import UserCard from '../components/pc/userCard2'
import {dateConvert} from '../action/utils/dataConvert'
export default { export default {
...@@ -43,14 +56,14 @@ ...@@ -43,14 +56,14 @@
let blogList = await $axios.$get(config.api.get.Blog.list,{ let blogList = await $axios.$get(config.api.get.Blog.list,{
params:{ params:{
page:1, page:1,
size:3, size:5,
} }
}); });
let projectList = await $axios.$get(config.api.get.Project.list,{ let projectList = await $axios.$get(config.api.get.Project.list,{
params:{ params:{
page:1, page:1,
size:3, size:5,
} }
}); });
...@@ -68,30 +81,75 @@ ...@@ -68,30 +81,75 @@
'https://yundingweb.oss-cn-beijing.aliyuncs.com/yunding/20190828/161fecb3d8b441c5b340319c62508513-file', 'https://yundingweb.oss-cn-beijing.aliyuncs.com/yunding/20190828/161fecb3d8b441c5b340319c62508513-file',
'https://s2.ax1x.com/2020/01/13/lHpvY4.png', 'https://s2.ax1x.com/2020/01/13/lHpvY4.png',
], ],
elitesList:[],
answerList:[],
topicList:[],
newsList:[],
} }
}, },
components:{ created() {
this.dataGetHotBloggersList();
CardContainer,Banner,ProjectCard this.dataGetHotAnswerList();
this.dataGetHotTopicList();
this.dataGetNewsList();
},
components:{
CardContainer,Banner,ProjectCard,UserCard
}, },
methods:{ methods:{
changeRoute(r){ changeRoute(r){
return this.$router.push(r); return this.$router.push(r);
}, },
showAlert(){ dateConvert(time) {
// $alert 使用方法 return dateConvert(time);
this.$alert('确认清空消息列表?', '', { },
confirmButtonText: '确定',
// callback: action => { dataGetHotBloggersList() {
// this.$message({ let params={
// type: 'info', page: 1,
// message: `action: ${ action }`, size: 5
// confirmButtonPosition: 'left', };
// }); this.$axios.$get(config.api.get.User.elites,{params:params})
// } .then((response)=>{
}); this.elitesList = response.data.dataList;
});
},
dataGetHotAnswerList() {
let params={
page: 1,
size: 10
};
this.$axios.$get(config.api.get.Question.hotList,{params:params})
.then((response)=>{
this.answerList = response.data.dataList;
});
},
dataGetHotTopicList() {
let params={
page: 1,
size: 10
};
this.$axios.$get(config.api.get.Topic.hotSearch,{params:params})
.then((response)=>{
this.topicList = response.data.dataList;
});
},
dataGetNewsList() {
let params = {
page: 1,
size: 5,
type: 1
};
this.$axios.$get(config.api.get.Content.list + '/13/contents',
{
params: params
}).then((response) => {
this.newsList = response.data.dataList;
})
}, },
}, },
mounted(){ mounted(){
...@@ -113,6 +171,59 @@ ...@@ -113,6 +171,59 @@
.home-container__r{ .home-container__r{
overflow:hidden; overflow:hidden;
width:302*$length; width:302*$length;
.topic-content__c{
@extend %flex-row-spb;
@extend %cursorPointer;
padding:0 16*$length;
box-sizing: border-box;
margin-top:20*$length;
p{
width:190*$length;
@include fontStyle(12,16,500,#333,left);
@extend %nowrap;
@extend %animate-transition;
&:hover{
color:#00AAE6
}
}
h6{
@include fontStyle(12,16,500,#ccc,left);
@extend %nowrap;
}
}
.information-wrap {
padding:12*$length 16*$length 0;
box-sizing: border-box;
width:302*$length;
&:hover{
.information-time{
color:rgba(0,170,230,.6);
}
.information-content{
color:rgba(0,170,230,1);
}
}
.information-time {
@extend %cursorPointer;
@include fontStyle(12, 16, 500, #CCC, left);
@extend %animate-transition;
@extend %nowrap;
}
.information-content {
width: 100%;
overflow: hidden;
margin-top: 3*$length;
@extend %nowrap;
@extend %cursorPointer;
@extend %animate-transition;
@include fontStyle(14, 19, 500, #333, left);
}
}
} }
} }
</style> </style>
...@@ -78,21 +78,30 @@ export default { ...@@ -78,21 +78,30 @@ export default {
} }
}, },
created() { created() {
this.$router.replace({
path: '/project', if(this.$route.query.type){
query: {
type: 'all' this.dataGetProjectCategory();
} this.dataGetHotProjectList();
}); this.getLabelTitle();
this.dataGetProjectCategory(); }else{
this.dataGetHotProjectList(); this.$router.replace({
this.getLabelTitle(); path: '/project',
query: {
type: 'all'
}
});
this.dataGetProjectCategory();
this.dataGetHotProjectList();
this.getLabelTitle();
}
}, },
watch:{ watch:{
$route(){ $route(){
this.restartPagination(); this.restartPagination();
this.dataGetProjectList(1);
this.getLabelTitle() this.getLabelTitle()
} }
}, },
...@@ -129,7 +138,7 @@ export default { ...@@ -129,7 +138,7 @@ export default {
page:1, page:1,
size:5 size:5
}; };
this.$axios.$get(config.api.get.Project.list,{params:params}).then((response)=>{ this.$axios.$get(config.api.get.Project.hotList,{params:params}).then((response)=>{
this.hotProjectList = response.data.dataList; this.hotProjectList = response.data.dataList;
}) })
......
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