From ba5acc3cdefd33a4845b578015e2aae8b43f80d3 Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期三, 04 六月 2025 11:40:29 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- pages/tabbar/index/home.vue | 92 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 75 insertions(+), 17 deletions(-) diff --git a/pages/tabbar/index/home.vue b/pages/tabbar/index/home.vue index 2a9bde6..e65155f 100644 --- a/pages/tabbar/index/home.vue +++ b/pages/tabbar/index/home.vue @@ -66,14 +66,14 @@ </view> <view style="width: 100%;word-wrap: break-word;white-space: normal;overflow-wrap: break-word;"> <text class="video-title">{{item.title}}</text> - <text class="video-tag" v-for="(tag, index) in item.tagList" :key="tag">#{{tag.tagName}}</text> + <text class="video-tag" v-for="(tag, index) in item.tagList" :key="tag.id">#{{tag.tagName}}</text> </view> </view> <!-- 鍙充晶浜掑姩鎸夐挳 --> <view class="action-buttons"> <view class="avatar-container"> - <image class="avatar" :src="item.authorAvatar" mode="aspectFill"></image> + <image class="avatar" @click="jumpToHomePage(item.authorId)" :src="item.authorAvatar" mode="aspectFill"></image> <!-- 鍏虫敞鍥炬爣 - 浣跨敤缁濆瀹氫綅 --> <view v-if="!item.subscribeThisAuthor" class="follow-icon" @click="subscribeAuth(index, item.authorId)"> <text class="iconfont"></text> @@ -123,13 +123,14 @@ <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> @@ -140,7 +141,8 @@ <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> @@ -176,11 +178,12 @@ </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() { return { + videoNoMore: false, // 鏄惁杩樻湁鏇村瑙嗛 commentNoMore: false, // 鏄惁杩樻湁鏇村璇勮 commentQuery: { pageNumber: 1, @@ -202,7 +205,7 @@ replyUserId: '', replyUserNickname: '', replyUserAvatar: '', - masterCommentId: '' + masterCommentId: null }, comments: [], // 璇勮鍒楄〃 commentsTotal: 0, // 璇勮鎬绘潯鏁� @@ -226,8 +229,11 @@ ], // 瑙嗛鍒楄〃鏁版嵁 videoContexts: [], // 瑙嗛涓婁笅鏂囧璞¢泦鍚� loading: false, // 鏄惁姝e湪鍔犺浇 - page: 1, // 褰撳墠椤电爜 - pageSize: 10 // 姣忛〉鏁伴噺 + videoQuery: { + pageNumber: 1, + pageSize: 6, + videoFrom: 'recommend' + } } }, onShow() { @@ -249,6 +255,44 @@ this.initVideoContexts(); }, methods: { + // 璺宠浆涓汉涓婚〉 + jumpToHomePage(authorId) { + uni.navigateTo({ + url: "/pages/video/home-page?authorId=" + authorId + }) + }, + // 鍙栨秷鐐硅禐 + 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++; @@ -285,7 +329,7 @@ replyUserId: '', replyUserNickname: '', replyUserAvatar: '', - masterCommentId: '' + masterCommentId: null } }, // 鍙栨秷鍥炲 @@ -453,22 +497,31 @@ // 鍔犺浇瑙嗛鏁版嵁 async loadVideos() { - if (this.loading) return; + if (this.loading || this.videoNoMore) return; this.loading = true; - getRecommendVideos({pageNumber: this.page, pageSize: this.pageSize}).then(res => { + getRecommendVideos(this.videoQuery).then(res => { console.log(res, "瑙嗛鏁版嵁"); - if (this.page === 1) { + if (this.videoQuery.pageNumber === 1) { this.videoList = res.data.data; } else { - this.videoList = [...this.videoList, ...res.data.data]; + this.videoList = [ + ...this.videoList, + ...res.data.data.filter( + (newItem) => !this.videoList.some((oldItem) => oldItem.id === newItem.id) + ), + ]; } - - this.page++; this.$nextTick(() => { this.initVideoContexts(); }); this.loading = false; + if(res.data.data.length < this.videoQuery.pageSize) { + this.videoNoMore = true; + return; + } + this.videoQuery.pageNumber++; + }) }, @@ -522,6 +575,7 @@ }, // 鍗曞嚮灞忓箷锛氭殏鍋滄垨缁х画鎾斁 togglePlay(index) { + console.log("鍗曞嚮瑙嗛", index, this.videoContexts); if(this.currentVideoIsPlaying) { this.videoContexts[index].pause(); } else { @@ -946,8 +1000,9 @@ } .thumbs-up { position: absolute; - right: 80rpx; + right: 20rpx; font-size: 32rpx; + width: 120rpx; } .textSideIcon { font-size: 36rpx; @@ -957,4 +1012,7 @@ margin-right: 10rpx; color: #cccccc; } + .thumbs-num { + margin-left: 4rpx; + } </style> \ No newline at end of file -- Gitblit v1.8.0