From 66784c40cc1ff21b00bb516bbba3cc62a46f6147 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 1 Nov 2022 07:46:34 +0800 Subject: [PATCH] Update _article_id.vue --- pages/article/_article_id.vue | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pages/article/_article_id.vue b/pages/article/_article_id.vue index eacbc05..1a99618 100644 --- a/pages/article/_article_id.vue +++ b/pages/article/_article_id.vue @@ -335,14 +335,18 @@ export default { _ts.gotoLogin(); } }, - setPreference() { + setPreference() { let _ts = this; _ts.$axios.$patch("/api/admin/article/update-perfect", { idArticle: _ts.article.idArticle, articlePerfect: '1', }).then(function (res) { - _ts.isPerfect = !_ts.isPerfect; - _ts.$message.success("设置成功!"); + if (res) { + _ts.$set(_ts, 'isPerfect', true); + _ts.$message.success("设置成功!"); + } else { + _ts.$message.error("设置失败!"); + } }) }, cancelPreference() { @@ -351,8 +355,12 @@ export default { idArticle: _ts.article.idArticle, articlePerfect: '0', }).then(function (res) { - _ts.isPerfect = !_ts.isPerfect; - _ts.$message.success("设置成功!"); + if (res) { + _ts.$set(_ts, 'isPerfect', false); + _ts.$message.success("取消成功!"); + } else { + _ts.$message.error("设置失败!"); + } }) }, thumbsUp() {