Authored by yyq

fix detail

... ... @@ -147,51 +147,53 @@ export default {
}
}
if (!get(result, 'data.total')) {
this.empty = true;
} else {
this.empty = false;
}
return result;
},
async fetchComments(pre) {
const result = await this.fetchCommentsAsync(pre);
let dirty = false;
let dirty = true;
if (result.code === 200) {
const comments = get(result, 'data.commentInfos', []);
if (!get(result, 'data.total')) {
this.empty = true;
} else {
if (comments.length) {
this.empty = false;
this.$emit('on-page-change', {
page: result.data.page,
size: result.data.total
});
if (comments.length) {
this.$emit('on-page-change', {
page: result.data.page,
size: result.data.total
});
if (pre) {
this.commentPreList.unshift(comments);
this.$nextTick(() => {
this.loadPreComment();
});
} else {
if (this.page <= 2) {
this.commentList = comments;
// 将评论滚动到可视区域
if (this.commentId) {
setTimeout(() => {
let scrollHeight = this.$refs.scroll.$el.offsetHeight;
let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);
if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {
this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetHeight);
}
}, 500);
}
} else {
this.commentList = this.commentList.concat(comments);
if (pre) {
this.commentPreList.unshift(comments);
this.$nextTick(() => {
this.loadPreComment();
});
} else {
if (this.page <= 2) {
this.commentList = comments;
// 将评论滚动到可视区域
if (this.commentId) {
setTimeout(() => {
let scrollHeight = this.$refs.scroll.$el.offsetHeight;
let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);
if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {
this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetHeight);
}
}, 500);
}
} else {
this.commentList = this.commentList.concat(comments);
}
dirty = true;
}
} else {
dirty = false;
}
this.firstLoading = false;
... ...