From 510b10e15c9af0c890aa400051a43ec41a50c3ae Mon Sep 17 00:00:00 2001 From: XiaoMo Date: Mon, 3 Apr 2023 16:40:10 +0800 Subject: [PATCH] =?UTF-8?q?a1300399510@qq.com=20=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BA=8E=202023/04/03=20-16:40:01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/index/allSections/AllSections.vue | 42 ++++++++++++++++----- src/views/index/recommend/Recommend.vue | 6 --- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/views/index/allSections/AllSections.vue b/src/views/index/allSections/AllSections.vue index 254281b..055a683 100755 --- a/src/views/index/allSections/AllSections.vue +++ b/src/views/index/allSections/AllSections.vue @@ -10,12 +10,12 @@
{{ i.name }}
-
-
- 空星 - 实星 +
+ 空星 + 实星
@@ -29,24 +29,46 @@ export default { data() { return { allActive: 0, - list: [{ + list: [{}], + postCollectionState: false, // 收藏的请求的状态 + - }], } }, methods: { allClick(index) { this.allActive = index }, + + // 点击收藏 starClick(k, fid) { - // if (this.starList[k].checked) this.starList[k].checked = false - // else this.starList[k].checked = true + if (this.postCollectionState) return + this.postCollectionState = true this.$http.post("/api/operation/forumFav", { fid }).then(res => { - console.log(res); + if (res.code != 200) return + this.list[this.allActive].data[k]['iscollection'] = 1 + this.$forceUpdate() + }).finally(() => { + this.postCollectionState = false + }) + }, + + // 点击取消收藏 + cancelCollection(k, fid) { + if (this.postCollectionState) return + this.postCollectionState = true + + this.$http.post("/api/operation/unforumFav", { + fid + }).then(res => { + if (res.code != 200) return + this.list[this.allActive].data[k]['iscollection'] = 0 + this.$forceUpdate() + }).finally(() => { + this.postCollectionState = false }) - this.$forceUpdate() }, // 获取全部板块 diff --git a/src/views/index/recommend/Recommend.vue b/src/views/index/recommend/Recommend.vue index 0edde0b..7b24493 100755 --- a/src/views/index/recommend/Recommend.vue +++ b/src/views/index/recommend/Recommend.vue @@ -7,12 +7,6 @@
- -