|
|
@@ -110,7 +110,7 @@
|
|
|
<div class="text item">
|
|
|
<div ref="comment" :style="wrapStyle" class="comment-wrap">
|
|
|
<comment
|
|
|
- v-model="videoComments"
|
|
|
+ v-model="dataList"
|
|
|
:user="currentUser"
|
|
|
:props="props"
|
|
|
:before-submit="submit"
|
|
|
@@ -118,6 +118,14 @@
|
|
|
:before-delete="deleteComment"
|
|
|
:upload-img="uploadImg"
|
|
|
/>
|
|
|
+ <el-pagination
|
|
|
+ :small="screenWidth <= 768"
|
|
|
+ layout="prev, pager, next"
|
|
|
+ :page-size="pageSize"
|
|
|
+ :current-page="currentPage"
|
|
|
+ :total="totalSize"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
@@ -220,7 +228,13 @@ export default {
|
|
|
components: { SideVideoCard, VideoPlayer, UserAvatarCard, PermissionDeniedCard, comment },
|
|
|
data() {
|
|
|
return {
|
|
|
- /** ********************************************************************/
|
|
|
+ // 屏幕宽度, 为了控制分页条的大小
|
|
|
+ screenWidth: document.body.clientWidth,
|
|
|
+ currentPage: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ totalSize: 0,
|
|
|
+ dataList: [],
|
|
|
+ // ********************************************************************/
|
|
|
wrapStyle: '',
|
|
|
videoComments: [
|
|
|
{
|
|
|
@@ -255,9 +269,11 @@ export default {
|
|
|
liked: 'liked',
|
|
|
reply: 'reply',
|
|
|
createAt: 'createAt',
|
|
|
+ total: 'total',
|
|
|
user: 'user'
|
|
|
},
|
|
|
- /** ********************************************************************/
|
|
|
+ // ********************************************************************/
|
|
|
+ videoId: null,
|
|
|
video: null,
|
|
|
user: null,
|
|
|
similarVideos: [],
|
|
|
@@ -288,17 +304,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- const videoId = this.$route.params.id
|
|
|
- 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
|
|
|
- }
|
|
|
- })
|
|
|
+ this.videoId = this.$route.params.id
|
|
|
+ this.accessCodeForm.contentId = this.videoId
|
|
|
+ this.getVideoInfo(this.videoId)
|
|
|
+ this.getSimilarVideos(this.videoId)
|
|
|
+ this.getCommentWrapper(this.currentPage)
|
|
|
},
|
|
|
mounted() {
|
|
|
const header = this.$refs.header
|
|
|
@@ -307,6 +317,37 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // ****************************************************************************************************************
|
|
|
+ handleCurrentChange(currentPage) {
|
|
|
+ this.currentPage = currentPage
|
|
|
+ this.getCommentWrapper(currentPage)
|
|
|
+ // 回到顶部
|
|
|
+ scrollTo(0, 0)
|
|
|
+ },
|
|
|
+ getCommentWrapper(pageNumber) {
|
|
|
+ getComment(this.videoId, pageNumber).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const respData = resp.data
|
|
|
+ this.dataList = respData.list
|
|
|
+ this.totalSize = respData.totalSize
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: resp.msg,
|
|
|
+ type: 'error',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: error.message,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // ****************************************************************************************************************
|
|
|
// 获取视频的详细信息
|
|
|
getVideoInfo(videoId) {
|
|
|
videoInfo(videoId).then(resp => {
|
|
|
@@ -506,10 +547,13 @@ export default {
|
|
|
})
|
|
|
add(Object.assign(res.newComment, { _id: new Date().getTime() }))
|
|
|
if (res.parent !== null) {
|
|
|
- console.log('parent: ', res.parent)
|
|
|
+ // console.log('parent: ', res.parent)
|
|
|
+ } else {
|
|
|
+ this.totalSize += 1
|
|
|
}
|
|
|
- console.log('addComment: ', res)
|
|
|
- publishComment().then(resp => {
|
|
|
+
|
|
|
+ // console.log('addComment: ', res)
|
|
|
+ /* publishComment(res).then(resp => {
|
|
|
if (resp.code === 0) {
|
|
|
this.$notify.success({
|
|
|
message: '评论已发布',
|
|
|
@@ -521,7 +565,7 @@ export default {
|
|
|
duration: 3000
|
|
|
})
|
|
|
}
|
|
|
- })
|
|
|
+ })*/
|
|
|
},
|
|
|
async like(comment) {
|
|
|
const res = await new Promise((resolve) => {
|