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.

559 lines
17 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
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 v-else 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 class="tw-mt-[34px] tw-flex tw-justify-end">
  78. <pagination :pageLength="pageLength" @update="updatePage"></pagination>
  79. </div>
  80. <!-- <v-pagination
  81. v-model="page"
  82. class="tw-mt-[28px]"
  83. :length="userSavedExhibitionPageLength"
  84. ></v-pagination> -->
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import TwoDots from "@/components/TwoDots";
  92. import ExhibitionListCard from "~/components/exhibition/ExhibitionListCard.vue";
  93. import userSidebar from "@/components/user/userSidebar.vue";
  94. import elementSelect from "@/components/newComponent/form/ElementSelect.vue";
  95. import pagination from "@/components/newComponent/pagination/pagination.vue";
  96. export default {
  97. name: "saveExhibition",
  98. layout: "profile",
  99. components: {
  100. TwoDots,
  101. ExhibitionListCard,
  102. userSidebar,
  103. elementSelect,
  104. pagination,
  105. },
  106. data() {
  107. return {
  108. test:false,
  109. firstName: "",
  110. lastName: "",
  111. userData: {},
  112. userCompanyId: [],
  113. userCompanyList: [],
  114. userAddNewCompanyList: [],
  115. userSavedExhibitionList: [],
  116. userVisibleSavedExhibitionList: [],
  117. userSavedExhibitionPageLength: 0,
  118. savedExhibitionPerPage: 6,
  119. yearOptions: [],
  120. monthOptions: [],
  121. dayOptions: [],
  122. yearSelect: "",
  123. monthSelect: "",
  124. daySelect: "",
  125. languageSelect: {
  126. en: "",
  127. zhtw: "",
  128. },
  129. phoneValid: false,
  130. countryList:[],
  131. countryOptions: [],
  132. countrySelect: 999,
  133. statusList:[],
  134. statusOptions: [],
  135. statusSelect: 999,
  136. page: 1,
  137. filterList: [],
  138. countryFilterList: [],
  139. userSaveExhibitionList: [],
  140. exhibitionList: [],
  141. exhibitionMap: new Map(),
  142. showUserExhibitionList: [],
  143. userSaveExhibition: [],
  144. CountryName:[],
  145. test:"",
  146. isRouterAlive: true,
  147. currentPage: 1,
  148. perPageItems: 6,
  149. };
  150. },
  151. async created() {
  152. this.fetchUserData();
  153. await this.fetchSavedExhibition();
  154. await this.fetchExhibition();
  155. await this.userSavedExhib();
  156. await this.filterSavedExhibition();
  157. //await this.showUserExhibitionList();
  158. this.$axios
  159. .get(`/trending/api/location/countries?RegionID&Lang=${this.$i18n.localeProperties["langQuery"]}`)
  160. .then((response) => {
  161. //console.log(JSON.stringify(response));
  162. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  163. let data = response.data.DATA.rel
  164. if(data){
  165. this.countryList = data;
  166. //console.log(this.countryList);
  167. this.countryOptions = this.countryList.map((item) => {
  168. return {
  169. id: item.CountryID,
  170. name: item.CountryName,
  171. };
  172. });
  173. const initial = {
  174. name: this.$t("userProfile.allCountries"),
  175. id: 999,
  176. };
  177. this.countryOptions.splice(0, 0, initial);
  178. }
  179. }
  180. })
  181. .catch((error) => {
  182. console.log(error);
  183. });
  184. this.$axios
  185. .get(`/trending/api/exhibition/statuses?Lang=${this.$i18n.localeProperties["langQuery"]}`)
  186. .then((response) => {
  187. //console.log(JSON.stringify(response));
  188. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  189. let data = response.data.DATA.rel
  190. if(data){
  191. this.statusList = data;
  192. this.statusOptions = this.statusList.map((item) => {
  193. return {
  194. id:"",
  195. Key: item.Key,
  196. Value: item.Value,
  197. };
  198. });
  199. const initial = {
  200. id: 999,
  201. Key: 999,
  202. Value: this.$t("userProfile.allStatus"),
  203. };
  204. this.statusOptions.splice(0, 0, initial);
  205. }
  206. }
  207. })
  208. .catch((error) => {
  209. console.log(error);
  210. });
  211. this.countryFilterList = this.showUserExhibitionList;
  212. },
  213. mounted() {
  214. this.yearOptions = Array.from(new Array(103), (val, index) =>
  215. (index + 1920).toString()
  216. );
  217. this.monthOptions = Array.from(new Array(13), (val, index) => {
  218. if (index < 10 && index > 0) {
  219. return "0" + index.toString();
  220. }
  221. if (index >= 10) {
  222. return index.toString();
  223. }
  224. });
  225. this.dayOptions = Array.from(new Array(32), (val, index) => {
  226. if (index < 10 && index > 0) {
  227. return "0" + index.toString();
  228. }
  229. if (index >= 10) {
  230. return index.toString();
  231. }
  232. });
  233. this.$nextTick(() => {
  234. window.addEventListener("resize", this.onResize);
  235. });
  236. },
  237. watch: {
  238. countrySelect: {
  239. handler: function () {
  240. if (this.countrySelect) {
  241. this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  242. //this.fetchSavedExhibition();
  243. //this.fetchExhibition();
  244. }
  245. },
  246. },
  247. statusSelect: {
  248. handler: function () {
  249. if (this.statusSelect) {
  250. this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  251. //this.fetchSavedExhibition();
  252. //this.fetchExhibition();
  253. }
  254. },
  255. },
  256. },
  257. computed: {
  258. pageLength() {
  259. return Math.ceil(this.userSaveExhibition.length / this.perPageItems);
  260. },
  261. },
  262. methods: {
  263. updatePage(value) {
  264. this.currentPage = value;
  265. this.fetchExhibition();
  266. },
  267. patchUserData() {
  268. // if (this.width < 1366) {
  269. // this.isEditInfoDialogActive = !this.isEditInfoDialogActive;
  270. // }
  271. if(this.$vuetify.breakpoint.name !== "xs"){
  272. this.userData.BirthDate = this.yearSelect + "-" + this.monthSelect + "-" + this.daySelect;
  273. if(this.userData.BirthDate.length < 10){
  274. this.userData.BirthDate = null;
  275. }
  276. }
  277. if(this.languageSelect.en == true){
  278. this.userData.LanguageID = "en-US";
  279. }else if(this.languageSelect.zhtw == true){
  280. this.userData.LanguageID = "zh-TW";
  281. }else{
  282. this.userData.LanguageID = "null";
  283. }
  284. const patchData = JSON.parse(JSON.stringify(this.userData));
  285. // delete patchData.LoginLog;
  286. // delete patchData.UserCompany;
  287. // delete patchData.UserSocialRelation;
  288. // delete patchData.UserExhibition;
  289. this.$axios
  290. .post(
  291. `/trending/api/Members/Member`, patchData
  292. )
  293. .then((response) => {
  294. //console.log(JSON.stringify(response));
  295. this.successUpdate = !this.successUpdate;
  296. setTimeout(() => {
  297. this.successUpdate = !this.successUpdate;
  298. }, 1000);
  299. this.fetchUserData();
  300. //this.$auth.$storage.setUniversal("userPicture", patchData.MemberPicture);
  301. // this.$auth.$storage.setUniversal(
  302. // "userLastName",
  303. // patchData.LastName
  304. // );
  305. // this.$store.dispatch("updatePicture");
  306. })
  307. .catch((error) => {
  308. console.log(error);
  309. });
  310. },
  311. fetchUserData() {
  312. this.$axios
  313. .get(
  314. `/trending/api/Members/Info`
  315. )
  316. .then((response) => {
  317. //console.log(JSON.stringify(response));
  318. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  319. let data = response.data.DATA.rel
  320. if(data){
  321. this.userData = data;
  322. this.firstName = this.userData.FirstName;
  323. this.lastName = this.userData.LastName;
  324. this.userData.Phone ? (this.phoneValid = true): (this.phoneValid = false);
  325. if(this.userData.ArgumentID == "en-US"){
  326. this.languageSelect.en = true;
  327. }else if(this.userData.ArgumentID == "zh-TW"){
  328. this.languageSelect.zhtw = true;
  329. }else{
  330. this.languageSelect.en = "";
  331. this.languageSelect.zhtw = "";
  332. }
  333. if (
  334. this.userData.BirthDate && typeof this.userData.BirthDate === "object"
  335. ){
  336. this.yearSelect = "";
  337. this.monthSelect = "";
  338. this.daySelect = "";
  339. }else{
  340. const space = this.userData.BirthDate.split("T");
  341. const date = space[0].split("-");
  342. this.yearSelect = date[0];
  343. this.monthSelect = date[1];
  344. this.daySelect = date[2];
  345. }
  346. }
  347. }
  348. })
  349. .catch((error) => {
  350. console.log(error);
  351. });
  352. },
  353. handleImageUpdate(pictureURL) {
  354. this.userData.picture = pictureURL;
  355. this.patchUserData();
  356. this.closeCropDialog();
  357. },
  358. logout() {
  359. this.$auth.$storage.removeUniversal("jwt");
  360. this.$auth.$storage.removeUniversal("userPicture");
  361. this.$auth.$storage.removeUniversal("userLastName");
  362. this.$auth.$storage.removeUniversal("userBeforePath");
  363. if (window.innerWidth < 1024) {
  364. this.$router.push(this.localePath("/"));
  365. } else {
  366. this.$router.push(this.localePath("/user"));
  367. }
  368. this.$auth.logout();
  369. },
  370. async fetchSavedExhibition() {
  371. this.$axios
  372. .get(
  373. `/trending/api/Favorite/Favorites?Type=Exhibition`
  374. )
  375. .then((response) => {
  376. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  377. let data = response.data.DATA.rel
  378. if(data){
  379. //console.log("data:" + JSON.stringify(data));
  380. this.userSaveExhibition = data;
  381. this.userSaveExhibition = this.userSaveExhibition.map((item) => {
  382. return{
  383. ParentID: item.ParentID,
  384. };
  385. });
  386. this.userSavedExhibitionPageLength = Math.ceil(
  387. this.userSaveExhibition.length / this.savedExhibitionPerPage
  388. );
  389. //this.userVisibleSavedExhibitionList = JSON.parse(JSON.stringify(this.userSaveExhibition));
  390. }
  391. }
  392. })
  393. .catch((error) => {
  394. console.log(error);
  395. });
  396. },
  397. async fetchExhibition() {
  398. this.$axios
  399. .get(
  400. `/trending/api/Exhibition/Cards?PageIndex=${this.currentPage}&PageSize=${this.perPageItems}&RegionIDs&CountryIDs&CityIDs&MainCategoryIDs&SubCategoryIDs&Status&Date&Sort&Query&Lang=${this.$i18n.localeProperties["langQuery"]}`
  401. )
  402. .then((response) => {
  403. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  404. let data = response.data.DATA.rel
  405. if(data){
  406. this.exhibitionList = data;
  407. this.showUserExhibitionList = [];
  408. this.countryFilterList = [];
  409. this.userSavedExhib();
  410. //Berlin示範的
  411. // this.exhibitionList.forEach((exhib) => {
  412. // this.exhibitionMap.set(exhib.ExhibitionID, exhib);
  413. // })
  414. // this.userSaveExhibition.forEach((exhib) => {
  415. // this.showUserExhibitionList.push(this.exhibitionMap.get(exhib.ExhibitionID));
  416. // })
  417. };
  418. };
  419. })
  420. .catch((error) => {
  421. console.log(error);
  422. });
  423. },
  424. async userSavedExhib(){
  425. this.exhibitionList.forEach((exhib) => {
  426. this.userSaveExhibition.forEach((user) => {
  427. if(exhib.ExhibitionID == user.ParentID){
  428. exhib.IsFavorite = 'Y';
  429. this.showUserExhibitionList.push(exhib);
  430. }
  431. })
  432. });
  433. this.countryFilterList = JSON.parse(
  434. JSON.stringify(this.showUserExhibitionList));
  435. },
  436. filterSavedExhibition(countryId, selectId) {
  437. this.countryFilterList = [];
  438. this.currentPage = 1;
  439. //const country = countryId;
  440. if (countryId == "999" && selectId == "999") {
  441. this.countryFilterList = JSON.parse(
  442. JSON.stringify(this.showUserExhibitionList)
  443. );
  444. } else if(countryId == "999" && selectId !== "999"){
  445. this.showUserExhibitionList.forEach((item) => {
  446. if(item.ExhibStatus == selectId){
  447. this.countryFilterList.push(item);
  448. }
  449. });
  450. }else if(countryId !== "999" && selectId == "999"){
  451. this.showUserExhibitionList.forEach((item) => {
  452. if(item.CountryID == countryId){
  453. this.countryFilterList.push(item);
  454. }
  455. });
  456. }else {
  457. this.showUserExhibitionList.forEach((item) => {
  458. if(item.CountryID == countryId && item.ExhibStatus == selectId){
  459. this.countryFilterList.push(item);
  460. }
  461. });
  462. // this.userSavedExhibitionPageLength = Math.ceil(
  463. // this.countryFilterList.length / this.savedExhibitionPerPage
  464. // );
  465. };
  466. },
  467. async removeExhibitionRelation() {
  468. this.countryFilterList = [];
  469. this.exhibitionList = [];
  470. this.userSaveExhibition = [];
  471. this.page = 1;
  472. this.fetchUserData();
  473. await this.fetchSavedExhibition();
  474. await this.fetchExhibition();
  475. //this.countryFilterList = this.showUserExhibitionList;
  476. if (this.countrySelect.toString() !== "999") {
  477. this.countrySelect = 999;
  478. }
  479. if (this.statusSelect.toString() !== "999") {
  480. this.statusSelect = 999;
  481. }
  482. this.$forceUpdate();
  483. },
  484. },
  485. };
  486. </script>
  487. <style scoped lang="scss">
  488. select {
  489. background-image: url("~/assets/svg/dropdownarrow.svg");
  490. width: auto;
  491. height: auto;
  492. background-position: right 12px center;
  493. background-repeat: no-repeat;
  494. }
  495. </style>