Browse Source

會員收藏展覽(還需優化)

Dev
parent
commit
bbb7830685
  1. 314
      FrontEnd/pages/user/saveExhibition.vue

314
FrontEnd/pages/user/saveExhibition.vue

@ -67,16 +67,31 @@
</nuxt-link>
</div>
<div v-else class="tw-mt-[20px] md:tw-mt-[30px]">
<div class="tw-mt-[20px] md:tw-mt-[30px]">
<ExhibitionListCard
<!-- <ExhibitionListCard
v-for="(exhibition, index) in countryFilterList"
:key="index"
class="tw-mb-[20px]"
:item="exhibition"
@toggle-favorite="removeExhibitionRelation($event)"
>
</ExhibitionListCard>
</ExhibitionListCard> -->
<div v-for="list in exhibitionCardList" :key="list">
<ExhibitionListCard :item="list"></ExhibitionListCard>
</div>
<!-- <ExhibitionListCard
v-for="(item, index) in exhibitionCardList"
:key="index"
class="tw-mb-[20px]"
:item="item"
>
@toggle-favorite="removeExhibitionRelation($event)"
</ExhibitionListCard> -->
<!-- <ExhibitionListCard v-for="item in exhibitionCardList" :key="item"></ExhibitionListCard> -->
<div class="tw-mt-[34px] tw-flex tw-justify-end">
<pagination :pageLength="pageLength" @update="updatePage"></pagination>
@ -155,81 +170,94 @@ export default {
test:"",
isRouterAlive: true,
currentPage: 1,
perPageItems: 6,
perPageItems: 600000,
exhibitionMap: new Map(),
exhibitionCardList: [],
userFavoriateList: [],
};
},
async created() {
this.fetchUserData();
await this.fetchSavedExhibition();
await this.fetchExhibition();
await this.userSavedExhib();
await this.filterSavedExhibition();
//await this.showUserExhibitionList();
this.$axios
.get(`/trending/api/location/countries?RegionID&Lang=${this.$i18n.localeProperties["langQuery"]}`)
.then((response) => {
//console.log(JSON.stringify(response));
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
if(data){
this.countryList = data;
//console.log(this.countryList);
this.countryOptions = this.countryList.map((item) => {
return {
id: item.CountryID,
name: item.CountryName,
};
});
const initial = {
name: this.$t("userProfile.allCountries"),
id: 999,
};
this.countryOptions.splice(0, 0, initial);
// await this.fetchExhibition();
// await this.fetchUserFavoriateExhibition();
}
}
})
.catch((error) => {
console.log(error);
});
await this.fetchFavoriate();
await this.fetchAllExhibition();
this.setUserExhibitionCard();
this.$axios
.get(`/trending/api/exhibition/statuses?Lang=${this.$i18n.localeProperties["langQuery"]}`)
.then((response) => {
//console.log(JSON.stringify(response));
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
if(data){
this.statusList = data;
this.statusOptions = this.statusList.map((item) => {
return {
id:"",
Key: item.Key,
Value: item.Value,
};
});
const initial = {
id: 999,
Key: 999,
Value: this.$t("userProfile.allStatus"),
};
this.statusOptions.splice(0, 0, initial);
}
}
})
.catch((error) => {
console.log(error);
});
this.countryFilterList = this.showUserExhibitionList;
// await this.userSavedExhib();
// await this.filterSavedExhibition();
// //await this.showUserExhibitionList();
// this.$axios
// .get(`/trending/api/location/countries?RegionID&Lang=${this.$i18n.localeProperties["langQuery"]}`)
// .then((response) => {
// //console.log(JSON.stringify(response));
// if(response && response.data && response.data.DATA && response.data.DATA.rel){
// let data = response.data.DATA.rel
// if(data){
// this.countryList = data;
// //console.log(this.countryList);
// this.countryOptions = this.countryList.map((item) => {
// return {
// id: item.CountryID,
// name: item.CountryName,
// };
// });
// const initial = {
// name: this.$t("userProfile.allCountries"),
// id: 999,
// };
// this.countryOptions.splice(0, 0, initial);
// }
// }
// })
// .catch((error) => {
// console.log(error);
// });
// this.$axios
// .get(`/trending/api/exhibition/statuses?Lang=${this.$i18n.localeProperties["langQuery"]}`)
// .then((response) => {
// //console.log(JSON.stringify(response));
// if(response && response.data && response.data.DATA && response.data.DATA.rel){
// let data = response.data.DATA.rel
// if(data){
// this.statusList = data;
// this.statusOptions = this.statusList.map((item) => {
// return {
// id:"",
// Key: item.Key,
// Value: item.Value,
// };
// });
// const initial = {
// id: 999,
// Key: 999,
// Value: this.$t("userProfile.allStatus"),
// };
// this.statusOptions.splice(0, 0, initial);
// }
// }
// })
// .catch((error) => {
// console.log(error);
// });
// this.countryFilterList = this.showUserExhibitionList;
},
mounted() {
this.yearOptions = Array.from(new Array(103), (val, index) =>
@ -281,6 +309,77 @@ export default {
},
},
methods: {
async fetchFavoriate() {
await this.$axios
.get(
`/trending/api/Favorite/Favorites?Type=Exhibition`
)
.then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
if(data){
this.userFavoriateList = data;
}
}
})
.catch((error) => {
console.log(error);
});
},
async fetchAllExhibition() {
await this.$axios
.get(
`/trending/api/Exhibition/Cards?PageIndex=${this.currentPage}&PageSize=${this.perPageItems}&RegionIDs&CountryIDs&CityIDs&MainCategoryIDs&SubCategoryIDs&Status&Date&Sort&Query&Lang=${this.$i18n.localeProperties["langQuery"]}`
)
.then((response) => {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
if(data){
console.table(data);
data.DataList.forEach(exhib => {
this.exhibitionMap.set(exhib.ExhibitionID, exhib);
});
// this.setUserExhibitionCard();
};
};
})
.catch((error) => {
console.log(error);
});
},
setUserExhibitionCard() {
this.userFavoriateList.forEach( fav => {
if(this.exhibitionMap.has(fav.ParentID)) {
this.exhibitionCardList.push(this.exhibitionMap.get(fav.ParentID));
}
});
console.log("mdfkkkkkkkuuuu");
console.table(this.exhibitionCardList);
},
updatePage(value) {
this.currentPage = value;
this.fetchExhibition();
@ -409,7 +508,7 @@ export default {
this.$auth.logout();
},
async fetchSavedExhibition() {
async fetchUserFavoriateExhibition() {
this.$axios
.get(
`/trending/api/Favorite/Favorites?Type=Exhibition`
@ -431,6 +530,8 @@ export default {
this.userSaveExhibition.length / this.savedExhibitionPerPage
);
console.table(this.userSaveExhibition);
//this.userVisibleSavedExhibitionList = JSON.parse(JSON.stringify(this.userSaveExhibition));
}
}
@ -441,7 +542,7 @@ export default {
},
async fetchExhibition() {
this.$axios
await this.$axios
.get(
`/trending/api/Exhibition/Cards?PageIndex=${this.currentPage}&PageSize=${this.perPageItems}&RegionIDs&CountryIDs&CityIDs&MainCategoryIDs&SubCategoryIDs&Status&Date&Sort&Query&Lang=${this.$i18n.localeProperties["langQuery"]}`
)
@ -449,11 +550,25 @@ export default {
if(response && response.data && response.data.DATA && response.data.DATA.rel){
let data = response.data.DATA.rel
if(data){
this.exhibitionList = data;
this.showUserExhibitionList = [];
this.countryFilterList = [];
this.exhibitionList = data.DataList;
this.exhibitionList.forEach(exhibition => {
this.exhibitionMap.set(exhibition.ExhibitionID, exhibition);
});
console.log("All exhibitions " + this.exhibitionMap.size);
console.table(this.exhibitionMap);
// this.exhibitionList = data.DataList;
// this.showUserExhibitionList = [];
// this.countryFilterList = [];
this.userSavedExhib();
// this.userSavedExhib();
@ -463,10 +578,24 @@ export default {
// this.exhibitionMap.set(exhib.ExhibitionID, exhib);
// })
// this.userSaveExhibition.forEach((exhib) => {
console.log("holy shit size");
console.log(this.userSaveExhibition);
this.userSaveExhibition.forEach((exhib) => {
if (this.exhibitionMap.has(exhib.ExhibitionID)) {
this.testArr.push(this.exhibitionMap.get(exhib.ExhibitionID));
}
})
console.log("mdfk");
console.table(this.testArr);
// this.showUserExhibitionList.push(this.exhibitionMap.get(exhib.ExhibitionID));
// })
};
};
})
@ -475,19 +604,22 @@ export default {
});
},
async userSavedExhib(){
this.exhibitionList.forEach((exhib) => {
this.userSaveExhibition.forEach((user) => {
if(exhib.ExhibitionID == user.ParentID){
exhib.IsFavorite = 'Y';
this.showUserExhibitionList.push(exhib);
}
})
});
this.countryFilterList = JSON.parse(
JSON.stringify(this.showUserExhibitionList));
// userSavedExhib(){
// this.exhibitionList.forEach(exhib => {
// // console.log(exhib.ExhibitionID);
// this.userSaveExhibition.forEach(user => {
// // console.log(user.ParentID);
// // if(exhib.ExhibitionID === user.ParentID){
// console.log(exhib.ExhibitionID);
// // exhib.IsFavorite = 'Y';
// // this.showUserExhibitionList.push(exhib);
// // }
// })
// });
// // this.countryFilterList = JSON.parse(
// // JSON.stringify(this.showUserExhibitionList));
},
// },
filterSavedExhibition(countryId, selectId) {
this.countryFilterList = [];

Loading…
Cancel
Save