From 23e64f8b3161cf03073b261225efff0cccda42d1 Mon Sep 17 00:00:00 2001 From: berlin-tzen Date: Tue, 14 Feb 2023 17:13:16 +0800 Subject: [PATCH] =?UTF-8?q?[WHAT]=20=E5=B1=95=E8=A6=BDID=E9=A0=81=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E9=96=8B=E7=99=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/exhibition/ExhibitionIntro.vue | 2 +- FrontEnd/pages/exhibition/_id.vue | 105 ++++++++++++++---- 2 files changed, 84 insertions(+), 23 deletions(-) diff --git a/FrontEnd/components/exhibition/ExhibitionIntro.vue b/FrontEnd/components/exhibition/ExhibitionIntro.vue index 9548ff7..b33ef9b 100644 --- a/FrontEnd/components/exhibition/ExhibitionIntro.vue +++ b/FrontEnd/components/exhibition/ExhibitionIntro.vue @@ -61,7 +61,7 @@ v-if="exhibition.area" class="my-1 frequencyArea neutrals--text text--darken-5" > - {{ $t("Event Space :") }} {{ exhibition.area }} + {{ $t("Event Space :") }} {{ exhibition.area.toFixed(2) }} diff --git a/FrontEnd/pages/exhibition/_id.vue b/FrontEnd/pages/exhibition/_id.vue index 9c06236..e13e492 100644 --- a/FrontEnd/pages/exhibition/_id.vue +++ b/FrontEnd/pages/exhibition/_id.vue @@ -35,6 +35,7 @@ {{ $t("Follow Event") }} + @@ -102,7 +103,7 @@ -
+
@@ -204,6 +205,8 @@ export default { exhibitionID: "", tab: "0", saved: false, + Favorite: {}, + favoriteSet: new Set(), exhibition: { id: null, name: "", @@ -257,6 +260,7 @@ export default { async created() { this.getExhibitionCard(); this.getAdList(); + this.getFavorite(); // await this.getExhibition(); // await this.getServiceCategory(); // await this.getCategorySwiperList(); @@ -264,20 +268,7 @@ export default { // await this.checkRelatedService(); }, async beforeCreate() { - if (this.$auth.loggedIn) { - // await this.$axios - // .get( - // `/member/exhibitions/user?jwt=${this.$auth.$storage.getUniversal("jwt").token - // }&exhibition_id=${this.$route.params.id}` - // ) - // .then((result) => { - // this.saved = result.data.saved; - // }) - // .catch((err) => { - // console.log(err); - // }); - // await this.$store.dispatch("updatePicture"); - } + }, mounted() { let vm = this; @@ -435,6 +426,7 @@ export default { this.exhibition.subcategories = exhib.SubCategories; this.setSideBarList(); + this.setFavorite(); } @@ -489,17 +481,67 @@ export default { navfix(entries, observer, isIntersecting) { this.navControl.nav = isIntersecting; }, + getFavorite() { + + this.favoriteSet.clear(); + + if (this.$auth.loggedIn) { + this.$axios.get(`/trending/api/Favorite/Favorites?Type=Exhibition`) + .then((result) => { + + if(result && result.data && result.data.DATA && result.data.DATA.rel){ + + let favoriteList = []; + favoriteList = result.data.DATA.rel; + + favoriteList.forEach(item => { + + this.favoriteSet.add(item.ParentID); + + }) + + } + + }) + .catch((err) => { + console.log("getFavorite"+err); + }); + + } + + }, + setFavorite() { + + if (this.favoriteSet.size > 0 && this.$auth.loggedIn) { + + if (this.favoriteSet.has(this.exhibition.id)) { + + this.saved = true; + + } + + } + + }, toggleFavorite() { + if (this.saved) { + this.saved = false; + this.Favorite.IsFavorite = 'N'; + } else { + this.saved = true; + this.Favorite.IsFavorite = 'Y'; + } + + this.Favorite.Type = 'Exhibition'; + this.Favorite.ParentID = this.exhibition.id; + if (this.$auth.loggedIn) { this.$axios - .put( - `/member/exhibitions?jwt=${this.$auth.$storage.getUniversal("jwt") - ? this.$auth.$storage.getUniversal("jwt").token - : "" - }&exhibition_id=${this.$route.params.id}&delete=${this.saved}` + .post( + `/trending/api/Favorite/Favorite`, this.Favorite ) .then((result) => { - this.saved = !this.saved; + }) .catch((err) => { console.log(err); @@ -508,6 +550,25 @@ export default { this.$router.push(this.localePath("/user")); } }, + // toggleFavorite() { + // if (this.$auth.loggedIn) { + // this.$axios + // .put( + // `/member/exhibitions?jwt=${this.$auth.$storage.getUniversal("jwt") + // ? this.$auth.$storage.getUniversal("jwt").token + // : "" + // }&exhibition_id=${this.$route.params.id}&delete=${this.saved}` + // ) + // .then((result) => { + // this.saved = !this.saved; + // }) + // .catch((err) => { + // console.log(err); + // }); + // } else { + // this.$router.push(this.localePath("/user")); + // } + // }, async getExhibition() { if (this.$route.query.preview) { await this.$axios