```//点赞
commentLike(e) {
var that = this;
let token = that.$storage.get('token') || null,
userInfo = that.$storage.get('users_info') || null;
that.$R.post('Api&a=toLike&_ajax=1', {
id: e.id,
users_id: userInfo.users_id,
isLike: e.isLike
}).then(res => {
uni.showToast({
title: '操作成功',
duration: 1000
});
that.comments.push();
that.getComment()
});
},
input(e) {
this.content = e
},
//发送评论
commentSend(e) {
var that = this;
let token = that.$storage.get('token') || null,
userInfo = that.$storage.get('users_info') || null;
that.$R.post('Api&a=postComment&_ajax=1', {
aid: that.aid,
userInfo: userInfo,
token: token,
content: that.content,
layer: e,
users_id: userInfo.users_id,
superNickname: that.superNickname,
superCommentId: that.superCommentId
}).then(res => {
uni.showToast({
title: '评论成功',
duration: 1000
});
that.content = "";
that.getComment()
});
},
// 获取评论
getComment() {
var that = this;
that.comments = [];
let token = that.$storage.get('token') || null,
userInfo = that.$storage.get('users_info') || null;
var users_id = userInfo ? userInfo.users_id : 0;
that.$R.post('Api&a=getComment&_ajax=1', {
aid: that.aid,
users_id: users_id,
layer: 1
}).then(res => {
console.log(res.data)
for (let item of res.data) {
item.nickname = item.nickname.substr(0, 1) + '*' + item.nickname.substr(item.nickname
.length - 1);
for (let i in item.children) {
let nickname = item.children[i].nickname
if (nickname) {
nickname = nickname.substr(0, 1) + '*' + nickname.substr(nickname.length - 1);
item.children[i].nickname = nickname
}
let superNickname = item.children[i].superNickname
if (superNickname) {
superNickname = superNickname.substr(0, 1) + '*' + superNickname.substr(
superNickname.length - 1);
item.children[i].superNickname = superNickname
}
}
that.comments.push(item);
}
//that.comments = res.data
});
},