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.

448 lines
12 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" @change="statusOptionSelected($event)"
  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 value="" selected>{{ $t("userProfile.allStatus") }}</option>
  26. <option v-for="(item, index) in statusOptions" :key="index" :value="item">
  27. {{ item.name }}
  28. </option>
  29. </select>
  30. </div>
  31. <div v-if="exhibitionCardList.length == 0" class="tw-mt-[80px] md:tw-mt-[90px]">
  32. <img class="tw-flex tw-mx-auto tw-w-[160px]" src="~/assets/img/savedExhibitionEmpty.png" alt="" />
  33. <div class="tw-text-[16px] tw-text-neutrals-800 tw-w-fit tw-mx-auto tw-mb-[50px] md:tw-mb-[60px]">
  34. {{ $t("userProfile.noSavedExhibitions") }}
  35. </div>
  36. <nuxt-link :to="localePath('/')"
  37. 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">
  38. {{ $t("Explore with ShowEasy") }}
  39. </nuxt-link>
  40. </div>
  41. <div v-else class="tw-mt-[20px] md:tw-mt-[30px]">
  42. <div v-for="exhib in exhibitionCardList" :key="exhib.ExhibitionID">
  43. <ExhibitionListCard :item="exhib" @toggle-favorite="fetchNewExhibitionCardList"></ExhibitionListCard>
  44. </div>
  45. <div class="tw-mt-[34px] tw-flex tw-justify-end">
  46. <pagination :pageLength="pageLength" @update="updatePage"></pagination>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import TwoDots from "@/components/TwoDots";
  55. import ExhibitionListCard from "~/components/exhibition/ExhibitionListCard.vue";
  56. import userSidebar from "@/components/user/userSidebar.vue";
  57. import elementSelect from "@/components/newComponent/form/ElementSelect.vue";
  58. import pagination from "@/components/newComponent/pagination/pagination.vue";
  59. export default {
  60. name: "saveExhibition",
  61. layout: "profile",
  62. components: {
  63. TwoDots,
  64. ExhibitionListCard,
  65. userSidebar,
  66. elementSelect,
  67. pagination,
  68. },
  69. data() {
  70. return {
  71. firstName: "",
  72. lastName: "",
  73. userData: {},
  74. userCompanyId: [],
  75. userCompanyList: [],
  76. userAddNewCompanyList: [],
  77. yearOptions: [],
  78. monthOptions: [],
  79. dayOptions: [],
  80. yearSelect: "",
  81. monthSelect: "",
  82. daySelect: "",
  83. languageSelect: {
  84. en: "",
  85. zhtw: "",
  86. },
  87. phoneValid: false,
  88. isRouterAlive: true,
  89. countrySelect: "",
  90. statusSelect: "",
  91. currentPage: 1,
  92. itemsPerPage: 6,
  93. total: 0,
  94. selectedCountry: [],
  95. selectedSubCategory: [],
  96. selectedStatus: [],
  97. countryOptions: [],
  98. statusOptions: [],
  99. exhibitionCardList: [],
  100. };
  101. },
  102. async created() {
  103. this.fetchUserData();
  104. await this.fetchNewExhibitionCardList();
  105. await this.fetchCountryList();
  106. await this.fetchStatusList();
  107. },
  108. mounted() {
  109. this.yearOptions = Array.from(new Array(103), (val, index) =>
  110. (index + 1920).toString()
  111. );
  112. this.monthOptions = Array.from(new Array(13), (val, index) => {
  113. if (index < 10 && index > 0) {
  114. return "0" + index.toString();
  115. }
  116. if (index >= 10) {
  117. return index.toString();
  118. }
  119. });
  120. this.dayOptions = Array.from(new Array(32), (val, index) => {
  121. if (index < 10 && index > 0) {
  122. return "0" + index.toString();
  123. }
  124. if (index >= 10) {
  125. return index.toString();
  126. }
  127. });
  128. this.$nextTick(() => {
  129. window.addEventListener("resize", this.onResize);
  130. });
  131. },
  132. watch: {
  133. },
  134. computed: {
  135. result() {
  136. return this.total;
  137. },
  138. pageLength() {
  139. return Math.ceil(this.result / this.itemsPerPage);
  140. },
  141. },
  142. methods: {
  143. async fetchCountryList() {
  144. await this.$axios
  145. .get(
  146. `/trending/api/Favorite/ExhibitionCountryList?Lang=${this.$i18n.localeProperties["langQuery"]}`
  147. )
  148. .then((response) => {
  149. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  150. let data = response.data.DATA.rel
  151. if (data) {
  152. const countryList = data;
  153. this.countryOptions = countryList.map((item) => {
  154. return {
  155. id: item.CountryID,
  156. name: item.CountryName,
  157. };
  158. });
  159. }
  160. }
  161. })
  162. .catch((error) => {
  163. console.log(error);
  164. });
  165. },
  166. async fetchStatusList() {
  167. await this.$axios
  168. .get(
  169. `/trending/api/Favorite/ExhibitionStatusList?Lang=${this.$i18n.localeProperties["langQuery"]}`
  170. )
  171. .then((response) => {
  172. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  173. let data = response.data.DATA.rel
  174. if (data) {
  175. const statusList = data;
  176. this.statusOptions = statusList.map((item) => {
  177. return {
  178. id: item.Key,
  179. name: item.Value,
  180. };
  181. });
  182. }
  183. }
  184. })
  185. .catch((error) => {
  186. console.log(error);
  187. });
  188. },
  189. async fetchExhibitionListCard() {
  190. await this.$axios
  191. .get(
  192. `/trending/api/Favorite/ExhibitionList?Lang=${this.$i18n.localeProperties["langQuery"]}` +
  193. `&PageIndex=${this.currentPage}` +
  194. `&PageSize=${this.itemsPerPage}` +
  195. `&CountryIDs=${JSON.stringify(this.selectedCountry)}` +
  196. `&SubCategoryIDs=${JSON.stringify(this.selectedSubCategory)}` +
  197. `&Status=${JSON.stringify(this.selectedStatus)}`
  198. )
  199. .then((response) => {
  200. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  201. let data = response.data.DATA.rel
  202. if (data.DataList) {
  203. this.exhibitionCardList = [];
  204. this.total = data.Total;
  205. data.DataList.forEach(exhib => {
  206. exhib.IsFavorite = "Y";
  207. this.exhibitionCardList.push(exhib);
  208. });
  209. }
  210. }
  211. })
  212. .catch((error) => {
  213. console.log(error);
  214. });
  215. },
  216. countryOptionSelected() {
  217. this.selectedCountry = [];
  218. if (this.countrySelect) {
  219. this.selectedCountry.push(this.countrySelect.id);
  220. }
  221. this.fetchNewExhibitionCardList();
  222. },
  223. statusOptionSelected() {
  224. this.selectedStatus = [];
  225. if (this.statusSelect) {
  226. this.selectedStatus.push(this.statusSelect.id);
  227. }
  228. this.fetchNewExhibitionCardList();
  229. },
  230. async fetchNewExhibitionCardList() {
  231. this.currentPage = 1;
  232. await this.fetchExhibitionListCard();
  233. },
  234. updatePage(value) {
  235. this.currentPage = value;
  236. window.scrollTo(0, 0);
  237. this.fetchExhibitionListCard();
  238. },
  239. patchUserData() {
  240. // if (this.width < 1366) {
  241. // this.isEditInfoDialogActive = !this.isEditInfoDialogActive;
  242. // }
  243. if (this.$vuetify.breakpoint.name !== "xs") {
  244. this.userData.BirthDate = this.yearSelect + "-" + this.monthSelect + "-" + this.daySelect;
  245. if (this.userData.BirthDate.length < 10) {
  246. this.userData.BirthDate = null;
  247. }
  248. }
  249. if (this.languageSelect.en == true) {
  250. this.userData.LanguageID = "en-US";
  251. } else if (this.languageSelect.zhtw == true) {
  252. this.userData.LanguageID = "zh-TW";
  253. } else {
  254. this.userData.LanguageID = "null";
  255. }
  256. const patchData = JSON.parse(JSON.stringify(this.userData));
  257. // delete patchData.LoginLog;
  258. // delete patchData.UserCompany;
  259. // delete patchData.UserSocialRelation;
  260. // delete patchData.UserExhibition;
  261. this.$axios
  262. .post(
  263. `/trending/api/Members/Member`, patchData
  264. )
  265. .then((response) => {
  266. //console.log(JSON.stringify(response));
  267. this.successUpdate = !this.successUpdate;
  268. setTimeout(() => {
  269. this.successUpdate = !this.successUpdate;
  270. }, 1000);
  271. this.fetchUserData();
  272. //this.$auth.$storage.setUniversal("userPicture", patchData.MemberPicture);
  273. // this.$auth.$storage.setUniversal(
  274. // "userLastName",
  275. // patchData.LastName
  276. // );
  277. // this.$store.dispatch("updatePicture");
  278. })
  279. .catch((error) => {
  280. console.log(error);
  281. });
  282. },
  283. fetchUserData() {
  284. this.$axios
  285. .get(
  286. `/trending/api/Members/Info`
  287. )
  288. .then((response) => {
  289. //console.log(JSON.stringify(response));
  290. if (response && response.data && response.data.DATA && response.data.DATA.rel) {
  291. let data = response.data.DATA.rel
  292. if (data) {
  293. this.userData = data;
  294. this.firstName = this.userData.FirstName;
  295. this.lastName = this.userData.LastName;
  296. this.userData.Phone ? (this.phoneValid = true) : (this.phoneValid = false);
  297. if (this.userData.ArgumentID == "en-US") {
  298. this.languageSelect.en = true;
  299. } else if (this.userData.ArgumentID == "zh-TW") {
  300. this.languageSelect.zhtw = true;
  301. } else {
  302. this.languageSelect.en = "";
  303. this.languageSelect.zhtw = "";
  304. }
  305. if (
  306. this.userData.BirthDate && typeof this.userData.BirthDate === "object"
  307. ) {
  308. this.yearSelect = "";
  309. this.monthSelect = "";
  310. this.daySelect = "";
  311. } else {
  312. const space = this.userData.BirthDate.split("T");
  313. const date = space[0].split("-");
  314. this.yearSelect = date[0];
  315. this.monthSelect = date[1];
  316. this.daySelect = date[2];
  317. }
  318. }
  319. }
  320. })
  321. .catch((error) => {
  322. console.log(error);
  323. });
  324. },
  325. handleImageUpdate(pictureURL) {
  326. this.userData.picture = pictureURL;
  327. this.patchUserData();
  328. this.closeCropDialog();
  329. },
  330. logout() {
  331. this.$auth.$storage.removeUniversal("jwt");
  332. this.$auth.$storage.removeUniversal("userPicture");
  333. this.$auth.$storage.removeUniversal("userLastName");
  334. this.$auth.$storage.removeUniversal("userBeforePath");
  335. if (window.innerWidth < 1024) {
  336. this.$router.push(this.localePath("/"));
  337. } else {
  338. this.$router.push(this.localePath("/user"));
  339. }
  340. this.$auth.logout();
  341. },
  342. },
  343. };
  344. </script>
  345. <style scoped lang="scss">
  346. select {
  347. background-image: url("~/assets/svg/dropdownarrow.svg");
  348. width: auto;
  349. height: auto;
  350. background-position: right 12px center;
  351. background-repeat: no-repeat;
  352. }
  353. </style>