reghao 3 rokov pred
rodič
commit
169232e023

+ 2 - 2
src/components/card/comment-card.vue

@@ -5,10 +5,10 @@
         {{ video.commentCount }} 条评论
       </v-col>
       <v-col>
-        <span @click="getHotComments">最热</span>
+        <span @click="getNewestComments">最新</span>
       </v-col>
       <v-col>
-        <span @click="getNewestComments">最新</span>
+        <span @click="getHotComments">最热</span>
       </v-col>
     </v-row>
     <v-divider />

+ 14 - 0
src/components/comment/index.vue

@@ -83,6 +83,8 @@
 import CommentForm from './components/CommentForm'
 import CommentList from './components/CommentList'
 import CommentItem from './components/CommentItem'
+import { childComment } from '@/api/comment/comment'
+
 export default {
   name: 'JuejinComment',
   components: { CommentList, CommentItem, CommentForm },
@@ -446,6 +448,18 @@ export default {
         this.currentPage = page
         console.log('获取下一页子评论')
       }
+    },
+    getChildComments(parentId) {
+      childComment(parentId, this.page).then(res => {
+        if (res.code === 0) {
+          this.page += 1
+        } else {
+          console.error(res.msg)
+        }
+      })
+        .catch(error => {
+          console.error(error.message)
+        })
     }
   }
 }