diff --git a/components/common/user/list.vue b/components/common/user/list.vue new file mode 100644 index 0000000..4f3c952 --- /dev/null +++ b/components/common/user/list.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/pages/user/_nickname.vue b/pages/user/_nickname.vue index 53a8a58..08cd7e2 100644 --- a/pages/user/_nickname.vue +++ b/pages/user/_nickname.vue @@ -29,19 +29,27 @@ + style="padding-left: calc(50vw - 11rem);"> 文章 作品集 + 关注用户 + 粉丝 - + - + + + + + + + @@ -49,10 +57,11 @@ import {mapState} from 'vuex'; import ArticleList from "~/components/archive/list"; import PortfolioList from "~/components/common/portfolio/list"; +import UserList from "~/components/common/user/list"; export default { name: "User", - components: {ArticleList, PortfolioList}, + components: {ArticleList, PortfolioList, UserList}, validate({params, store}) { return params.nickname }, @@ -62,7 +71,9 @@ export default { .dispatch('user/fetchDetail', params) .catch(err => error({statusCode: 404})), store.dispatch('user/fetchArticleList', params), - store.dispatch('user/fetchPortfolioList', params) + store.dispatch('user/fetchPortfolioList', params), + store.dispatch('user/fetchFollowerList', params), + store.dispatch('user/fetchFollowingList', params) ]) }, computed: { @@ -70,6 +81,8 @@ export default { user: state => state.user.data, articles: state => state.user.articles, portfolios: state => state.user.portfolios, + followers: state => state.user.followers, + followings: state => state.user.followings, oauth: state => state.oauth }) }, @@ -86,6 +99,12 @@ export default { currentChangePortfolio(page) { this.$store.dispatch('user/fetchPortfolioList', {page: page, nickname: this.$route.params.nickname}) }, + currentChangeFollowing(page) { + this.$store.dispatch('user/fetchFollowingList', {page: page, nickname: this.$route.params.nickname}) + }, + currentChangeFollower(page) { + this.$store.dispatch('user/fetchFollowerList', {page: page, nickname: this.$route.params.nickname}) + }, handleToggleTab(key) { this.$set(this, 'activeTab', key); }, @@ -271,4 +290,8 @@ h3, .h3 { padding-right: 0.75rem; padding-left: 0.75rem; } + +.tab-content { + min-height: 50vh; +} diff --git a/store/user.js b/store/user.js index e322a6f..9a29f64 100644 --- a/store/user.js +++ b/store/user.js @@ -17,6 +17,14 @@ export const state = () => { portfolios: { portfolios: [], pagination: {} + }, + followers: { + users: [], + pagination: {} + }, + followings: { + users: [], + pagination: {} } } } @@ -33,6 +41,12 @@ export const mutations = { }, updatePortfolioList(state, action) { state.portfolios = action + }, + updateFollowerList(state, action) { + state.followers = action + }, + updateFollowingList(state, action) { + state.followings = action } } @@ -80,5 +94,45 @@ export const actions = { .catch(error => { commit('updateFetching', false) }) + }, + fetchFollowerList({commit}, params) { + commit('updateFetching', true); + commit('updateFollowerList', { + users: [], + pagination: {} + }) + return this.$axios + .$get(`${USER_API_PATH}/${params.nickname}/followers`, { + params: { + page: params.page + } + }) + .then(response => { + commit('updateFollowerList', response) + commit('updateFetching', false) + }) + .catch(error => { + commit('updateFetching', false) + }) + }, + fetchFollowingList({commit}, params) { + commit('updateFetching', true); + commit('updateFollowingList', { + users: [], + pagination: {} + }) + return this.$axios + .$get(`${USER_API_PATH}/${params.nickname}/followings`, { + params: { + page: params.page + } + }) + .then(response => { + commit('updateFollowingList', response) + commit('updateFetching', false) + }) + .catch(error => { + commit('updateFetching', false) + }) } }