diff --git a/pages/article/_article_id.vue b/pages/article/_article_id.vue index aa7c761..be10795 100644 --- a/pages/article/_article_id.vue +++ b/pages/article/_article_id.vue @@ -33,11 +33,19 @@ # {{ tag.tagTitle }} - + + 编辑文章 编辑标签 分享 + + 关注 + 分享 + @@ -173,6 +181,7 @@ loading: false, isShare: false, dialogVisible: false, + isFollow: false, shareData: {}, } }, @@ -196,12 +205,17 @@ if (_ts.isShare) { _ts.$set(_ts, 'isShare', false); } else { - _ts.$axios.$get('/api/article/' + _ts.article.idArticle + '/share').then(function (res) { - if (res) { - _ts.$set(_ts, 'shareData', res); - _ts.$set(_ts, 'isShare', true); - } - }); + if (_ts.user) { + _ts.$axios.$get('/api/article/' + _ts.article.idArticle + '/share').then(function (res) { + if (res) { + _ts.$set(_ts, 'shareData', res); + _ts.$set(_ts, 'isShare', true); + } + }); + } else { + _ts.$set(_ts, 'shareData', {shareUrl: _ts.article.articlePermalink}); + _ts.$set(_ts, 'isShare', true); + } } } }, @@ -213,6 +227,32 @@ closeTagsDialog() { this.$set(this, 'dialogVisible', false); this.$store.dispatch('article/fetchDetail', this.$route.params) + }, + followUser(idUser) { + let _ts = this; + if (_ts.user) { + _ts.$axios.$post('/api/follow', { + followingId: idUser, + followingType: 0 + }).then(function (res) { + _ts.$set(_ts, 'isFollow', res); + }) + } else { + _ts.gotoLogin() + } + }, + cancelFollowUser(idUser) { + let _ts = this; + if (_ts.user) { + _ts.$axios.$post('/api/follow/cancel-follow', { + followingId: idUser, + followingType: 0 + }).then(function (res) { + _ts.$set(_ts, 'isFollow', res); + }) + } else { + _ts.gotoLogin() + } } }, mounted() {