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.

523 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. <div class="xl:tw-flex xl:tw-justify-between xl:tw-items-start">
  4. <userSidebar
  5. :userData="userData"
  6. :firstName="firstName"
  7. :lastName="lastName"
  8. class="tw-hidden xl:tw-block"
  9. >
  10. </userSidebar>
  11. <!-- <div class="xl:tw-hidden"></div> -->
  12. <div
  13. class="tw-bg-white xl:tw-p-[30px] xl:tw-rounded-[20px] xl:tw-min-w-[900px] xl:tw-max-w-[900px]"
  14. >
  15. <div
  16. class="tw-text-[20px] tw-font-bold tw-text-base-primary tw-mb-[20px] md:t24 md:tw-mb-[30px]"
  17. >
  18. <two-dots class="tw-mr-[30px]"></two-dots
  19. >{{ $t("userProfile.savedExhibitions") }}
  20. </div>
  21. <div class="tw-text-[14px] tw-text-base-primary tw-mb-[10px]">
  22. {{ $t("userProfile.savedExhibitionsFilter") }}
  23. </div>
  24. <div>
  25. <select
  26. v-model="countrySelect"
  27. 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]"
  28. >
  29. <option
  30. v-for="(item, index) in countryOptions"
  31. :key="index"
  32. :value="item.id"
  33. >
  34. {{ item.name }}
  35. </option>
  36. </select>
  37. <select
  38. v-model="statusSelect"
  39. 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]"
  40. >
  41. <option v-for="(item, index) in statusOptions" :key="index" :value="item.Key">
  42. {{ item.Value }}
  43. </option>
  44. </select>
  45. </div>
  46. <div
  47. v-if="showUserExhibitionList.length == 0"
  48. class="tw-mt-[80px] md:tw-mt-[90px]"
  49. >
  50. <img
  51. class="tw-flex tw-mx-auto tw-w-[160px]"
  52. src="~/assets/img/savedExhibitionEmpty.png"
  53. alt=""
  54. />
  55. <div
  56. class="tw-text-[16px] tw-text-neutrals-800 tw-w-fit tw-mx-auto tw-mb-[50px] md:tw-mb-[60px]"
  57. >
  58. {{ $t("userProfile.noSavedExhibitions") }}
  59. </div>
  60. <nuxt-link
  61. :to="localePath('/')"
  62. 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"
  63. >
  64. {{ $t("Explore with ShowEasy") }}
  65. </nuxt-link>
  66. </div>
  67. <div v-else class="tw-mt-[20px] md:tw-mt-[30px]">
  68. <ExhibitionListCard
  69. v-for="(exhibition, index) in countryFilterList"
  70. :key="index"
  71. class="tw-mb-[20px]"
  72. :item="exhibition"
  73. @toggle-favorite="removeExhibitionRelation($event)"
  74. >
  75. </ExhibitionListCard>
  76. <!-- <v-pagination
  77. v-model="page"
  78. class="tw-mt-[28px]"
  79. :length="userSavedExhibitionPageLength"
  80. ></v-pagination> -->
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. import TwoDots from "@/components/TwoDots";
  88. import ExhibitionListCard from "~/components/exhibition/ExhibitionListCard.vue";
  89. import userSidebar from "@/components/user/userSidebar.vue";
  90. import elementSelect from "@/components/newComponent/form/ElementSelect.vue";
  91. export default {
  92. name: "saveExhibition",
  93. layout: "profile",
  94. components: {
  95. TwoDots,
  96. ExhibitionListCard,
  97. userSidebar,
  98. elementSelect,
  99. },
  100. data() {
  101. return {
  102. test:false,
  103. firstName: "",
  104. lastName: "",
  105. userData: {},
  106. userCompanyId: [],
  107. userCompanyList: [],
  108. userAddNewCompanyList: [],
  109. userSavedExhibitionList: [],
  110. userVisibleSavedExhibitionList: [],
  111. userSavedExhibitionPageLength: 0,
  112. savedExhibitionPerPage: 6,
  113. yearOptions: [],
  114. monthOptions: [],
  115. dayOptions: [],
  116. yearSelect: "",
  117. monthSelect: "",
  118. daySelect: "",
  119. languageSelect: {
  120. en: "",
  121. zhtw: "",
  122. },
  123. phoneValid: false,
  124. countryList:[],
  125. countryOptions: [],
  126. countrySelect: 999,
  127. statusList:[],
  128. statusOptions: [],
  129. statusSelect: 999,
  130. page: 1,
  131. filterList: [],
  132. countryFilterList: [],
  133. userSaveExhibitionList: [],
  134. exhibitionList: [],
  135. exhibitionMap: new Map(),
  136. showUserExhibitionList: [],
  137. userSaveExhibition: [],
  138. CountryName:[],
  139. test:"",
  140. };
  141. },
  142. async created() {
  143. this.fetchUserData();
  144. await this.fetchSavedExhibition();
  145. await this.fetchExhibition();
  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 () {
  230. if (this.countrySelect) {
  231. this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  232. //this.fetchSavedExhibition();
  233. //this.fetchExhibition();
  234. }
  235. },
  236. },
  237. statusSelect: {
  238. handler: function () {
  239. if (this.statusSelect) {
  240. this.filterSavedExhibition(this.countrySelect,this.statusSelect);
  241. //this.fetchSavedExhibition();
  242. //this.fetchExhibition();
  243. }
  244. },
  245. },
  246. },
  247. computed: {},
  248. methods: {
  249. patchUserData() {
  250. // if (this.width < 1366) {
  251. // this.isEditInfoDialogActive = !this.isEditInfoDialogActive;
  252. // }
  253. if(this.$vuetify.breakpoint.name !== "xs"){
  254. this.userData.BirthDate = this.yearSelect + "-" + this.monthSelect + "-" + this.daySelect;
  255. if(this.userData.BirthDate.length < 10){
  256. this.userData.BirthDate = null;
  257. }
  258. }
  259. if(this.languageSelect.en == true){
  260. this.userData.LanguageID = "en-US";
  261. }else if(this.languageSelect.zhtw == true){
  262. this.userData.LanguageID = "zh-TW";
  263. }else{
  264. this.userData.LanguageID = "null";
  265. }
  266. const patchData = JSON.parse(JSON.stringify(this.userData));
  267. // delete patchData.LoginLog;
  268. // delete patchData.UserCompany;
  269. // delete patchData.UserSocialRelation;
  270. // delete patchData.UserExhibition;
  271. this.$axios
  272. .post(
  273. `/trending/api/Members/Member`, patchData
  274. )
  275. .then((response) => {
  276. //console.log(JSON.stringify(response));
  277. this.successUpdate = !this.successUpdate;
  278. setTimeout(() => {
  279. this.successUpdate = !this.successUpdate;
  280. }, 1000);
  281. this.fetchUserData();
  282. //this.$auth.$storage.setUniversal("userPicture", patchData.MemberPicture);
  283. // this.$auth.$storage.setUniversal(
  284. // "userLastName",
  285. // patchData.LastName
  286. // );
  287. // this.$store.dispatch("updatePicture");
  288. })
  289. .catch((error) => {
  290. console.log(error);
  291. });
  292. },
  293. fetchUserData() {
  294. this.$axios
  295. .get(
  296. `/trending/api/Members/Info`
  297. )
  298. .then((response) => {
  299. //console.log(JSON.stringify(response));
  300. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  301. let data = response.data.DATA.rel
  302. if(data){
  303. this.userData = data;
  304. this.firstName = this.userData.FirstName;
  305. this.lastName = this.userData.LastName;
  306. this.userData.Phone ? (this.phoneValid = true): (this.phoneValid = false);
  307. if(this.userData.ArgumentID == "en-US"){
  308. this.languageSelect.en = true;
  309. }else if(this.userData.ArgumentID == "zh-TW"){
  310. this.languageSelect.zhtw = true;
  311. }else{
  312. this.languageSelect.en = "";
  313. this.languageSelect.zhtw = "";
  314. }
  315. if (
  316. this.userData.BirthDate && typeof this.userData.BirthDate === "object"
  317. ){
  318. this.yearSelect = "";
  319. this.monthSelect = "";
  320. this.daySelect = "";
  321. }else{
  322. const space = this.userData.BirthDate.split("T");
  323. const date = space[0].split("-");
  324. this.yearSelect = date[0];
  325. this.monthSelect = date[1];
  326. this.daySelect = date[2];
  327. }
  328. }
  329. }
  330. })
  331. .catch((error) => {
  332. console.log(error);
  333. });
  334. },
  335. handleImageUpdate(pictureURL) {
  336. this.userData.picture = pictureURL;
  337. this.patchUserData();
  338. this.closeCropDialog();
  339. },
  340. logout() {
  341. this.$auth.$storage.removeUniversal("jwt");
  342. this.$auth.$storage.removeUniversal("userPicture");
  343. this.$auth.$storage.removeUniversal("userLastName");
  344. this.$auth.$storage.removeUniversal("userBeforePath");
  345. if (window.innerWidth < 1024) {
  346. this.$router.push(this.localePath("/"));
  347. } else {
  348. this.$router.push(this.localePath("/user"));
  349. }
  350. this.$auth.logout();
  351. },
  352. async fetchSavedExhibition() {
  353. this.$axios
  354. .get(
  355. `/trending/api/Favorite/Favorites?Type=Exhibition`
  356. )
  357. .then((response) => {
  358. console.log(JSON.stringify(response));
  359. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  360. let data = response.data.DATA.rel
  361. if(data){
  362. //console.log("data:" + JSON.stringify(data));
  363. this.userSaveExhibition = data;
  364. this.userSaveExhibition = this.userSaveExhibition.map((item) => {
  365. return{
  366. ParentID: item.ParentID,
  367. };
  368. });
  369. this.userSavedExhibitionPageLength = Math.ceil(
  370. this.userSaveExhibition.length / this.savedExhibitionPerPage
  371. );
  372. //this.userVisibleSavedExhibitionList = JSON.parse(JSON.stringify(this.userSaveExhibition));
  373. }
  374. }
  375. })
  376. .catch((error) => {
  377. console.log(error);
  378. });
  379. },
  380. async fetchExhibition() {
  381. this.$axios
  382. .get(
  383. `/trending/api/Exhibition/Cards?RegionIDs&CountryIDs&CityIDs&MainCategoryIDs&SubCategoryIDs&Status&Date&Sort&Lang=${this.$i18n.localeProperties["langQuery"]}`
  384. )
  385. .then((response) => {
  386. console.log(JSON.stringify(response));
  387. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  388. let data = response.data.DATA.rel
  389. if(data){
  390. this.exhibitionList = data;
  391. this.exhibitionList.forEach((exhib) => {
  392. this.userSaveExhibition.forEach((user) => {
  393. if(exhib.ExhibitionID == user.ParentID){
  394. this.showUserExhibitionList.push(exhib);
  395. }
  396. })
  397. });
  398. this.countryFilterList = JSON.parse(
  399. JSON.stringify(this.showUserExhibitionList));
  400. //Berlin示範的
  401. // this.exhibitionList.forEach((exhib) => {
  402. // this.exhibitionMap.set(exhib.ExhibitionID, exhib);
  403. // })
  404. // this.userSaveExhibition.forEach((exhib) => {
  405. // this.showUserExhibitionList.push(this.exhibitionMap.get(exhib.ExhibitionID));
  406. // })
  407. };
  408. };
  409. })
  410. .catch((error) => {
  411. console.log(error);
  412. });
  413. },
  414. filterSavedExhibition(countryId, selectId) {
  415. this.countryFilterList = [];
  416. this.page = 1;
  417. //const country = countryId;
  418. if (countryId == "999" && selectId == "999") {
  419. this.countryFilterList = JSON.parse(
  420. JSON.stringify(this.showUserExhibitionList)
  421. );
  422. } else if(countryId == "999" && selectId !== "999"){
  423. this.showUserExhibitionList.forEach((item) => {
  424. if(item.ExhibStatus == selectId){
  425. this.countryFilterList.push(item);
  426. }
  427. });
  428. }else if(countryId !== "999" && selectId == "999"){
  429. this.showUserExhibitionList.forEach((item) => {
  430. if(item.CountryID == countryId){
  431. this.countryFilterList.push(item);
  432. }
  433. });
  434. }else {
  435. this.showUserExhibitionList.forEach((item) => {
  436. if(item.CountryID == countryId && item.ExhibStatus == selectId){
  437. this.countryFilterList.push(item);
  438. }
  439. });
  440. // this.userSavedExhibitionPageLength = Math.ceil(
  441. // this.countryFilterList.length / this.savedExhibitionPerPage
  442. // );
  443. };
  444. },
  445. async removeExhibitionRelation() {
  446. this.page = 1;
  447. await this.fetchUserData();
  448. await this.fetchExhibition();
  449. this.countryFilterList = this.showUserExhibitionList;
  450. if (this.countrySelect.toString() !== "999") {
  451. this.countrySelect = 999;
  452. }
  453. },
  454. },
  455. };
  456. </script>
  457. <style scoped lang="scss">
  458. select {
  459. background-image: url("~/assets/svg/dropdownarrow.svg");
  460. width: auto;
  461. height: auto;
  462. background-position: right 12px center;
  463. background-repeat: no-repeat;
  464. }
  465. </style>