...
|
...
|
@@ -2,7 +2,10 @@ |
|
|
<div class="comment-list">
|
|
|
<div class="comment-content-flex">
|
|
|
<div class="comment-content">
|
|
|
<Scroll ref="scroll" :data="commentList" :options="scrollOption" @pulling-up="onPullingUp">
|
|
|
<div class="loading" v-if="firstLoading">
|
|
|
<Loading></Loading>
|
|
|
</div>
|
|
|
<Scroll v-else ref="scroll" :data="commentList" :options="scrollOption" @pulling-up="onPullingUp">
|
|
|
<CommentItem
|
|
|
v-for="comment in commentList"
|
|
|
:key="comment.parentComment.id"
|
...
|
...
|
@@ -16,7 +19,7 @@ |
|
|
</Scroll>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="comment-footer">
|
|
|
<div class="comment-footer" v-if="!firstLoading">
|
|
|
<CommentPlaceholder
|
|
|
class="comment-input"
|
|
|
:dest-id="destId"
|
...
|
...
|
@@ -33,7 +36,7 @@ |
|
|
|
|
|
<script>
|
|
|
import CommentItem from './comment-item.vue';
|
|
|
import {Scroll} from 'cube-ui';
|
|
|
import {Scroll, Loading} from 'cube-ui';
|
|
|
import {get} from 'lodash';
|
|
|
import {createNamespacedHelpers} from 'vuex';
|
|
|
const {mapActions} = createNamespacedHelpers('comment');
|
...
|
...
|
@@ -53,6 +56,7 @@ export default { |
|
|
return {
|
|
|
page: 1,
|
|
|
commentList: [],
|
|
|
firstLoading: true,
|
|
|
scrollOption: {
|
|
|
bounce: false,
|
|
|
pullUpLoad: {
|
...
|
...
|
@@ -79,11 +83,17 @@ export default { |
|
|
if (result.code === 200) {
|
|
|
const comments = get(result, 'data.commentInfos', []);
|
|
|
|
|
|
this.$emit('on-page-change', {
|
|
|
page: this.page,
|
|
|
size: result.data.total
|
|
|
});
|
|
|
if (this.page === 1) {
|
|
|
this.commentList = comments;
|
|
|
this.$nextTick(() => {
|
|
|
this.$emit('on-page-ready', {success: true});
|
|
|
await new Promise((r) => {
|
|
|
setTimeout(() => {
|
|
|
r();
|
|
|
}, 400);
|
|
|
});
|
|
|
this.commentList = comments;
|
|
|
} else {
|
|
|
this.commentList = this.commentList.concat(comments);
|
|
|
}
|
...
|
...
|
@@ -92,11 +102,10 @@ export default { |
|
|
} else {
|
|
|
dirty = false;
|
|
|
}
|
|
|
this.$emit('on-page-change', {
|
|
|
page: this.page,
|
|
|
size: result.data.total
|
|
|
});
|
|
|
this.firstLoading = false;
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.scroll.forceUpdate(dirty);
|
|
|
});
|
|
|
} else {
|
|
|
this.$createToast && this.$createToast({
|
|
|
txt: result.message || '服务器开小差了',
|
...
|
...
|
@@ -119,6 +128,7 @@ export default { |
|
|
async init() {
|
|
|
this.page = 1;
|
|
|
this.commentList = [];
|
|
|
this.firstLoading = true;
|
|
|
this.fetchComments(true);
|
|
|
},
|
|
|
async onReply({commentId}) {
|
...
|
...
|
@@ -141,11 +151,19 @@ export default { |
|
|
}
|
|
|
}
|
|
|
},
|
|
|
components: {Scroll, CommentItem}
|
|
|
components: {Scroll, CommentItem, Loading}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
.loading {
|
|
|
width: 100%;
|
|
|
height: 200px;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
}
|
|
|
|
|
|
.comment-list {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
...
|
...
|
|