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.

549 lines
16 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
  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 :userData="userData" :firstName="firstName" :lastName="lastName" class="tw-hidden xl:tw-block">
  6. </userSidebar>
  7. <!-- <div class="xl:tw-hidden"></div> -->
  8. <div class="tw-bg-white xl:tw-p-[30px] xl:tw-rounded-[20px] xl:tw-min-w-[900px] xl:tw-max-w-[900px]">
  9. <div class="tw-text-[20px] tw-font-bold tw-text-base-primary tw-mb-[20px] md:t24 md:tw-mb-[30px]">
  10. <two-dots class="tw-mr-[30px]"></two-dots>{{ $t("userProfile.savedExhibitions") }}
  11. </div>
  12. <div class="tw-text-[14px] tw-text-base-primary tw-mb-[10px]">
  13. {{ $t("userProfile.savedExhibitionsFilter") }}
  14. </div>
  15. <div>
  16. <select v-model="countrySelect" @change="countryOptionSelected($event)"
  17. 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]">
  18. <option value="" selected>{{ $t("userProfile.allCountries") }}</option>
  19. <option v-for="(item, index) in countryOptions" :key="index" :value="item">
  20. {{ item.name }}
  21. </option>
  22. </select>
  23. <select v-model="statusSelect"
  24. 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]">
  25. <option v-for="(item, index) in statusOptions" :key="index" :value="item.Key">
  26. {{ item.Value }}
  27. </option>
  28. </select>
  29. </div>
  30. <div v-if="exhibitionCardList.length == 0" class="tw-mt-[80px] md:tw-mt-[90px]">
  31. <img class="tw-flex tw-mx-auto tw-w-[160px]" src="~/assets/img/savedExhibitionEmpty.png" alt="" />
  32. <div class="tw-text-[16px] tw-text-neutrals-800 tw-w-fit tw-mx-auto tw-mb-[50px] md:tw-mb-[60px]">
  33. {{ $t("userProfile.noSavedExhibitions") }}
  34. </div>
  35. <nuxt-link :to="localePath('/')"
  36. 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">
  37. {{ $t("Explore with ShowEasy") }}
  38. </nuxt-link>
  39. </div>
  40. <div v-else class="tw-mt-[20px] md:tw-mt-[30px]">
  41. <!-- <ExhibitionListCard
  42. v-for="(exhibition, index) in countryFilterList"
  43. :key="index"
  44. class="tw-mb-[20px]"
  45. :item="exhibition"
  46. @toggle-favorite="removeExhibitionRelation($event)"
  47. >
  48. </ExhibitionListCard> -->
  49. <div v-for="exhib in exhibitionCardList" :key="exhib.ExhibitionID">
  50. <ExhibitionListCard :item="exhib" @toggle-favorite="updateExhibitionCardList"></ExhibitionListCard>
  51. </div>
  52. <!-- <ExhibitionListCard
  53. v-for="(item, index) in exhibitionCardList"
  54. :key="index"
  55. class="tw-mb-[20px]"
  56. :item="item"
  57. >
  58. @toggle-favorite="removeExhibitionRelation($event)"
  59. </ExhibitionListCard> -->
  60. <!-- <ExhibitionListCard v-for="item in exhibitionCardList" :key="item"></ExhibitionListCard> -->
  61. <div class="tw-mt-[34px] tw-flex tw-justify-end">
  62. <pagination :pageLength="pageLength" @update="updatePage"></pagination>
  63. </div>
  64. <!-- <v-pagination
  65. v-model="page"
  66. class="tw-mt-[28px]"
  67. :length="userSavedExhibitionPageLength"
  68. ></v-pagination> -->
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import TwoDots from "@/components/TwoDots";
  76. import ExhibitionListCard from "~/components/exhibition/ExhibitionListCard.vue";
  77. import userSidebar from "@/components/user/userSidebar.vue";
  78. import elementSelect from "@/components/newComponent/form/ElementSelect.vue";
  79. import pagination from "@/components/newComponent/pagination/pagination.vue";
  80. export default {
  81. name: "saveExhibition",
  82. layout: "profile",
  83. components: {
  84. TwoDots,
  85. ExhibitionListCard,
  86. userSidebar,
  87. elementSelect,
  88. pagination,
  89. },
  90. data() {
  91. return {
  92. test: false,
  93. firstName: "",
  94. lastName: "",
  95. userData: {},
  96. userCompanyId: [],
  97. userCompanyList: [],
  98. userAddNewCompanyList: [],
  99. userSavedExhibitionList: [],
  100. userVisibleSavedExhibitionList: [],
  101. userSavedExhibitionPageLength: 0,
  102. savedExhibitionPerPage: 6,
  103. yearOptions: [],
  104. monthOptions: [],
  105. dayOptions: [],
  106. yearSelect: "",
  107. monthSelect: "",
  108. daySelect: "",
  109. languageSelect: {
  110. en: "",
  111. zhtw: "",
  112. },
  113. phoneValid: false,
  114. // countrySelect: 999,
  115. statusList: [],
  116. statusOptions: [],
  117. statusSelect: 999,
  118. page: 1,
  119. filterList: [],
  120. countryFilterList: [],
  121. // userSaveExhibitionList: [],
  122. exhibitionList: [],
  123. showUserExhibitionList: [],
  124. // userSaveExhibition: [],
  125. CountryName: [],
  126. test: "",
  127. isRouterAlive: true,
  128. countrySelect: "",
  129. currentPage: 1,
  130. itemsPerPage: 10,
  131. total: 0,
  132. selectedCountry: [],
  133. selectedSubCategory: [],
  134. selectedStatus: [],
  135. countryOptions: [],
  136. exhibitionCardList: [],
  137. userFavoriateList: [],
  138. };
  139. },
  140. async created() {
  141. this.fetchUserData();
  142. await this.fetchExhibitionListCard();
  143. await this.fetchCountryList();
  144. this.fetchStatusList();
  145. // await this.userSavedExhib();
  146. // await this.filterSavedExhibition();
  147. // //await this.showUserExhibitionList();
  148. // this.$axios
  149. // .get(`/trending/api/location/countries?RegionID&Lang=${this.$i18n.localeProperties["langQuery"]}`)
  150. // .then((response) => {
  151. // //console.log(JSON.stringify(response));
  152. // if(response && response.data && response.data.DATA && response.data.DATA.rel){
  153. // let data = response.data.DATA.rel
  154. // if(data){
  155. // this.countryList = data;
  156. // //console.log(this.countryList);
  157. // this.countryOptions = this.countryList.map((item) => {
  158. // return {
  159. // id: item.CountryID,
  160. // name: item.CountryName,
  161. // };
  162. // });
  163. // const initial = {
  164. // name: this.$t("userProfile.allCountries"),
  165. // id: 999,
  166. // };
  167. // this.countryOptions.splice(0, 0, initial);
  168. // }
  169. // }
  170. // })
  171. // .catch((error) => {
  172. // console.log(error);
  173. // });
  174. // this.$axios
  175. // .get(`/trending/api/exhibition/statuses?Lang=${this.$i18n.localeProperties["langQuery"]}`)
  176. // .then((response) => {
  177. // //console.log(JSON.stringify(response));
  178. // if(response && response.data && response.data.DATA && response.data.DATA.rel){
  179. // let data = response.data.DATA.rel
  180. // if(data){
  181. // this.statusList = data;
  182. // this.statusOptions = this.statusList.map((item) => {
  183. // return {
  184. // id:"",
  185. // Key: item.Key,
  186. // Value: item.Value,
  187. // };
  188. // });
  189. // const initial = {
  190. // id: 999,
  191. // Key: 999,
  192. // Value: this.$t("userProfile.allStatus"),
  193. // };
  194. // this.statusOptions.splice(0, 0, initial);
  195. // }
  196. // }
  197. // })
  198. // .catch((error) => {
  199. // console.log(error);
  200. // });
  201. // this.countryFilterList = this.showUserExhibitionList;
  202. },
  203. mounted() {
  204. this.yearOptions = Array.from(new Array(103), (val, index) =>
  205. (index + 1920).toString()
  206. );
  207. this.monthOptions = Array.from(new Array(13), (val, index) => {
  208. if (index < 10 && index > 0) {
  209. return "0" + index.toString();
  210. }
  211. if (index >= 10) {
  212. return index.toString();
  213. }
  214. });
  215. this.dayOptions = Array.from(new Array(32), (val, index) => {
  216. if (index < 10 && index > 0) {
  217. return "0" + index.toString();
  218. }
  219. if (index >= 10) {
  220. return index.toString();
  221. }
  222. });
  223. this.$nextTick(() => {
  224. window.addEventListener("resize", this.onResize);
  225. });
  226. },
  227. watch: {
  228. // countrySelect: {
  229. // handler: function (value) {
  230. // console.log("countrySelected "+ value);
  231. // if (this.countrySelect) {
  232. // console.log(this.countrySelect);
  233. // // this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  234. // //this.fetchSavedExhibition();
  235. // //this.fetchExhibition();
  236. // }
  237. // },
  238. // },
  239. // statusSelect: {
  240. // handler: function () {
  241. // if (this.statusSelect) {
  242. // this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  243. // //this.fetchSavedExhibition();
  244. // //this.fetchExhibition();
  245. // }
  246. // },
  247. // },
  248. },
  249. computed: {
  250. result() {
  251. return this.total;
  252. },
  253. pageLength() {
  254. return Math.ceil(this.result / this.itemsPerPage);
  255. },
  256. },
  257. methods: {
  258. async fetchCountryList() {
  259. await this.$axios
  260. .get(
  261. `/trending/api/Favorite/ExhibitionCountryList?Lang=${this.$i18n.localeProperties["langQuery"]}`
  262. )
  263. .then((response) => {
  264. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  265. let data = response.data.DATA.rel
  266. if (data) {
  267. const countryList = data;
  268. this.countryOptions = countryList.map((item) => {
  269. return {
  270. id: item.CountryID,
  271. name: item.CountryName,
  272. };
  273. });
  274. }
  275. }
  276. })
  277. .catch((error) => {
  278. console.log(error);
  279. });
  280. },
  281. async fetchExhibitionListCard() {
  282. await this.$axios
  283. .get(
  284. `/trending/api/Favorite/ExhibitionList?Lang=${this.$i18n.localeProperties["langQuery"]}` +
  285. `&PageIndex=${this.currentPage}` +
  286. `&PageSize=${this.itemsPerPage}` +
  287. `&CountryIDs=${JSON.stringify(this.selectedCountry)}` +
  288. `&SubCategoryIDs=${JSON.stringify(this.selectedSubCategory)}` +
  289. `&Status=${JSON.stringify(this.selectedStatus)}`
  290. )
  291. .then((response) => {
  292. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  293. let data = response.data.DATA.rel
  294. if (data.DataList) {
  295. this.exhibitionCardList = [];
  296. this.total = data.Total;
  297. data.DataList.forEach(exhib => {
  298. exhib.IsFavorite = "Y";
  299. this.exhibitionCardList.push(exhib);
  300. });
  301. }
  302. }
  303. })
  304. .catch((error) => {
  305. console.log(error);
  306. });
  307. },
  308. countryOptionSelected() {
  309. this.currentPage = 1;
  310. this.selectedCountry = [];
  311. if (this.countrySelect) {
  312. this.selectedCountry.push(this.countrySelect.id);
  313. }
  314. this.updateExhibitionCardList();
  315. },
  316. async fetchStatusList() {
  317. await this.$axios
  318. .get(
  319. `/trending/api/Favorite/Favorites?Type=Exhibition`
  320. )
  321. .then((response) => {
  322. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  323. let data = response.data.DATA.rel
  324. if (data) {
  325. this.userFavoriateList = data;
  326. }
  327. }
  328. })
  329. .catch((error) => {
  330. console.log(error);
  331. });
  332. },
  333. async updateExhibitionCardList() {
  334. await this.fetchExhibitionListCard();
  335. },
  336. updatePage(value) {
  337. this.currentPage = value;
  338. window.scrollTo(0, 0);
  339. this.fetchExhibitionListCard();
  340. },
  341. patchUserData() {
  342. // if (this.width < 1366) {
  343. // this.isEditInfoDialogActive = !this.isEditInfoDialogActive;
  344. // }
  345. if (this.$vuetify.breakpoint.name !== "xs") {
  346. this.userData.BirthDate = this.yearSelect + "-" + this.monthSelect + "-" + this.daySelect;
  347. if (this.userData.BirthDate.length < 10) {
  348. this.userData.BirthDate = null;
  349. }
  350. }
  351. if (this.languageSelect.en == true) {
  352. this.userData.LanguageID = "en-US";
  353. } else if (this.languageSelect.zhtw == true) {
  354. this.userData.LanguageID = "zh-TW";
  355. } else {
  356. this.userData.LanguageID = "null";
  357. }
  358. const patchData = JSON.parse(JSON.stringify(this.userData));
  359. // delete patchData.LoginLog;
  360. // delete patchData.UserCompany;
  361. // delete patchData.UserSocialRelation;
  362. // delete patchData.UserExhibition;
  363. this.$axios
  364. .post(
  365. `/trending/api/Members/Member`, patchData
  366. )
  367. .then((response) => {
  368. //console.log(JSON.stringify(response));
  369. this.successUpdate = !this.successUpdate;
  370. setTimeout(() => {
  371. this.successUpdate = !this.successUpdate;
  372. }, 1000);
  373. this.fetchUserData();
  374. //this.$auth.$storage.setUniversal("userPicture", patchData.MemberPicture);
  375. // this.$auth.$storage.setUniversal(
  376. // "userLastName",
  377. // patchData.LastName
  378. // );
  379. // this.$store.dispatch("updatePicture");
  380. })
  381. .catch((error) => {
  382. console.log(error);
  383. });
  384. },
  385. fetchUserData() {
  386. this.$axios
  387. .get(
  388. `/trending/api/Members/Info`
  389. )
  390. .then((response) => {
  391. //console.log(JSON.stringify(response));
  392. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  393. let data = response.data.DATA.rel
  394. if (data) {
  395. this.userData = data;
  396. this.firstName = this.userData.FirstName;
  397. this.lastName = this.userData.LastName;
  398. this.userData.Phone ? (this.phoneValid = true) : (this.phoneValid = false);
  399. if (this.userData.ArgumentID == "en-US") {
  400. this.languageSelect.en = true;
  401. } else if (this.userData.ArgumentID == "zh-TW") {
  402. this.languageSelect.zhtw = true;
  403. } else {
  404. this.languageSelect.en = "";
  405. this.languageSelect.zhtw = "";
  406. }
  407. if (
  408. this.userData.BirthDate && typeof this.userData.BirthDate === "object"
  409. ) {
  410. this.yearSelect = "";
  411. this.monthSelect = "";
  412. this.daySelect = "";
  413. } else {
  414. const space = this.userData.BirthDate.split("T");
  415. const date = space[0].split("-");
  416. this.yearSelect = date[0];
  417. this.monthSelect = date[1];
  418. this.daySelect = date[2];
  419. }
  420. }
  421. }
  422. })
  423. .catch((error) => {
  424. console.log(error);
  425. });
  426. },
  427. handleImageUpdate(pictureURL) {
  428. this.userData.picture = pictureURL;
  429. this.patchUserData();
  430. this.closeCropDialog();
  431. },
  432. logout() {
  433. this.$auth.$storage.removeUniversal("jwt");
  434. this.$auth.$storage.removeUniversal("userPicture");
  435. this.$auth.$storage.removeUniversal("userLastName");
  436. this.$auth.$storage.removeUniversal("userBeforePath");
  437. if (window.innerWidth < 1024) {
  438. this.$router.push(this.localePath("/"));
  439. } else {
  440. this.$router.push(this.localePath("/user"));
  441. }
  442. this.$auth.logout();
  443. },
  444. },
  445. };
  446. </script>
  447. <style scoped lang="scss">
  448. select {
  449. background-image: url("~/assets/svg/dropdownarrow.svg");
  450. width: auto;
  451. height: auto;
  452. background-position: right 12px center;
  453. background-repeat: no-repeat;
  454. }
  455. </style>