| | |
| | | <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> |
| | |
| | | </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() { |
| | |
| | | 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) => { |