From 3b238b10eabf4ccb01af3955492c16b68526c9bd Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 27 五月 2025 14:35:03 +0800
Subject: [PATCH] 关注作者功能

---
 pages/tabbar/index/home.vue |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/pages/tabbar/index/home.vue b/pages/tabbar/index/home.vue
index 8d25e61..6b2f4c5 100644
--- a/pages/tabbar/index/home.vue
+++ b/pages/tabbar/index/home.vue
@@ -75,7 +75,7 @@
 		   <view class="avatar-container">
 			   <image class="avatar" :src="item.authorAvatar" mode="aspectFill"></image>
 			   <!-- 鍏虫敞鍥炬爣 - 浣跨敤缁濆瀹氫綅 -->
-			   <view class="follow-icon">
+			   <view v-if="!item.subscribeThisAuthor" class="follow-icon" @click="subscribeAuth(index, item.authorId)">
 				 <text class="iconfont">&#xe629;</text>
 			   </view>
 		   </view>
@@ -96,7 +96,7 @@
 </template>
 
 <script>
-import { getRecommendVideos, savePlayRecord } from "@/api/video.js";
+import { getRecommendVideos, savePlayRecord, subscribe } from "@/api/video.js";
 import { changeCollect } from "@/api/collect.js";
 export default {
   data() {
@@ -142,6 +142,28 @@
     this.initVideoContexts();
   },
   methods: {
+	  // 鍏虫敞浣滆��
+	  subscribeAuth(index, authorId) {
+		this.videoList.forEach(video => {
+			if(video.authorId === authorId) {
+				video.subscribeThisAuthor = true
+			}
+		})
+		subscribe(authorId).then(res => {
+			if(res.data.code === 200) {
+				uni.showToast({
+				  title: '鍏虫敞鎴愬姛~',
+				  icon: 'none'
+				});
+			} else {
+				this.videoList.forEach(video => {
+					if(video.authorId === authorId) {
+						video.subscribeThisAuthor = false
+					}
+				})
+			}
+		})
+	  },
     // 鍒濆鍖栬棰戜笂涓嬫枃
     initVideoContexts() {
       this.videoContexts = this.videoList.map((_, index) => {

--
Gitblit v1.8.0