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.

597 lines
15 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
  1. <template>
  2. <div
  3. class="tw-px-[30px] tw-mb-[60px] md:tw-mb-[100px] xl:tw-px-[60px] xl:tw-max-w-screen-xl xl:tw-mx-auto xl:tw-grid xl:tw-grid-cols-[380px_auto] xl:tw-gap-[30px]">
  4. <section class="xl:tw-col-span-2 tw-mb-5 md:tw-mb-0">
  5. <centerMode :list="adList" v-if="adList.length"></centerMode>
  6. </section>
  7. <section class="xl:tw-col-span-2 tw-mb-[40px] xl:tw-mb-[10px]">
  8. <Breadcrumbs class="tw-py-[7px] md:tw-py-[10px] xl:tw-py-[13px] tw-mb-4 md:tw-mb-6 xl:tw-mb-0"></Breadcrumbs>
  9. <sort :results="result" :sortType="sortType" :sortBy="sortBy" @sort="updateSortBy($event)"
  10. @filter="$modal.show(`sidebar-filter-modal`)"></sort>
  11. </section>
  12. <section class="tw-grid tw-grid-cols-1 tw-gap-[30px] tw-auto-rows-min">
  13. <div class="tw-max-h-min" v-if="$vuetify.breakpoint.xl">
  14. <DateCard @update="updateDateFilter" :modalChecked="selectedDates" />
  15. </div>
  16. <div v-if="$vuetify.breakpoint.xl">
  17. <oneLevel :label="'exhibition.Show Status'" :list="statusList" @update="updateStatusFilter"></oneLevel>
  18. </div>
  19. <div v-if="$vuetify.breakpoint.xl">
  20. <multipleLevel :label="'Categories'" :placeholder="'Find Categories...'" :list="categoryList"
  21. :queryItem="categoryQueryFilter" @update="updateCategoryFilter"></multipleLevel>
  22. </div>
  23. <div v-if="$vuetify.breakpoint.xl">
  24. <multipleLevel :label="'Location'" :placeholder="'Find country/city ...'" :list="locationList"
  25. :queryItem="locationQueryFilter" @update="updateLocationFilter"></multipleLevel>
  26. </div>
  27. <div v-if="$vuetify.breakpoint.xl">
  28. <!-- <rating></rating> -->
  29. </div>
  30. </section>
  31. <section class="">
  32. <ExhibitionListCard v-for="(item, index) in exhibitionList" :key="index" :item="item"></ExhibitionListCard>
  33. <div class="tw-mt-[34px] tw-flex tw-justify-end">
  34. <pagination :pageLength="pageLength" @update="updatePage"></pagination>
  35. </div>
  36. </section>
  37. <div v-if="!$vuetify.breakpoint.xl">
  38. <!-- <ShowSidebarFilterModal :statusList="statuses" :locationList="locations" :categoryList="categories"
  39. :statusChecked="selectedStatus" :locationChecked="locationChecked" :categoryChecked="categoryChecked"
  40. :datesChecked="selectedDates" @updateCategoryFilter="updateCategoryFilter"
  41. @updateLocationFilter="updateLocationFilter" @updateStatusFilter="updateStatusFilter"
  42. @updateDateFilter="updateDateFilter">
  43. </ShowSidebarFilterModal> -->
  44. <ShowSidebarFilterModal :statusList="statusList" :locationList="locationList" :categoryList="categoryList"
  45. :statusChecked="selectedStatus"
  46. :datesChecked="selectedDates" @updateCategoryFilter="updateCategoryFilter"
  47. @updateLocationFilter="updateLocationFilter" @updateStatusFilter="updateStatusFilter"
  48. @updateDateFilter="updateDateFilter">
  49. </ShowSidebarFilterModal>
  50. </div>
  51. <loading :isLoading="isPageLoading"></loading>
  52. </div>
  53. </template>
  54. <script>
  55. import Breadcrumbs from "~/components/Breadcrumbs.vue";
  56. import centerMode from "@/components/swiper/centerMode";
  57. import ExhibitionListCard from "~/components/exhibition/ExhibitionListCard.vue";
  58. import DateCard from "~/components/exhibition/DateCard.vue";
  59. import sort from "@/components/newComponent/sort/sort";
  60. import multipleLevel from "@/components/newComponent/filter/multipleLevel";
  61. import oneLevel from "@/components/newComponent/filter/oneLevel";
  62. import rating from "@/components/newComponent/filter/rating.vue";
  63. import pagination from "@/components/newComponent/pagination/pagination.vue";
  64. import ShowSidebarFilterModal from "@/components/exhibition/ShowSidebarFilterModal.vue";
  65. import { XIcon } from "vue-feather-icons";
  66. import loading from "@/components/newComponent/loading/loading.vue";
  67. export default {
  68. name: "ExhibitionView",
  69. auth: false,
  70. meta: {
  71. name: "Exhibition",
  72. },
  73. components: {
  74. centerMode,
  75. Breadcrumbs,
  76. DateCard,
  77. ExhibitionListCard,
  78. XIcon,
  79. sort,
  80. multipleLevel,
  81. oneLevel,
  82. rating,
  83. pagination,
  84. ShowSidebarFilterModal,
  85. loading,
  86. },
  87. data: () => ({
  88. currentPage: 1,
  89. itemsPerPage: 10,
  90. total: 0,
  91. adList: [],
  92. statusList: [],
  93. exhibitionList: [],
  94. locationList: [],
  95. selectedDates: [],
  96. selectedStatus: [],
  97. statusMap: new Map(),
  98. regionMap: new Map(),
  99. countryMap: new Map(),
  100. cityMap: new Map(),
  101. mainCategoryMap: new Map(),
  102. subCategoryMap: new Map(),
  103. selectedMainCategory: [],
  104. selectedSubCategory: [],
  105. selectedRegion: [],
  106. selectedCountry: [],
  107. selectedCity: [],
  108. favoriteSet: new Set(),
  109. categoryList: [],
  110. categoryQueryFilter: "",
  111. locationQueryFilter: "",
  112. width: undefined,
  113. sortType: [
  114. { name: "exhibition.Recommended", value: "Recommended" },
  115. { name: "exhibition.ShowDate", value: "ShowDate" },
  116. { name: "exhibition.ExhibitorCount", value: "ExhibitorCount" },
  117. { name: "exhibition.VisitorCount", value: "VisitorCount" },
  118. ],
  119. sortBy: "ShowDate",
  120. query: ""
  121. }),
  122. async created() {
  123. // console.log("created");
  124. this.isPageLoading = true;
  125. // this.getAdList();
  126. await this.getStatusList();
  127. await this.getLocationList();
  128. await this.getCategoryList();
  129. await this.getFavorite();
  130. await this.getQuery();
  131. if (process.client) {
  132. this.width = window.innerWidth;
  133. }
  134. this.$nextTick(() => {
  135. this.isPageLoading = false;
  136. });
  137. },
  138. async mounted() {
  139. // console.log("mounted");
  140. this.$nextTick(() => {
  141. window.addEventListener("resize", this.onResize);
  142. });
  143. },
  144. beforeDestroy() {
  145. window.removeEventListener("resize", this.onResize);
  146. },
  147. computed: {
  148. result() {
  149. return this.total;
  150. },
  151. pageLength() {
  152. return Math.ceil(this.result / this.itemsPerPage);
  153. },
  154. },
  155. watch: {
  156. $route() {
  157. this.getQuery();
  158. },
  159. },
  160. methods: {
  161. onResize() {
  162. if (process.client) {
  163. this.width = window.innerWidth;
  164. }
  165. },
  166. getAdList() {
  167. this.adList = [
  168. {
  169. id: 'banner_1',
  170. image: require('/assets/img/banner/banner_1.png'),
  171. url: '/service?taiwan=taiwan'
  172. },
  173. {
  174. id: 'banner_2',
  175. image: require('/assets/img/banner/banner_2.png'),
  176. url: 'javascript:void(0);'
  177. },
  178. {
  179. id: 'banner_3',
  180. image: require('/assets/img/banner/banner_3.png'),
  181. url: 'javascript:void(0);'
  182. },
  183. {
  184. id: 'banner_4',
  185. image: require('/assets/img/banner/banner_4.png'),
  186. url: 'javascript:void(0);'
  187. },
  188. {
  189. id: 'banner_5',
  190. image: require('/assets/img/banner/banner_5.png'),
  191. url: 'javascript:void(0);'
  192. }
  193. ]
  194. },
  195. async getStatusList() {
  196. await this.$axios
  197. .get(
  198. `/trending/api/Exhibition/Statuses?Lang=${this.$i18n.localeProperties["langQuery"]}`
  199. )
  200. .then((result) => {
  201. if(result && result.data && result.data.DATA && result.data.DATA.rel){
  202. this.statusList = result.data.DATA.rel;
  203. this.statusList = this.statusList.map((item => {
  204. this.statusMap.set(item.Key, item.Value);
  205. return {
  206. title: item.Value,
  207. key: item.Key,
  208. };
  209. }));
  210. }
  211. })
  212. .catch((err) => {
  213. console.log(err);
  214. });
  215. },
  216. async getCategoryList() {
  217. await this.$axios
  218. .get(
  219. `/trending/api/Exhibition/Categories?Lang=${this.$i18n.localeProperties["langQuery"]}`
  220. )
  221. .then((result) => {
  222. if(result && result.data && result.data.DATA && result.data.DATA.rel){
  223. this.categoryList = result.data.DATA.rel;
  224. this.categoryList = this.categoryList.map((item) => {
  225. this.mainCategoryMap.set(item.CategoryID, item);
  226. item.SubCategoryList = item.SubCategoryList.map(
  227. (children) => {
  228. this.subCategoryMap.set(children.CategoryID, children);
  229. return {
  230. title: children.CategoryName,
  231. key: children.CategoryID,
  232. };
  233. }
  234. );
  235. return {
  236. title: item.CategoryName,
  237. key: item.CategoryID,
  238. children: item.SubCategoryList,
  239. };
  240. });
  241. }
  242. })
  243. .catch((err) => {
  244. console.log(err);
  245. });
  246. },
  247. async getLocationList() {
  248. await this.$axios
  249. .get(
  250. `/trending/api/Exhibition/Locations?Lang=${this.$i18n.localeProperties["langQuery"]}`
  251. )
  252. .then((result) => {
  253. if(result && result.data && result.data.DATA && result.data.DATA.rel){
  254. var vm = this;
  255. vm.locationList = result.data.DATA.rel;
  256. vm.locationList = vm.locationList.map((region) => {
  257. this.regionMap.set(region.RegionID, region);
  258. region.CountryList = region.CountryList.map((country) => {
  259. this.countryMap.set(country.CountryID, country);
  260. country.CityList = country.CityList.map((city) => {
  261. this.cityMap.set(city.CityID, city);
  262. return {
  263. title: city.CityName,
  264. key: city.CityID,
  265. };
  266. });
  267. return {
  268. title: country.CountryName,
  269. key: country.CountryID,
  270. children: country.CityList,
  271. };
  272. });
  273. return {
  274. title: region.RegionName,
  275. key: region.RegionID,
  276. children: region.CountryList,
  277. };
  278. });
  279. return result.data.DATA.rel;
  280. }
  281. })
  282. .catch((err) => {
  283. console.log(err);
  284. });
  285. },
  286. async getExhibitionCard() {
  287. await this.$axios
  288. .get(
  289. `/trending/api/Exhibition/Cards?Lang=${this.$i18n.localeProperties["langQuery"]}` +
  290. `&PageIndex=${this.currentPage}` +
  291. `&PageSize=${this.itemsPerPage}` +
  292. `&RegionIDs=${JSON.stringify(this.selectedRegion)}` +
  293. `&CountryIDs=${JSON.stringify(this.selectedCountry)}` +
  294. `&CityIDs=${JSON.stringify(this.selectedCity)}` +
  295. `&MainCategoryIDs=${JSON.stringify(this.selectedMainCategory)}` +
  296. `&SubCategoryIDs=${JSON.stringify(this.selectedSubCategory)}` +
  297. `&Status=${JSON.stringify(this.selectedStatus)}` +
  298. `&Date=${JSON.stringify(this.selectedDates)}` +
  299. `&Sort=${this.sortBy}` +
  300. `&Query=${this.query}`
  301. )
  302. .then((result) => {
  303. if(result && result.data && result.data.DATA && result.data.DATA.rel){
  304. let data = result.data.DATA.rel
  305. if(data.DataList.length>0){
  306. this.total = data.Total;
  307. this.exhibitionList = data.DataList;
  308. this.setFavorite();
  309. }
  310. }
  311. })
  312. .catch((err) => {
  313. console.log(err);
  314. this.exhibitionList = [];
  315. });
  316. },
  317. async getFavorite() {
  318. this.favoriteSet.clear();
  319. if (this.$auth.loggedIn) {
  320. await this.$axios
  321. .get(
  322. `/trending/api/Favorite/Favorites?Type=Exhibition`
  323. )
  324. .then((result) => {
  325. if(result && result.data && result.data.DATA && result.data.DATA.rel){
  326. let favoriteList = [];
  327. favoriteList = result.data.DATA.rel;
  328. favoriteList.forEach(item => {
  329. this.favoriteSet.add(item.ParentID);
  330. })
  331. }
  332. })
  333. .catch((err) => {
  334. console.log(err);
  335. });
  336. }
  337. },
  338. setFavorite() {
  339. if (this.exhibitionList.length > 0 && this.$auth.loggedIn) {
  340. for (let i = 0; i < this.exhibitionList.length; i++) {
  341. if (this.favoriteSet.has(this.exhibitionList[i].ExhibitionID)) {
  342. this.exhibitionList[i].IsFavorite = "Y";
  343. }
  344. }
  345. }
  346. },
  347. getNewExhibitionCard() {
  348. this.currentPage = 1;
  349. this.query = "";
  350. this.getExhibitionCard();
  351. },
  352. updateSortBy(data) {
  353. this.sortBy = data;
  354. this.getNewExhibitionCard();
  355. },
  356. updatePage(value) {
  357. this.currentPage = value;
  358. window.scrollTo(0,0);
  359. this.getExhibitionCard();
  360. },
  361. updateCategoryFilter(value) {
  362. this.selectedMainCategory = [];
  363. this.selectedSubCategory = [];
  364. value.forEach(key => {
  365. if (this.mainCategoryMap.has(key)) {
  366. this.selectedMainCategory.push(key);
  367. }
  368. if (this.subCategoryMap.has(key)) {
  369. this.selectedSubCategory.push(key);
  370. }
  371. });
  372. this.getNewExhibitionCard();
  373. },
  374. updateLocationFilter(value) {
  375. this.selectedRegion = [];
  376. this.selectedCountry = [];
  377. this.selectedCity = [];
  378. value.forEach(key => {
  379. if (this.regionMap.has(key)) {
  380. this.selectedRegion.push(key);
  381. }
  382. if (this.countryMap.has(key)) {
  383. this.selectedCountry.push(key);
  384. }
  385. if (this.cityMap.has(key)) {
  386. this.selectedCity.push(key);
  387. }
  388. });
  389. this.getNewExhibitionCard();
  390. },
  391. updateStatusFilter(value) {
  392. this.selectedStatus = [];
  393. value.forEach(key => {
  394. if (this.statusMap.has(key)) {
  395. this.selectedStatus.push(key);
  396. }
  397. });
  398. this.getNewExhibitionCard();
  399. },
  400. updateDateFilter(value) {
  401. this.selectedDates = value;
  402. this.getNewExhibitionCard();
  403. },
  404. async getQuery() {
  405. let vm = this;
  406. this.selectedMainCategory = [];
  407. this.selectedSubCategory = [];
  408. this.selectedCountry = [];
  409. this.selectedCity = [];
  410. this.query = "";
  411. if (this.$route.query.category) {
  412. vm.categoryQueryFilter = vm.$route.query.category;
  413. this.selectedMainCategory.push(vm.$route.query.category);
  414. }
  415. if (this.$route.query.subcategory) {
  416. vm.categoryQueryFilter = vm.$route.query.subcategory;
  417. this.selectedSubCategory.push(vm.$route.query.subcategory);
  418. }
  419. if (this.$route.query.country) {
  420. vm.locationQueryFilter = vm.$route.query.country;
  421. this.selectedCountry.push(vm.$route.query.country);
  422. }
  423. if (this.$route.query.city) {
  424. vm.locationQueryFilter = vm.$route.query.city;
  425. this.selectedCity.push(vm.$route.query.city);
  426. }
  427. if (this.$route.query.q) {
  428. this.query = vm.$route.query.q;
  429. }
  430. this.getExhibitionCard();
  431. },
  432. },
  433. };
  434. </script>
  435. <style scoped lang="scss">
  436. .sort-by-text {
  437. max-width: 142px;
  438. >h3 {
  439. border-right: 1px solid #e5e5e5;
  440. }
  441. }
  442. .sort-by-text-sm {
  443. max-width: 112px;
  444. >h3 {
  445. border-right: 1px solid #e5e5e5;
  446. }
  447. }
  448. </style>
  449. <style lang="scss">
  450. .filter-zindex {
  451. z-index: 499 !important;
  452. }
  453. .exhibition-pagination {
  454. .v-pagination {
  455. justify-content: flex-end;
  456. }
  457. .v-pagination__navigation,
  458. .v-pagination__item {
  459. box-shadow: none;
  460. margin: 0;
  461. min-width: 28px;
  462. &.v-pagination__item--active {
  463. color: $primary-orange !important;
  464. }
  465. }
  466. }
  467. .v-breadcrumbs {
  468. padding: 0px;
  469. }
  470. .v-application ul {
  471. padding-left: 0px;
  472. }
  473. </style>