From 3b238b10eabf4ccb01af3955492c16b68526c9bd Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 27 五月 2025 14:35:03 +0800
Subject: [PATCH] 关注作者功能
---
api/video.js | 13 +++++++++++++
pages/tabbar/index/home.vue | 26 ++++++++++++++++++++++++--
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/api/video.js b/api/video.js
index fd76f80..49e1772 100644
--- a/api/video.js
+++ b/api/video.js
@@ -47,3 +47,16 @@
data: data
});
}
+
+/**
+ * 鍏虫敞浣滆��
+ *
+ * @param params
+ */
+ export function subscribe(authorId) {
+ return http.request({
+ url: "/lmk/my-subscribe/subscribe/" + authorId,
+ method: Method.POST,
+ needToken: true
+ });
+}
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"></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