diff --git a/FrontEnd/components/exhibition/ExhibitionListCard.vue b/FrontEnd/components/exhibition/ExhibitionListCard.vue index e8f49d2..89d6035 100644 --- a/FrontEnd/components/exhibition/ExhibitionListCard.vue +++ b/FrontEnd/components/exhibition/ExhibitionListCard.vue @@ -108,8 +108,8 @@ -
-
+
+
@@ -139,40 +139,40 @@ export default { }, data: () => ({ StatusMap: ExhibitCardStatus, + Favorite: { + Type: "", + ParentID: "", + IsFavorite: "", + Memo: "" + } }), methods: { formatDate, dateCountDown, needLeftTagStatus, - onToggleFavorite(id) { + onToggleFavorite(item) { + + if (item.IsFavorite === 'Y') { + item.IsFavorite = 'N'; + } else { + item.IsFavorite = 'Y'; + } + + this.Favorite.IsFavorite = item.IsFavorite; + this.Favorite.Type = 'Exhibition'; + this.Favorite.ParentID = item.ExhibitionID; + if (this.$auth.loggedIn) { - // this.$axios - // .put( - // `/member/exhibitions?jwt=${ - // this.$auth.$storage.getUniversal("jwt") - // ? this.$auth.$storage.getUniversal("jwt").token - // : "" - // }&exhibition_id=${this.item.id}&delete=${ - // this.item.saved ? this.item.saved : false - // }` - // ) - // .then((result) => { - // if (result.data.message == "successfully unsaved exhibition") { - // this.item.saved = false; - // } else if (result.data.message == "successfully saved exhibition") { - // this.item.saved = true; - // } - // this.$emit("toggle-favorite", { - // id: this.item.id, - // saved: this.item.saved, - // }); - // }) - // .catch((err) => { - // console.log(err); - // }); - // this.$nextTick(() => { - // this.$forceUpdate(); - // }); + this.$axios + .post( + `/trending/api/Favorite/Favorite`, this.Favorite + ) + .then((result) => { + + }) + .catch((err) => { + console.log(err); + }); } else { this.$router.push(this.localePath("/user")); } diff --git a/FrontEnd/pages/exhibition/index.vue b/FrontEnd/pages/exhibition/index.vue index 50f7b9b..e759df7 100644 --- a/FrontEnd/pages/exhibition/index.vue +++ b/FrontEnd/pages/exhibition/index.vue @@ -37,7 +37,7 @@ -->
+ >
@@ -236,6 +236,8 @@ export default { selectedMainCategoryJson: "", selectedSubCategoryJson: "", + favoriteSet: new Set(), + categories: [], unsortRegionList: [], unsortCountryList: [], @@ -259,6 +261,7 @@ export default { this.getStatusList(); this.getLocationList(); this.getCategoryList(); + this.getFavorite(); this.getExhibitionCard(); // await this.getUnsortLocationList(); // await this.getUnsortCategoryList(); @@ -272,21 +275,21 @@ export default { // } let userSavedList = []; if (this.$auth.loggedIn) { - await this.$axios - .get( - `/member/users/${this.$auth.$storage.getUniversal("jwt").user_id - }?jwt=${this.$auth.$storage.getUniversal("jwt").token}` - ) - .then((res) => { - userSavedList = res.data.UserExhibition; - }) - .catch((err) => { - console.log(err); - }); - this.$store.dispatch("updatePicture"); - this.$nextTick(() => { - this.$forceUpdate(); - }); + // await this.$axios + // .get( + // `/member/users/${this.$auth.$storage.getUniversal("jwt").user_id + // }?jwt=${this.$auth.$storage.getUniversal("jwt").token}` + // ) + // .then((res) => { + // userSavedList = res.data.UserExhibition; + // }) + // .catch((err) => { + // console.log(err); + // }); + // this.$store.dispatch("updatePicture"); + // this.$nextTick(() => { + // this.$forceUpdate(); + // }); } userSavedList = userSavedList.map((item) => item.exhibition_id); for (let i = 0; i < this.exhibitionList.length; i++) { @@ -306,21 +309,21 @@ export default { async mounted() { let userSavedList = []; if (this.$auth.loggedIn) { - await this.$axios - .get( - `/member/users/${this.$auth.$storage.getUniversal("jwt").user_id - }?jwt=${this.$auth.$storage.getUniversal("jwt").token}` - ) - .then((res) => { - userSavedList = res.data.UserExhibition; - }) - .catch((err) => { - console.log(err); - }); - this.$store.dispatch("updatePicture"); - this.$nextTick(() => { - this.$forceUpdate(); - }); + // await this.$axios + // .get( + // `/member/users/${this.$auth.$storage.getUniversal("jwt").user_id + // }?jwt=${this.$auth.$storage.getUniversal("jwt").token}` + // ) + // .then((res) => { + // userSavedList = res.data.UserExhibition; + // }) + // .catch((err) => { + // console.log(err); + // }); + // this.$store.dispatch("updatePicture"); + // this.$nextTick(() => { + // this.$forceUpdate(); + // }); } userSavedList = userSavedList.map((item) => item.exhibition_id); for (let i = 0; i < this.exhibitionList.length; i++) { @@ -367,17 +370,17 @@ export default { async fetchUser() { let userSavedList = []; if (this.$auth.loggedIn) { - await this.$axios - .get( - `/member/users/${this.$auth.$storage.getUniversal("jwt").user_id - }?jwt=${this.$auth.$storage.getUniversal("jwt").token}` - ) - .then((res) => { - userSavedList = res.data.UserExhibition; - }) - .catch((err) => { - console.log(err); - }); + // await this.$axios + // .get( + // `/member/users/${this.$auth.$storage.getUniversal("jwt").user_id + // }?jwt=${this.$auth.$storage.getUniversal("jwt").token}` + // ) + // .then((res) => { + // userSavedList = res.data.UserExhibition; + // }) + // .catch((err) => { + // console.log(err); + // }); } userSavedList = userSavedList.map((item) => item.exhibition_id); for (let i = 0; i < this.exhibitionList.length; i++) { @@ -388,13 +391,6 @@ export default { } } }, - async onToggleFavorite(obj) { - this.exhibitionList.findIndex((i) => { - if (i.id == obj.id) { - i.saved = obj.saved; - } - }); - }, getAdList() { this.ads = [{ @@ -537,6 +533,7 @@ export default { if (result.data.DATA.rel) { this.exhibitionList = result.data.DATA.rel; + this.setFavorite(); } }) @@ -544,6 +541,55 @@ export default { console.log(err); this.exhibitionList = []; }); + }, + getFavorite() { + + this.favoriteSet.clear(); + + if (this.$auth.loggedIn) { + this.$axios + .get( + `/trending/api/Favorite/Favorites?Type=Exhibition` + ) + .then((result) => { + + if (result.data.DATA.rel) { + + let favoriteList = []; + favoriteList = result.data.DATA.rel; + + favoriteList.forEach(item => { + + this.favoriteSet.add(item.ParentID); + + }) + } + + }) + .catch((err) => { + console.log(err); + }); + + } + + }, + setFavorite() { + + if(this.exhibitionList.length > 0 && this.$auth.loggedIn) { + + for(let i =0; i < this.exhibitionList.length; i++) { + + if (this.favoriteSet.has(this.exhibitionList[i].ExhibitionID)) { + + this.exhibitionList[i].IsFavorite = "Y"; + + } + + } + + } + + }, updateSortBy(data) { @@ -580,30 +626,6 @@ export default { this.getExhibitionCard(); }, - filterByCategory(data, categories) { - if (categories.length > 0) { - return data.filter((item) => { - let findItem = false; - if (item.subcategories) { - for (const cate of item.subcategories) { - if (categories.includes(cate.name)) { - findItem = true; - } - } - } - if (item.categories) { - for (const cate of item.categories) { - if (categories.includes(cate.name)) { - findItem = true; - } - } - } - return findItem; - }); - } else { - return data; - } - }, updateLocationFilter(value) { var SelectedRegionArray = []; @@ -637,18 +659,6 @@ export default { this.getExhibitionCard(); }, - filterByLocation(data, locations) { - if (locations.length > 0) { - return data.filter( - (item) => - locations.includes(item.region ? item.region.name : null) || - locations.includes(item.city ? item.city.name : null) || - locations.includes(item.country ? item.country.name : null) - ); - } else { - return data; - } - }, updateStatusFilter(value) { var SelectedStatusArray = []; @@ -666,18 +676,8 @@ export default { this.getExhibitionCard(); }, - filterByStatus(data, status) { - if (status.length > 0) { - return data.filter((item) => status.includes(Number(item.status.id))); - } else { - return data; - } - }, updateDateFilter(value) { this.datesChecked = value; - - console.log("date: " + JSON.stringify(this.datesChecked)); - this.getExhibitionCard(); }, sortServiceList(data) {