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.

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