| | |
| | | <view style="position: relative;"> |
| | | <text class="time">{{formatTime(comment.createTime)}}</text> |
| | | <text @click="openReply(comment)" class="reply-btu time">回复</text> |
| | | <text class="thumbs-up time iconfont"></text> |
| | | <text v-if="!comment.hasThumbsUp" class="thumbs-up time iconfont" @click="thubmsUp(comment.id, index, null)"><text v-show="comment.thumbsUpNum > 0" class="thumbs-num">{{comment.thumbsUpNum}}</text></text> |
| | | <text v-else class="thumbs-up time iconfont" @click="cancelThumbsUp(comment.id, index, null)"><text v-show="comment.thumbsUpNum > 0" class="thumbs-num">{{comment.thumbsUpNum}}</text></text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <!-- 回复列表 --> |
| | | <view class="reply-list" v-if="comment.replies && comment.replies.length > 0"> |
| | | <view class="reply-item" v-for="reply in comment.replies" :key="reply.id"> |
| | | <view class="reply-item" v-for="(reply, replyIndex) in comment.replies" :key="reply.id"> |
| | | <view class="reply-content"> |
| | | <view style="display: flex;"> |
| | | <image class="comment-reply-avatar" :src="reply.replyUserAvatar || '/static/default-avatar.png'"></image> |
| | | <text class="nickname">{{reply.userNickname}}</text> |
| | | <text v-if="reply.replyUserId && reply.masterCommentId !== reply.replyId" class="reply-to"><text style="margin-right: 10rpx;font-size: 28rpx;" class="iconfont"></text>{{reply.replyUserNickname}}</text> |
| | | </view> |
| | |
| | | <view class="reply-footer"> |
| | | <text class="time">{{formatTime(reply.createTime)}}</text> |
| | | <text @click="openReply(comment, reply)" class="reply-btu time">回复</text> |
| | | <text class="thumbs-up time iconfont"> </text> |
| | | <text v-if="!reply.hasThumbsUp" class="thumbs-up time iconfont" @click="thubmsUp(reply.id, index, replyIndex)"><text v-show="reply.thumbsUpNum > 0" class="thumbs-num">{{reply.thumbsUpNum}}</text></text> |
| | | <text v-else class="thumbs-up time iconfont" @click="cancelThumbsUp(reply.id, index, replyIndex)"><text v-show="reply.thumbsUpNum > 0" class="thumbs-num">{{reply.thumbsUpNum}}</text></text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { getRecommendVideos, savePlayRecord, subscribe, getVideoComments, addVideoComment } from "@/api/video.js"; |
| | | import { getRecommendVideos, savePlayRecord, subscribe, getVideoComments, addVideoComment, thubmsUpComment, cancelThubmsUpComment } from "@/api/video.js"; |
| | | import { changeCollect } from "@/api/collect.js"; |
| | | export default { |
| | | data() { |
| | |
| | | replyId: '', |
| | | replyUserId: '', |
| | | replyUserNickname: '', |
| | | masterCommentId: '' |
| | | replyUserAvatar: '', |
| | | masterCommentId: null |
| | | }, |
| | | comments: [], // 评论列表 |
| | | commentsTotal: 0, // 评论总条数 |
| | |
| | | this.initVideoContexts(); |
| | | }, |
| | | methods: { |
| | | // 取消点赞 |
| | | async cancelThumbsUp(id, commentIndex, replyIndex) { |
| | | const data = { |
| | | refId: id, |
| | | thumbsUpType: 'video_comment' |
| | | } |
| | | cancelThubmsUpComment(data).then(res => { |
| | | if(replyIndex != null) { |
| | | this.comments[commentIndex].replies[replyIndex].hasThumbsUp = false; |
| | | this.comments[commentIndex].replies[replyIndex].thumbsUpNum -= 1; |
| | | } else { |
| | | this.comments[commentIndex].hasThumbsUp = false; |
| | | this.comments[commentIndex].thumbsUpNum -= 1; |
| | | } |
| | | }) |
| | | }, |
| | | // 评论点赞 |
| | | async thubmsUp(id, commentIndex, replyIndex) { |
| | | const data = { |
| | | refId: id, |
| | | thumbsUpType: 'video_comment' |
| | | } |
| | | thubmsUpComment(data).then(res => { |
| | | if(replyIndex != null) { |
| | | this.comments[commentIndex].replies[replyIndex].hasThumbsUp = true; |
| | | this.comments[commentIndex].replies[replyIndex].thumbsUpNum += 1; |
| | | } else { |
| | | this.comments[commentIndex].hasThumbsUp = true; |
| | | this.comments[commentIndex].thumbsUpNum += 1; |
| | | } |
| | | }) |
| | | }, |
| | | // 加载下一页回复 |
| | | loadNextPageReply(index) { |
| | | this.replyCommentQuery.pageNumber++; |
| | |
| | | const videoId = this.commentForm.videoId; |
| | | this.commentForm = { // 评论表单数据 |
| | | id: '', |
| | | videoId: videoId, |
| | | videoId: '', |
| | | commentContent: '', |
| | | replyId: '', |
| | | replyUserId: '', |
| | | replyUserNickname: '', |
| | | masterCommentId: '' |
| | | replyUserAvatar: '', |
| | | masterCommentId: null |
| | | } |
| | | }, |
| | | // 取消回复 |
| | |
| | | this.commentForm.replyId = comment.id; |
| | | this.commentForm.replyUserId = comment.userId; |
| | | this.commentForm.replyUserNickname = comment.userNickname; |
| | | this.commentForm.replyUserAvatar = comment.userAvatar; |
| | | // 自动聚焦输入框 |
| | | this.$nextTick(() => { |
| | | const input = this.$refs.commentInput; |
| | |
| | | border-radius: 50%; |
| | | margin-right: 10rpx; |
| | | } |
| | | .comment-reply-avatar { |
| | | width: 40rpx; |
| | | height: 40rpx; |
| | | border-radius: 50%; |
| | | margin-right: 10rpx; |
| | | } |
| | | |
| | | .comment-content { |
| | | flex: 1; |
| | |
| | | } |
| | | .thumbs-up { |
| | | position: absolute; |
| | | right: 80rpx; |
| | | right: 20rpx; |
| | | font-size: 32rpx; |
| | | width: 120rpx; |
| | | } |
| | | .textSideIcon { |
| | | font-size: 36rpx; |
| | |
| | | margin-right: 10rpx; |
| | | color: #cccccc; |
| | | } |
| | | .thumbs-num { |
| | | margin-left: 4rpx; |
| | | } |
| | | </style> |