|
@@ -25,12 +25,29 @@
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</v-row>
|
|
</v-row>
|
|
|
|
|
+ <v-snackbar
|
|
|
|
|
+ v-model="showMessage"
|
|
|
|
|
+ :top="true"
|
|
|
|
|
+ :timeout="1000"
|
|
|
|
|
+ >
|
|
|
|
|
+ {{ message }}
|
|
|
|
|
+ <template v-slot:action="{ attrs }">
|
|
|
|
|
+ <v-btn
|
|
|
|
|
+ color="pink"
|
|
|
|
|
+ text
|
|
|
|
|
+ v-bind="attrs"
|
|
|
|
|
+ @click="showMessage = false"
|
|
|
|
|
+ >
|
|
|
|
|
+ 关闭
|
|
|
|
|
+ </v-btn>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </v-snackbar>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import Comment from '@/components/comment'
|
|
import Comment from '@/components/comment'
|
|
|
-import { videoComment } from '@/api/comment/comment'
|
|
|
|
|
|
|
+import { submitComment, videoComment } from '@/api/comment/comment'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'CommentCard',
|
|
name: 'CommentCard',
|
|
@@ -57,17 +74,20 @@ export default {
|
|
|
liked: 'liked',
|
|
liked: 'liked',
|
|
|
reply: 'reply',
|
|
reply: 'reply',
|
|
|
createAt: 'createAt',
|
|
createAt: 'createAt',
|
|
|
- user: 'visitor'
|
|
|
|
|
|
|
+ user: 'user'
|
|
|
},
|
|
},
|
|
|
currentUser: null,
|
|
currentUser: null,
|
|
|
busy: false,
|
|
busy: false,
|
|
|
- page: 1
|
|
|
|
|
|
|
+ page: 1,
|
|
|
|
|
+ showMessage: false,
|
|
|
|
|
+ message: ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
const userInfo = this.$store.state.user.userInfo
|
|
const userInfo = this.$store.state.user.userInfo
|
|
|
if (userInfo !== null) {
|
|
if (userInfo !== null) {
|
|
|
this.currentUser = {
|
|
this.currentUser = {
|
|
|
|
|
+ userId: userInfo.userId,
|
|
|
name: userInfo.username,
|
|
name: userInfo.username,
|
|
|
avatar: userInfo.avatarUrl
|
|
avatar: userInfo.avatarUrl
|
|
|
}
|
|
}
|
|
@@ -101,7 +121,6 @@ export default {
|
|
|
for (const item of res.data.list) {
|
|
for (const item of res.data.list) {
|
|
|
this.videoComments.push(item)
|
|
this.videoComments.push(item)
|
|
|
}
|
|
}
|
|
|
- console.log('已获取的评论数量: ' + this.videoComments.length)
|
|
|
|
|
} else {
|
|
} else {
|
|
|
console.error(res.msg)
|
|
console.error(res.msg)
|
|
|
}
|
|
}
|
|
@@ -114,11 +133,29 @@ export default {
|
|
|
async submit(newComment, parent, add) {
|
|
async submit(newComment, parent, add) {
|
|
|
const res = await new Promise((resolve) => {
|
|
const res = await new Promise((resolve) => {
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
|
|
+ var parentId = null
|
|
|
|
|
+ if (parent !== null) {
|
|
|
|
|
+ parentId = parent.id
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const commentSbtData = {}
|
|
|
|
|
+ commentSbtData.videoId = this.video.videoId
|
|
|
|
|
+ commentSbtData.userId = newComment.user.userId
|
|
|
|
|
+ commentSbtData.parentId = parentId
|
|
|
|
|
+ commentSbtData.content = newComment.content
|
|
|
|
|
+ commentSbtData.imgSrc = newComment.imgSrc
|
|
|
|
|
+ commentSbtData.createAt = newComment.createAt
|
|
|
|
|
+ submitComment(commentSbtData).then(res => {
|
|
|
|
|
+ if (res.code !== 0) {
|
|
|
|
|
+ this.message = '评论发送失败'
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
resolve({ newComment, parent })
|
|
resolve({ newComment, parent })
|
|
|
}, 300)
|
|
}, 300)
|
|
|
})
|
|
})
|
|
|
add(Object.assign(res.newComment, { _id: new Date().getTime() }))
|
|
add(Object.assign(res.newComment, { _id: new Date().getTime() }))
|
|
|
- console.log('addComment: ', res)
|
|
|
|
|
},
|
|
},
|
|
|
async like(comment) {
|
|
async like(comment) {
|
|
|
const res = await new Promise((resolve) => {
|
|
const res = await new Promise((resolve) => {
|