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.

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