11
This commit is contained in:
@@ -48,6 +48,60 @@ const actions = {
|
||||
uni.$u.toast("获取信息失败");
|
||||
})
|
||||
},
|
||||
async comment({ commit, state},params) {
|
||||
return new Promise((resolve,reject)=>{
|
||||
uni.$u.http.post('/friendcircle/comment',params).then(data=>{
|
||||
console.log("评论成功",data);
|
||||
let index = -1;
|
||||
for(let i=0;i<state.list.length;i++){
|
||||
if(state.list[i].id==params.id){
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log("index",index);
|
||||
if(index!=-1){
|
||||
state.list[index].comments.unshift(params);
|
||||
resolve(data);
|
||||
}else{
|
||||
reject(data);
|
||||
}
|
||||
}).catch(e=>{
|
||||
console.log("评论失败",e);
|
||||
uni.$u.toast("评论失败");
|
||||
reject(e);
|
||||
})
|
||||
})
|
||||
},
|
||||
async like({commit, state},params) {
|
||||
return new Promise((resolve,reject)=>{
|
||||
uni.$u.http.post('/friendcircle/like',params).then(data=>{
|
||||
console.log("点赞成功",data);
|
||||
let index = -1;
|
||||
for(let i=0;i<state.list.length;i++){
|
||||
if(state.list[i].id==params.id){
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log("index",index);
|
||||
if(index!=-1){
|
||||
if(data.is_liked){
|
||||
state.list[index].likes.push(params.user_id);
|
||||
}else{
|
||||
state.list[index].likes.splice(state.list[index].likes.indexOf(params.user_id),1);
|
||||
}
|
||||
resolve(data);
|
||||
}else{
|
||||
reject(data);
|
||||
}
|
||||
}).catch(e=>{
|
||||
console.log("点赞失败",e);
|
||||
uni.$u.toast("点赞失败");
|
||||
reject(e);
|
||||
})
|
||||
})
|
||||
},
|
||||
async updateUnreadCount({commit,state},v) {
|
||||
commit("SET_UNREAD_COUNT", state.unread_count+v);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user