You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

691 lines
20 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="saveExhibition xl:tw-max-w-[1246px] xl:tw-mx-auto">
  3. <router-view v-if="isRouterAlive" />
  4. <div class="xl:tw-flex xl:tw-justify-between xl:tw-items-start">
  5. <userSidebar
  6. :userData="userData"
  7. :firstName="firstName"
  8. :lastName="lastName"
  9. class="tw-hidden xl:tw-block"
  10. >
  11. </userSidebar>
  12. <!-- <div class="xl:tw-hidden"></div> -->
  13. <div
  14. class="tw-bg-white xl:tw-p-[30px] xl:tw-rounded-[20px] xl:tw-min-w-[900px] xl:tw-max-w-[900px]"
  15. >
  16. <div
  17. class="tw-text-[20px] tw-font-bold tw-text-base-primary tw-mb-[20px] md:t24 md:tw-mb-[30px]"
  18. >
  19. <two-dots class="tw-mr-[30px]"></two-dots
  20. >{{ $t("userProfile.savedExhibitions") }}
  21. </div>
  22. <div class="tw-text-[14px] tw-text-base-primary tw-mb-[10px]">
  23. {{ $t("userProfile.savedExhibitionsFilter") }}
  24. </div>
  25. <div>
  26. <select
  27. v-model="countrySelect"
  28. class="tw-text-neutrals-500 tw-w-[196px] tw-border tw-border-solid tw-border-neutrals-200 tw-rounded-[10px] tw-px-[15px] tw-py-[9px] tw-head-body tw-outline-none tw-mr-[20px] focus:tw-border-primary-1 md:tw-text-[16px]"
  29. >
  30. <option
  31. v-for="(item, index) in countryOptions"
  32. :key="index"
  33. :value="item.id"
  34. >
  35. {{ item.name }}
  36. </option>
  37. </select>
  38. <select
  39. v-model="statusSelect"
  40. class="tw-text-neutrals-500 tw-w-[196px] tw-border tw-border-solid tw-border-neutrals-200 tw-rounded-[10px] tw-px-[15px] tw-py-[9px] tw-head-body tw-outline-none focus:tw-border-primary-1 md:tw-text-[16px]"
  41. >
  42. <option v-for="(item, index) in statusOptions" :key="index" :value="item.Key">
  43. {{ item.Value }}
  44. </option>
  45. </select>
  46. </div>
  47. <div
  48. v-if="showUserExhibitionList.length == 0"
  49. class="tw-mt-[80px] md:tw-mt-[90px]"
  50. >
  51. <img
  52. class="tw-flex tw-mx-auto tw-w-[160px]"
  53. src="~/assets/img/savedExhibitionEmpty.png"
  54. alt=""
  55. />
  56. <div
  57. class="tw-text-[16px] tw-text-neutrals-800 tw-w-fit tw-mx-auto tw-mb-[50px] md:tw-mb-[60px]"
  58. >
  59. {{ $t("userProfile.noSavedExhibitions") }}
  60. </div>
  61. <nuxt-link
  62. :to="localePath('/')"
  63. class="tw-flex tw-text-[16px] tw-w-fit tw-bg-primary-1 tw-text-white tw-px-[16px] tw-py-[9px] tw-rounded-[12px] tw-mx-auto tw-mb-[37px] md:tw-mb-0"
  64. >
  65. {{ $t("Explore with ShowEasy") }}
  66. </nuxt-link>
  67. </div>
  68. <div class="tw-mt-[20px] md:tw-mt-[30px]">
  69. <!-- <ExhibitionListCard
  70. v-for="(exhibition, index) in countryFilterList"
  71. :key="index"
  72. class="tw-mb-[20px]"
  73. :item="exhibition"
  74. @toggle-favorite="removeExhibitionRelation($event)"
  75. >
  76. </ExhibitionListCard> -->
  77. <div v-for="list in exhibitionCardList" :key="list">
  78. <ExhibitionListCard :item="list"></ExhibitionListCard>
  79. </div>
  80. <!-- <ExhibitionListCard
  81. v-for="(item, index) in exhibitionCardList"
  82. :key="index"
  83. class="tw-mb-[20px]"
  84. :item="item"
  85. >
  86. @toggle-favorite="removeExhibitionRelation($event)"
  87. </ExhibitionListCard> -->
  88. <!-- <ExhibitionListCard v-for="item in exhibitionCardList" :key="item"></ExhibitionListCard> -->
  89. <div class="tw-mt-[34px] tw-flex tw-justify-end">
  90. <pagination :pageLength="pageLength" @update="updatePage"></pagination>
  91. </div>
  92. <!-- <v-pagination
  93. v-model="page"
  94. class="tw-mt-[28px]"
  95. :length="userSavedExhibitionPageLength"
  96. ></v-pagination> -->
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </template>
  102. <script>
  103. import TwoDots from "@/components/TwoDots";
  104. import ExhibitionListCard from "~/components/exhibition/ExhibitionListCard.vue";
  105. import userSidebar from "@/components/user/userSidebar.vue";
  106. import elementSelect from "@/components/newComponent/form/ElementSelect.vue";
  107. import pagination from "@/components/newComponent/pagination/pagination.vue";
  108. export default {
  109. name: "saveExhibition",
  110. layout: "profile",
  111. components: {
  112. TwoDots,
  113. ExhibitionListCard,
  114. userSidebar,
  115. elementSelect,
  116. pagination,
  117. },
  118. data() {
  119. return {
  120. test:false,
  121. firstName: "",
  122. lastName: "",
  123. userData: {},
  124. userCompanyId: [],
  125. userCompanyList: [],
  126. userAddNewCompanyList: [],
  127. userSavedExhibitionList: [],
  128. userVisibleSavedExhibitionList: [],
  129. userSavedExhibitionPageLength: 0,
  130. savedExhibitionPerPage: 6,
  131. yearOptions: [],
  132. monthOptions: [],
  133. dayOptions: [],
  134. yearSelect: "",
  135. monthSelect: "",
  136. daySelect: "",
  137. languageSelect: {
  138. en: "",
  139. zhtw: "",
  140. },
  141. phoneValid: false,
  142. countryList:[],
  143. countryOptions: [],
  144. countrySelect: 999,
  145. statusList:[],
  146. statusOptions: [],
  147. statusSelect: 999,
  148. page: 1,
  149. filterList: [],
  150. countryFilterList: [],
  151. userSaveExhibitionList: [],
  152. exhibitionList: [],
  153. exhibitionMap: new Map(),
  154. showUserExhibitionList: [],
  155. userSaveExhibition: [],
  156. CountryName:[],
  157. test:"",
  158. isRouterAlive: true,
  159. currentPage: 1,
  160. perPageItems: 600000,
  161. exhibitionMap: new Map(),
  162. exhibitionCardList: [],
  163. userFavoriateList: [],
  164. };
  165. },
  166. async created() {
  167. this.fetchUserData();
  168. // await this.fetchExhibition();
  169. // await this.fetchUserFavoriateExhibition();
  170. await this.fetchFavoriate();
  171. await this.fetchAllExhibition();
  172. this.setUserExhibitionCard();
  173. // await this.userSavedExhib();
  174. // await this.filterSavedExhibition();
  175. // //await this.showUserExhibitionList();
  176. // this.$axios
  177. // .get(`/trending/api/location/countries?RegionID&Lang=${this.$i18n.localeProperties["langQuery"]}`)
  178. // .then((response) => {
  179. // //console.log(JSON.stringify(response));
  180. // if(response && response.data && response.data.DATA && response.data.DATA.rel){
  181. // let data = response.data.DATA.rel
  182. // if(data){
  183. // this.countryList = data;
  184. // //console.log(this.countryList);
  185. // this.countryOptions = this.countryList.map((item) => {
  186. // return {
  187. // id: item.CountryID,
  188. // name: item.CountryName,
  189. // };
  190. // });
  191. // const initial = {
  192. // name: this.$t("userProfile.allCountries"),
  193. // id: 999,
  194. // };
  195. // this.countryOptions.splice(0, 0, initial);
  196. // }
  197. // }
  198. // })
  199. // .catch((error) => {
  200. // console.log(error);
  201. // });
  202. // this.$axios
  203. // .get(`/trending/api/exhibition/statuses?Lang=${this.$i18n.localeProperties["langQuery"]}`)
  204. // .then((response) => {
  205. // //console.log(JSON.stringify(response));
  206. // if(response && response.data && response.data.DATA && response.data.DATA.rel){
  207. // let data = response.data.DATA.rel
  208. // if(data){
  209. // this.statusList = data;
  210. // this.statusOptions = this.statusList.map((item) => {
  211. // return {
  212. // id:"",
  213. // Key: item.Key,
  214. // Value: item.Value,
  215. // };
  216. // });
  217. // const initial = {
  218. // id: 999,
  219. // Key: 999,
  220. // Value: this.$t("userProfile.allStatus"),
  221. // };
  222. // this.statusOptions.splice(0, 0, initial);
  223. // }
  224. // }
  225. // })
  226. // .catch((error) => {
  227. // console.log(error);
  228. // });
  229. // this.countryFilterList = this.showUserExhibitionList;
  230. },
  231. mounted() {
  232. this.yearOptions = Array.from(new Array(103), (val, index) =>
  233. (index + 1920).toString()
  234. );
  235. this.monthOptions = Array.from(new Array(13), (val, index) => {
  236. if (index < 10 && index > 0) {
  237. return "0" + index.toString();
  238. }
  239. if (index >= 10) {
  240. return index.toString();
  241. }
  242. });
  243. this.dayOptions = Array.from(new Array(32), (val, index) => {
  244. if (index < 10 && index > 0) {
  245. return "0" + index.toString();
  246. }
  247. if (index >= 10) {
  248. return index.toString();
  249. }
  250. });
  251. this.$nextTick(() => {
  252. window.addEventListener("resize", this.onResize);
  253. });
  254. },
  255. watch: {
  256. countrySelect: {
  257. handler: function () {
  258. if (this.countrySelect) {
  259. this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  260. //this.fetchSavedExhibition();
  261. //this.fetchExhibition();
  262. }
  263. },
  264. },
  265. statusSelect: {
  266. handler: function () {
  267. if (this.statusSelect) {
  268. this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  269. //this.fetchSavedExhibition();
  270. //this.fetchExhibition();
  271. }
  272. },
  273. },
  274. },
  275. computed: {
  276. pageLength() {
  277. return Math.ceil(this.userSaveExhibition.length / this.perPageItems);
  278. },
  279. },
  280. methods: {
  281. async fetchFavoriate() {
  282. await this.$axios
  283. .get(
  284. `/trending/api/Favorite/Favorites?Type=Exhibition`
  285. )
  286. .then((response) => {
  287. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  288. let data = response.data.DATA.rel
  289. if(data){
  290. this.userFavoriateList = data;
  291. }
  292. }
  293. })
  294. .catch((error) => {
  295. console.log(error);
  296. });
  297. },
  298. async fetchAllExhibition() {
  299. await this.$axios
  300. .get(
  301. `/trending/api/Exhibition/Cards?PageIndex=${this.currentPage}&PageSize=${this.perPageItems}&RegionIDs&CountryIDs&CityIDs&MainCategoryIDs&SubCategoryIDs&Status&Date&Sort&Query&Lang=${this.$i18n.localeProperties["langQuery"]}`
  302. )
  303. .then((response) => {
  304. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  305. let data = response.data.DATA.rel
  306. if(data){
  307. console.table(data);
  308. data.DataList.forEach(exhib => {
  309. this.exhibitionMap.set(exhib.ExhibitionID, exhib);
  310. });
  311. // this.setUserExhibitionCard();
  312. };
  313. };
  314. })
  315. .catch((error) => {
  316. console.log(error);
  317. });
  318. },
  319. setUserExhibitionCard() {
  320. this.userFavoriateList.forEach( fav => {
  321. if(this.exhibitionMap.has(fav.ParentID)) {
  322. this.exhibitionCardList.push(this.exhibitionMap.get(fav.ParentID));
  323. }
  324. });
  325. console.log("mdfkkkkkkkuuuu");
  326. console.table(this.exhibitionCardList);
  327. },
  328. updatePage(value) {
  329. this.currentPage = value;
  330. this.fetchExhibition();
  331. },
  332. patchUserData() {
  333. // if (this.width < 1366) {
  334. // this.isEditInfoDialogActive = !this.isEditInfoDialogActive;
  335. // }
  336. if(this.$vuetify.breakpoint.name !== "xs"){
  337. this.userData.BirthDate = this.yearSelect + "-" + this.monthSelect + "-" + this.daySelect;
  338. if(this.userData.BirthDate.length < 10){
  339. this.userData.BirthDate = null;
  340. }
  341. }
  342. if(this.languageSelect.en == true){
  343. this.userData.LanguageID = "en-US";
  344. }else if(this.languageSelect.zhtw == true){
  345. this.userData.LanguageID = "zh-TW";
  346. }else{
  347. this.userData.LanguageID = "null";
  348. }
  349. const patchData = JSON.parse(JSON.stringify(this.userData));
  350. // delete patchData.LoginLog;
  351. // delete patchData.UserCompany;
  352. // delete patchData.UserSocialRelation;
  353. // delete patchData.UserExhibition;
  354. this.$axios
  355. .post(
  356. `/trending/api/Members/Member`, patchData
  357. )
  358. .then((response) => {
  359. //console.log(JSON.stringify(response));
  360. this.successUpdate = !this.successUpdate;
  361. setTimeout(() => {
  362. this.successUpdate = !this.successUpdate;
  363. }, 1000);
  364. this.fetchUserData();
  365. //this.$auth.$storage.setUniversal("userPicture", patchData.MemberPicture);
  366. // this.$auth.$storage.setUniversal(
  367. // "userLastName",
  368. // patchData.LastName
  369. // );
  370. // this.$store.dispatch("updatePicture");
  371. })
  372. .catch((error) => {
  373. console.log(error);
  374. });
  375. },
  376. fetchUserData() {
  377. this.$axios
  378. .get(
  379. `/trending/api/Members/Info`
  380. )
  381. .then((response) => {
  382. //console.log(JSON.stringify(response));
  383. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  384. let data = response.data.DATA.rel
  385. if(data){
  386. this.userData = data;
  387. this.firstName = this.userData.FirstName;
  388. this.lastName = this.userData.LastName;
  389. this.userData.Phone ? (this.phoneValid = true): (this.phoneValid = false);
  390. if(this.userData.ArgumentID == "en-US"){
  391. this.languageSelect.en = true;
  392. }else if(this.userData.ArgumentID == "zh-TW"){
  393. this.languageSelect.zhtw = true;
  394. }else{
  395. this.languageSelect.en = "";
  396. this.languageSelect.zhtw = "";
  397. }
  398. if (
  399. this.userData.BirthDate && typeof this.userData.BirthDate === "object"
  400. ){
  401. this.yearSelect = "";
  402. this.monthSelect = "";
  403. this.daySelect = "";
  404. }else{
  405. const space = this.userData.BirthDate.split("T");
  406. const date = space[0].split("-");
  407. this.yearSelect = date[0];
  408. this.monthSelect = date[1];
  409. this.daySelect = date[2];
  410. }
  411. }
  412. }
  413. })
  414. .catch((error) => {
  415. console.log(error);
  416. });
  417. },
  418. handleImageUpdate(pictureURL) {
  419. this.userData.picture = pictureURL;
  420. this.patchUserData();
  421. this.closeCropDialog();
  422. },
  423. logout() {
  424. this.$auth.$storage.removeUniversal("jwt");
  425. this.$auth.$storage.removeUniversal("userPicture");
  426. this.$auth.$storage.removeUniversal("userLastName");
  427. this.$auth.$storage.removeUniversal("userBeforePath");
  428. if (window.innerWidth < 1024) {
  429. this.$router.push(this.localePath("/"));
  430. } else {
  431. this.$router.push(this.localePath("/user"));
  432. }
  433. this.$auth.logout();
  434. },
  435. async fetchUserFavoriateExhibition() {
  436. this.$axios
  437. .get(
  438. `/trending/api/Favorite/Favorites?Type=Exhibition`
  439. )
  440. .then((response) => {
  441. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  442. let data = response.data.DATA.rel
  443. if(data){
  444. //console.log("data:" + JSON.stringify(data));
  445. this.userSaveExhibition = data;
  446. this.userSaveExhibition = this.userSaveExhibition.map((item) => {
  447. return{
  448. ParentID: item.ParentID,
  449. };
  450. });
  451. this.userSavedExhibitionPageLength = Math.ceil(
  452. this.userSaveExhibition.length / this.savedExhibitionPerPage
  453. );
  454. console.table(this.userSaveExhibition);
  455. //this.userVisibleSavedExhibitionList = JSON.parse(JSON.stringify(this.userSaveExhibition));
  456. }
  457. }
  458. })
  459. .catch((error) => {
  460. console.log(error);
  461. });
  462. },
  463. async fetchExhibition() {
  464. await this.$axios
  465. .get(
  466. `/trending/api/Exhibition/Cards?PageIndex=${this.currentPage}&PageSize=${this.perPageItems}&RegionIDs&CountryIDs&CityIDs&MainCategoryIDs&SubCategoryIDs&Status&Date&Sort&Query&Lang=${this.$i18n.localeProperties["langQuery"]}`
  467. )
  468. .then((response) => {
  469. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  470. let data = response.data.DATA.rel
  471. if(data){
  472. this.exhibitionList = data.DataList;
  473. this.exhibitionList.forEach(exhibition => {
  474. this.exhibitionMap.set(exhibition.ExhibitionID, exhibition);
  475. });
  476. console.log("All exhibitions " + this.exhibitionMap.size);
  477. console.table(this.exhibitionMap);
  478. // this.exhibitionList = data.DataList;
  479. // this.showUserExhibitionList = [];
  480. // this.countryFilterList = [];
  481. // this.userSavedExhib();
  482. //Berlin示範的
  483. // this.exhibitionList.forEach((exhib) => {
  484. // this.exhibitionMap.set(exhib.ExhibitionID, exhib);
  485. // })
  486. console.log("holy shit size");
  487. console.log(this.userSaveExhibition);
  488. this.userSaveExhibition.forEach((exhib) => {
  489. if (this.exhibitionMap.has(exhib.ExhibitionID)) {
  490. this.testArr.push(this.exhibitionMap.get(exhib.ExhibitionID));
  491. }
  492. })
  493. console.log("mdfk");
  494. console.table(this.testArr);
  495. };
  496. };
  497. })
  498. .catch((error) => {
  499. console.log(error);
  500. });
  501. },
  502. // userSavedExhib(){
  503. // this.exhibitionList.forEach(exhib => {
  504. // // console.log(exhib.ExhibitionID);
  505. // this.userSaveExhibition.forEach(user => {
  506. // // console.log(user.ParentID);
  507. // // if(exhib.ExhibitionID === user.ParentID){
  508. // console.log(exhib.ExhibitionID);
  509. // // exhib.IsFavorite = 'Y';
  510. // // this.showUserExhibitionList.push(exhib);
  511. // // }
  512. // })
  513. // });
  514. // // this.countryFilterList = JSON.parse(
  515. // // JSON.stringify(this.showUserExhibitionList));
  516. // },
  517. filterSavedExhibition(countryId, selectId) {
  518. this.countryFilterList = [];
  519. this.currentPage = 1;
  520. //const country = countryId;
  521. if (countryId == "999" && selectId == "999") {
  522. this.countryFilterList = JSON.parse(
  523. JSON.stringify(this.showUserExhibitionList)
  524. );
  525. } else if(countryId == "999" && selectId !== "999"){
  526. this.showUserExhibitionList.forEach((item) => {
  527. if(item.ExhibStatus == selectId){
  528. this.countryFilterList.push(item);
  529. }
  530. });
  531. }else if(countryId !== "999" && selectId == "999"){
  532. this.showUserExhibitionList.forEach((item) => {
  533. if(item.CountryID == countryId){
  534. this.countryFilterList.push(item);
  535. }
  536. });
  537. }else {
  538. this.showUserExhibitionList.forEach((item) => {
  539. if(item.CountryID == countryId && item.ExhibStatus == selectId){
  540. this.countryFilterList.push(item);
  541. }
  542. });
  543. // this.userSavedExhibitionPageLength = Math.ceil(
  544. // this.countryFilterList.length / this.savedExhibitionPerPage
  545. // );
  546. };
  547. },
  548. async removeExhibitionRelation() {
  549. this.countryFilterList = [];
  550. this.exhibitionList = [];
  551. this.userSaveExhibition = [];
  552. this.page = 1;
  553. this.fetchUserData();
  554. await this.fetchSavedExhibition();
  555. await this.fetchExhibition();
  556. //this.countryFilterList = this.showUserExhibitionList;
  557. if (this.countrySelect.toString() !== "999") {
  558. this.countrySelect = 999;
  559. }
  560. if (this.statusSelect.toString() !== "999") {
  561. this.statusSelect = 999;
  562. }
  563. this.$forceUpdate();
  564. },
  565. },
  566. };
  567. </script>
  568. <style scoped lang="scss">
  569. select {
  570. background-image: url("~/assets/svg/dropdownarrow.svg");
  571. width: auto;
  572. height: auto;
  573. background-position: right 12px center;
  574. background-repeat: no-repeat;
  575. }
  576. </style>