Authored by yyq

fix detail

@@ -147,51 +147,53 @@ export default { @@ -147,51 +147,53 @@ export default {
147 } 147 }
148 } 148 }
149 149
  150 + if (!get(result, 'data.total')) {
  151 + this.empty = true;
  152 + } else {
  153 + this.empty = false;
  154 + }
  155 +
150 return result; 156 return result;
151 }, 157 },
152 async fetchComments(pre) { 158 async fetchComments(pre) {
153 const result = await this.fetchCommentsAsync(pre); 159 const result = await this.fetchCommentsAsync(pre);
154 - let dirty = false; 160 + let dirty = true;
155 161
156 if (result.code === 200) { 162 if (result.code === 200) {
157 const comments = get(result, 'data.commentInfos', []); 163 const comments = get(result, 'data.commentInfos', []);
158 164
159 - if (!get(result, 'data.total')) {  
160 - this.empty = true;  
161 - } else {  
162 - if (comments.length) {  
163 - this.empty = false;  
164 - this.$emit('on-page-change', {  
165 - page: result.data.page,  
166 - size: result.data.total  
167 - }); 165 + if (comments.length) {
  166 + this.$emit('on-page-change', {
  167 + page: result.data.page,
  168 + size: result.data.total
  169 + });
168 170
169 - if (pre) {  
170 - this.commentPreList.unshift(comments);  
171 - this.$nextTick(() => {  
172 - this.loadPreComment();  
173 - });  
174 - } else {  
175 - if (this.page <= 2) {  
176 - this.commentList = comments;  
177 -  
178 - // 将评论滚动到可视区域  
179 - if (this.commentId) {  
180 - setTimeout(() => {  
181 - let scrollHeight = this.$refs.scroll.$el.offsetHeight;  
182 - let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);  
183 -  
184 - if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {  
185 - this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetHeight);  
186 - }  
187 - }, 500);  
188 - }  
189 - } else {  
190 - this.commentList = this.commentList.concat(comments); 171 + if (pre) {
  172 + this.commentPreList.unshift(comments);
  173 + this.$nextTick(() => {
  174 + this.loadPreComment();
  175 + });
  176 + } else {
  177 + if (this.page <= 2) {
  178 + this.commentList = comments;
  179 +
  180 + // 将评论滚动到可视区域
  181 + if (this.commentId) {
  182 + setTimeout(() => {
  183 + let scrollHeight = this.$refs.scroll.$el.offsetHeight;
  184 + let dom = this.$refs.commentList.getElementsByClassName('comment-' + this.commentId);
  185 +
  186 + if (scrollHeight && dom.length && (dom[0].offsetHeight + dom[0].offsetTop > scrollHeight)) {
  187 + this.$refs.scroll.scrollTo(0, scrollHeight - this.$refs.commentList.offsetHeight);
  188 + }
  189 + }, 500);
191 } 190 }
  191 + } else {
  192 + this.commentList = this.commentList.concat(comments);
192 } 193 }
193 - dirty = true;  
194 } 194 }
  195 + } else {
  196 + dirty = false;
195 } 197 }
196 198
197 this.firstLoading = false; 199 this.firstLoading = false;