|
|
@@ -213,6 +213,7 @@ import { similarVideo, videoInfo, videoErrorReport, downloadVideo, cacheBiliVide
|
|
|
import { collectItem } from '@/api/collect'
|
|
|
import { getUserInfo } from '@/api/user'
|
|
|
import { submitAccessCode } from '@/api/content'
|
|
|
+import { publishComment, getComment } from '@/api/comment'
|
|
|
|
|
|
export default {
|
|
|
name: 'VideoPage',
|
|
|
@@ -221,32 +222,43 @@ export default {
|
|
|
return {
|
|
|
/** ********************************************************************/
|
|
|
wrapStyle: '',
|
|
|
- videoComments: [],
|
|
|
+ videoComments: [
|
|
|
+ {
|
|
|
+ commentId: 114511,
|
|
|
+ content: 'this is comment content',
|
|
|
+ imageUrl: '//oss.reghao.cn/image/a/41e5094eac724efeb2675eea22dd4468.jpg',
|
|
|
+ children: [],
|
|
|
+ likes: 0,
|
|
|
+ liked: false,
|
|
|
+ reply: null,
|
|
|
+ createAt: 1700271326393,
|
|
|
+ user: {
|
|
|
+ userId: 10001,
|
|
|
+ name: '西瓜',
|
|
|
+ avatar: '//oss.reghao.cn/image/a/41e5094eac724efeb2675eea22dd4468.jpg'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
currentUser: {
|
|
|
+ userId: 10002,
|
|
|
name: '草莓',
|
|
|
- avatar: '//picx.zhimg.com/v2-a2c89378a6332cbfed3e28b5ab84feb7.jpg'
|
|
|
+ avatar: '//picx.zhimg.com/v2-a2c89378a6332cbfed3e28b5ab84feb7.jpg',
|
|
|
+ author: true
|
|
|
},
|
|
|
+ // 自定义组件中 comment 对象的字段名
|
|
|
props: {
|
|
|
- id: 114511,
|
|
|
- content: 'this is comment content',
|
|
|
- imgSrc: '//oss.reghao.cn/image/a/41e5094eac724efeb2675eea22dd4468.jpg',
|
|
|
- children: [],
|
|
|
- likes: 0,
|
|
|
- liked: false,
|
|
|
- reply: null,
|
|
|
+ id: 'commentId',
|
|
|
+ content: 'content',
|
|
|
+ imgSrc: 'imageUrl',
|
|
|
+ children: 'children',
|
|
|
+ likes: 'likes',
|
|
|
+ liked: 'liked',
|
|
|
+ reply: 'reply',
|
|
|
createAt: 'createAt',
|
|
|
- user: {
|
|
|
- name: '芒果',
|
|
|
- avatar: '//oss.reghao.cn/image/a/41e5094eac724efeb2675eea22dd4468.jpg'
|
|
|
- }
|
|
|
+ user: 'user'
|
|
|
},
|
|
|
/** ********************************************************************/
|
|
|
video: null,
|
|
|
- videoProp: {
|
|
|
- info: null,
|
|
|
- autoPlay: false,
|
|
|
- playlist: []
|
|
|
- },
|
|
|
user: null,
|
|
|
similarVideos: [],
|
|
|
isCollected: false,
|
|
|
@@ -280,6 +292,13 @@ export default {
|
|
|
this.accessCodeForm.contentId = videoId
|
|
|
this.getVideoInfo(videoId)
|
|
|
this.getSimilarVideos(videoId)
|
|
|
+
|
|
|
+ getComment(videoId, 1).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ console.log(resp.data)
|
|
|
+ this.videoComments = resp.data.list
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
mounted() {
|
|
|
const header = this.$refs.header
|
|
|
@@ -293,8 +312,6 @@ export default {
|
|
|
videoInfo(videoId).then(resp => {
|
|
|
if (resp.code === 0) {
|
|
|
// this.showAccessCodeDialog = true
|
|
|
- this.videoProp = resp.data
|
|
|
-
|
|
|
this.video = resp.data
|
|
|
document.title = resp.data.title
|
|
|
this.userId = resp.data.userId
|
|
|
@@ -479,6 +496,8 @@ export default {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ // ****************************************************************************************************************
|
|
|
+ // 评论
|
|
|
async submit(newComment, parent, add) {
|
|
|
const res = await new Promise((resolve) => {
|
|
|
setTimeout(() => {
|
|
|
@@ -486,7 +505,23 @@ export default {
|
|
|
}, 300)
|
|
|
})
|
|
|
add(Object.assign(res.newComment, { _id: new Date().getTime() }))
|
|
|
+ if (res.parent !== null) {
|
|
|
+ console.log('parent: ', res.parent)
|
|
|
+ }
|
|
|
console.log('addComment: ', res)
|
|
|
+ publishComment().then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.$notify.success({
|
|
|
+ message: '评论已发布',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$notify.warning({
|
|
|
+ message: '评论发布失败',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
async like(comment) {
|
|
|
const res = await new Promise((resolve) => {
|
|
|
@@ -500,9 +535,7 @@ export default {
|
|
|
async uploadImg({ file, callback }) {
|
|
|
const res = await new Promise((resolve, reject) => {
|
|
|
const reader = new FileReader()
|
|
|
-
|
|
|
reader.readAsDataURL(file)
|
|
|
-
|
|
|
reader.onload = () => {
|
|
|
resolve(reader.result)
|
|
|
}
|
|
|
@@ -511,7 +544,6 @@ export default {
|
|
|
reject(reader.error)
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
callback(res)
|
|
|
console.log('uploadImg: ', res)
|
|
|
},
|
|
|
@@ -523,6 +555,7 @@ export default {
|
|
|
})
|
|
|
console.log('deleteComment: ', res)
|
|
|
}
|
|
|
+ // ****************************************************************************************************************
|
|
|
}
|
|
|
}
|
|
|
</script>
|