From a0442e80e6158f8c71a4003eb547f0fa2f6b89c9 Mon Sep 17 00:00:00 2001 From: x ronger Date: Sun, 27 Sep 2020 23:15:51 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=87=E7=AB=A0=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E5=A2=9E=E5=8A=A0=E5=85=B3=E6=B3=A8/?= =?UTF-8?q?=E5=8F=96=E5=85=B3=E4=BD=9C=E8=80=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/article/_article_id.vue | 54 ++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-) 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() {