|
|
@@ -254,8 +254,9 @@
|
|
|
<span v-text="videoData.username" />
|
|
|
</router-link>
|
|
|
<span v-html="' '" />
|
|
|
- <v-btn small outlined color="primary" @click="followingUser">
|
|
|
- <span>关注</span>
|
|
|
+ <v-btn small outlined color="primary" @click="followUserWrapper">
|
|
|
+ <span v-if="isFollowed">已关注</span>
|
|
|
+ <span v-if="!isFollowed">关注</span>
|
|
|
<span v-html="' '" />
|
|
|
<span v-text="videoData.followerCount" />
|
|
|
</v-btn>
|
|
|
@@ -286,6 +287,34 @@
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
</v-container>
|
|
|
+ <v-dialog
|
|
|
+ v-model="showUnfollowDialog"
|
|
|
+ persistent
|
|
|
+ max-width="600px"
|
|
|
+ >
|
|
|
+ <v-card>
|
|
|
+ <v-card-title>
|
|
|
+ <span class="text-h5">已关注, 确定要取消关注?</span>
|
|
|
+ </v-card-title>
|
|
|
+ <v-card-actions>
|
|
|
+ <v-spacer />
|
|
|
+ <v-btn
|
|
|
+ color="blue darken-1"
|
|
|
+ text
|
|
|
+ @click="showUnfollowDialog = false"
|
|
|
+ >
|
|
|
+ 取消
|
|
|
+ </v-btn>
|
|
|
+ <v-btn
|
|
|
+ color="blue darken-1"
|
|
|
+ text
|
|
|
+ @click="unfollowUserWrapper"
|
|
|
+ >
|
|
|
+ 确定
|
|
|
+ </v-btn>
|
|
|
+ </v-card-actions>
|
|
|
+ </v-card>
|
|
|
+ </v-dialog>
|
|
|
<v-snackbar
|
|
|
v-model="showMessage"
|
|
|
:top="true"
|
|
|
@@ -309,6 +338,7 @@
|
|
|
<script>
|
|
|
import { similarVideo, videoInfo, getDisplayedVideoList } from '@/api/media/video'
|
|
|
import { collectVideo } from '@/api/media/collection'
|
|
|
+import { followUser, unfollowUser, checkRelation } from '@/api/user/user'
|
|
|
import ItemCard from '@/components/card/item-card.vue'
|
|
|
import CommentCard from '@/components/card/comment-card.vue'
|
|
|
import VideoPlayer from '@/components/player/player.vue'
|
|
|
@@ -346,6 +376,9 @@ export default {
|
|
|
vidProp: null,
|
|
|
benched: 0,
|
|
|
switch1: true,
|
|
|
+ isFollowed: false,
|
|
|
+ showUnfollowDialog: false,
|
|
|
+ userId: null,
|
|
|
showMessage: false,
|
|
|
message: ''
|
|
|
}
|
|
|
@@ -388,6 +421,8 @@ export default {
|
|
|
this.videoData = vidData
|
|
|
document.title = vidData.title
|
|
|
|
|
|
+ this.userId = res.data.userId
|
|
|
+ this.checkRelationWrapper(this.userId)
|
|
|
const vidProp = {}
|
|
|
vidProp.videoId = vidData.videoId
|
|
|
vidProp.coverUrl = vidData.coverUrl
|
|
|
@@ -428,8 +463,43 @@ export default {
|
|
|
console.error(error.message)
|
|
|
})
|
|
|
},
|
|
|
- followingUser() {
|
|
|
- console.log('关注 UP 主')
|
|
|
+ checkRelationWrapper(userId) {
|
|
|
+ checkRelation(userId).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.isFollowed = res.data
|
|
|
+ } else {
|
|
|
+ alert(res.data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ followUserWrapper() {
|
|
|
+ console.log(this.isFollowed)
|
|
|
+ if (this.isFollowed) {
|
|
|
+ this.showUnfollowDialog = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ followUser(this.userId).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.isFollowed = true
|
|
|
+ this.message = '已关注'
|
|
|
+ this.showMessage = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ unfollowUserWrapper() {
|
|
|
+ if (!this.isFollowed) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.showUnfollowDialog = false
|
|
|
+ unfollowUser(this.userId).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.isFollowed = false
|
|
|
+ this.message = '已取消关注'
|
|
|
+ this.showMessage = true
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
likeVideo() {
|
|
|
console.log('点赞 ' + this.videoId)
|