|
@@ -70,7 +70,7 @@ export default { |
|
@@ -70,7 +70,7 @@ export default { |
70
|
},
|
70
|
},
|
71
|
methods: {
|
71
|
methods: {
|
72
|
...mapActions(['fetchCommentList', 'fetchReplayList', 'postComment']),
|
72
|
...mapActions(['fetchCommentList', 'fetchReplayList', 'postComment']),
|
73
|
- async fetchComments(refresh) {
|
73
|
+ async fetchComments(lazy) {
|
74
|
const result = await this.fetchCommentList({
|
74
|
const result = await this.fetchCommentList({
|
75
|
destId: this.destId,
|
75
|
destId: this.destId,
|
76
|
columnType: this.columnType,
|
76
|
columnType: this.columnType,
|
|
@@ -81,23 +81,24 @@ export default { |
|
@@ -81,23 +81,24 @@ export default { |
81
|
if (result.code === 200) {
|
81
|
if (result.code === 200) {
|
82
|
const comments = get(result, 'data.commentInfos', []);
|
82
|
const comments = get(result, 'data.commentInfos', []);
|
83
|
|
83
|
|
84
|
- if (refresh) {
|
|
|
85
|
- setTimeout(() => {
|
84
|
+ setTimeout(() => {
|
|
|
85
|
+ if (this.page === 1) {
|
86
|
this.commentList = comments;
|
86
|
this.commentList = comments;
|
87
|
- }, 200);
|
|
|
88
|
- } else {
|
|
|
89
|
- this.commentList = this.commentList.concat(comments);
|
|
|
90
|
- }
|
|
|
91
|
-
|
|
|
92
|
- if (comments.length) {
|
|
|
93
|
- this.page++;
|
|
|
94
|
- } else {
|
|
|
95
|
- dirty = false;
|
|
|
96
|
- }
|
|
|
97
|
- this.$emit('on-page-change', {
|
|
|
98
|
- page: this.page,
|
|
|
99
|
- size: result.data.total
|
|
|
100
|
- });
|
87
|
+ console.log('this.commentList')
|
|
|
88
|
+ } else {
|
|
|
89
|
+ this.commentList = this.commentList.concat(comments);
|
|
|
90
|
+ }
|
|
|
91
|
+ if (comments.length) {
|
|
|
92
|
+ this.page++;
|
|
|
93
|
+ } else {
|
|
|
94
|
+ dirty = false;
|
|
|
95
|
+ }
|
|
|
96
|
+ this.$emit('on-page-change', {
|
|
|
97
|
+ page: this.page,
|
|
|
98
|
+ size: result.data.total
|
|
|
99
|
+ });
|
|
|
100
|
+ this.$refs.scroll.forceUpdate(dirty);
|
|
|
101
|
+ }, lazy ? 200 : 0);
|
101
|
} else {
|
102
|
} else {
|
102
|
this.$createToast && this.$createToast({
|
103
|
this.$createToast && this.$createToast({
|
103
|
txt: result.message || '服务器开小差了',
|
104
|
txt: result.message || '服务器开小差了',
|
|
@@ -105,20 +106,20 @@ export default { |
|
@@ -105,20 +106,20 @@ export default { |
105
|
time: 1000
|
106
|
time: 1000
|
106
|
}).show();
|
107
|
}).show();
|
107
|
}
|
108
|
}
|
108
|
- this.$refs.scroll.forceUpdate(dirty);
|
|
|
109
|
return result;
|
109
|
return result;
|
110
|
},
|
110
|
},
|
111
|
onPullingUp() {
|
111
|
onPullingUp() {
|
112
|
this.fetchComments();
|
112
|
this.fetchComments();
|
113
|
},
|
113
|
},
|
114
|
async onComment() {
|
114
|
async onComment() {
|
115
|
- this.init();
|
115
|
+ this.page = 1;
|
|
|
116
|
+ this.$refs.scroll.scrollTo(0, 0, 200);
|
|
|
117
|
+ this.fetchComments(false);
|
116
|
},
|
118
|
},
|
117
|
async init() {
|
119
|
async init() {
|
118
|
this.page = 1;
|
120
|
this.page = 1;
|
119
|
this.commentList = [];
|
121
|
this.commentList = [];
|
120
|
- this.$refs.scroll.forceUpdate(true);
|
|
|
121
|
- await this.fetchComments(true);
|
122
|
+ this.fetchComments(true);
|
122
|
},
|
123
|
},
|
123
|
async onReply({commentId}) {
|
124
|
async onReply({commentId}) {
|
124
|
const result = await this.fetchReplayList({
|
125
|
const result = await this.fetchReplayList({
|