|
|
@@ -136,14 +136,14 @@ import StatusCard from '@/components/card/StatusCard'
|
|
|
import VideoCard from '@/components/card/VideoCard'
|
|
|
import AudioCard from '@/components/card/AudioCard'
|
|
|
import ImageAlbumCard from '@/components/card/ImageAlbumCard'
|
|
|
-import ArticleCard from 'components/card/ArticleCard'
|
|
|
+import ArticleCard from '@/components/card/ArticleCard'
|
|
|
|
|
|
import { getUserInfo, checkRelation, followUser, unfollowUser } from "@/api/user";
|
|
|
import { getUserContentData, userVideoCard } from "@/api/video";
|
|
|
import { getUserAlbums1 } from "@/api/image";
|
|
|
import { getUserAudios } from "@/api/audio";
|
|
|
import { userStatus } from "@/api/status";
|
|
|
-import { getArticles } from "@/api/article";
|
|
|
+import { getUserArticles } from "@/api/article";
|
|
|
|
|
|
export default {
|
|
|
name: 'Home',
|
|
|
@@ -169,9 +169,9 @@ export default {
|
|
|
},
|
|
|
created() {
|
|
|
this.userId = this.$route.params.id
|
|
|
- getUserInfo(this.userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.user = res.data
|
|
|
+ getUserInfo(this.userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.user = resp.data
|
|
|
const path = this.$route.path
|
|
|
if (path.endsWith("video")) {
|
|
|
this.activeName = 'video'
|
|
|
@@ -194,17 +194,17 @@ export default {
|
|
|
this.getData()
|
|
|
}
|
|
|
})
|
|
|
- checkRelation(this.userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- if (res.data) {
|
|
|
+ checkRelation(this.userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ if (resp.data) {
|
|
|
this.followButton.text = '已关注'
|
|
|
this.followButton.icon = 'el-icon-check'
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- getUserContentData(this.userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.userContentData = res.data
|
|
|
+ getUserContentData(this.userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.userContentData = resp.data
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
@@ -223,10 +223,25 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- initPagination() {
|
|
|
- this.pageSize = 12
|
|
|
- this.currentPage = 1
|
|
|
- this.totalSize = 0
|
|
|
+ followUser(userId) {
|
|
|
+ if (this.followButton.text === '关注') {
|
|
|
+ followUser(userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.followButton.text = '已关注'
|
|
|
+ this.followButton.icon = 'el-icon-check'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ unfollowUser(userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.followButton.text = '关注'
|
|
|
+ this.followButton.icon = 'el-icon-plus'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ sendMessage(userId) {
|
|
|
+ console.log('发送消息')
|
|
|
},
|
|
|
handleCurrentChange(pageNumber) {
|
|
|
this.currentPage = pageNumber
|
|
|
@@ -251,12 +266,12 @@ export default {
|
|
|
if (this.activeName === 'video') {
|
|
|
this.userVideoListWrapper(this.currentPage, this.userId)
|
|
|
} else if (this.activeName === 'image') {
|
|
|
- getUserAlbums1(this.userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- const resData = res.data
|
|
|
- if (resData.length !== 0) {
|
|
|
+ getUserAlbums1(this.userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const respData = resp.data
|
|
|
+ if (respData.length !== 0) {
|
|
|
this.showEmpty = false
|
|
|
- for (const item of resData) {
|
|
|
+ for (const item of respData) {
|
|
|
this.dataList.push(item)
|
|
|
}
|
|
|
} else {
|
|
|
@@ -265,12 +280,12 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
} else if (this.activeName === 'audio') {
|
|
|
- getUserAudios(this.userId, this.currentPage).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- const resData = res.data.list
|
|
|
- if (resData.length !== 0) {
|
|
|
+ getUserAudios(this.userId, this.currentPage).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const respData = resp.data.list
|
|
|
+ if (respData.length !== 0) {
|
|
|
this.showEmpty = false
|
|
|
- for (const item of resData) {
|
|
|
+ for (const item of respData) {
|
|
|
this.dataList.push(item)
|
|
|
}
|
|
|
} else {
|
|
|
@@ -279,12 +294,12 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
} else if (this.activeName === 'article') {
|
|
|
- getArticles(this.currentPage).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- const resData = res.data.list
|
|
|
- if (resData.length !== 0) {
|
|
|
+ getUserArticles(this.userId, this.currentPage).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const respData = resp.data.list
|
|
|
+ if (respData.length !== 0) {
|
|
|
this.showEmpty = false
|
|
|
- for (const item of resData) {
|
|
|
+ for (const item of respData) {
|
|
|
this.dataList.push(item)
|
|
|
}
|
|
|
} else {
|
|
|
@@ -296,32 +311,12 @@ export default {
|
|
|
this.userStatusListWrapper(this.currentPage, this.userId)
|
|
|
}
|
|
|
},
|
|
|
- followUser(userId) {
|
|
|
- if (this.followButton.text === '关注') {
|
|
|
- followUser(userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.followButton.text = '已关注'
|
|
|
- this.followButton.icon = 'el-icon-check'
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- unfollowUser(userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.followButton.text = '关注'
|
|
|
- this.followButton.icon = 'el-icon-plus'
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- sendMessage(userId) {
|
|
|
- console.log('发送消息')
|
|
|
- },
|
|
|
userVideoListWrapper(pageNumber, userId) {
|
|
|
- userVideoCard(pageNumber, userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- const resData = res.data
|
|
|
- this.dataList = resData.list
|
|
|
- this.totalSize = resData.totalSize
|
|
|
+ userVideoCard(pageNumber, userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const respData = resp.data
|
|
|
+ this.dataList = respData.list
|
|
|
+ this.totalSize = respData.totalSize
|
|
|
if (this.dataList.length !== 0) {
|
|
|
this.showEmpty = false
|
|
|
} else {
|
|
|
@@ -331,9 +326,9 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
userStatusListWrapper(pageNumber, userId) {
|
|
|
- userStatus(userId, pageNumber).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.dataList = res.data.list
|
|
|
+ userStatus(userId, pageNumber).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.dataList = resp.data.list
|
|
|
if (this.dataList.length === 0) {
|
|
|
this.showEmpty = true
|
|
|
} else {
|