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.

338 lines
11 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
  1. <template>
  2. <div>
  3. <Swiper class="swiper tw-mb-[15px] md:tw-mb-[30px]" :options="swiperOption" @click="slideClicked">
  4. <SwiperSlide v-for="(item, index) in bookingType" :key="index"
  5. :class="['tw-transition-all tw-delay-75 tw-ease-in-out',currentType === item
  6. ? 'tw-flex tw-justify-center tw-py-[13px] tw-border-b-2 tw-border-solid tw-border-0 tw-border-primary-1 tw-text-primary-1 tw-cursor-pointer'
  7. : 'tw-flex tw-justify-center tw-py-[13px] tw-border-b tw-border-base-disable hover:tw-border-b-2 tw-border-solid tw-border-0 tw-border-transparent hover:tw-text-primary-1 tw-cursor-pointer']">
  8. {{ item }}
  9. </SwiperSlide>
  10. </Swiper>
  11. <h4 class="t14 tw-font-bold md:t16 tw-mb-[10px]">{{ $t("Filter") }}</h4>
  12. <div class="element tw-w-fit md:tw-w-fit tw-mb-[15px] md:tw-mb-[30px]">
  13. <ElementSelect :select="{
  14. required: false,
  15. }" :selectList="categories" :default="0" @change="getCategory" :defaultOptionMsg="$t('All Categories')">
  16. </ElementSelect>
  17. </div>
  18. <UserServiceItem v-for="(item, index) in bookingList" :key="index" :info="item" @contact-us="activeContactUs"
  19. @upload-remittance-slip="activeUploadSlip"></UserServiceItem>
  20. <!-- <div v-if="bookingList.length < 1" class="tw-mt-[5px] tw-mb-[60px]">
  21. <div class="tw-flex tw-justify-center tw-mt-[60px] tw-mb-[30px]">
  22. <img :src="emptyImg" alt="" class="tw-h-[142px] tw-w-[160px]" />
  23. </div>
  24. <div class="tw-text-center tw-body-3 tw-text-neutrals-800 tw-mb-[30px]">
  25. {{
  26. currentType === "全部"
  27. ? $t(`No Bookings yet ...`)
  28. : $t(`You don't have any ${currentType} bookings`)
  29. }}
  30. </div>
  31. <div class="tw-flex tw-justify-center tw-mb-[30px]">
  32. <button
  33. class="tw-transition tw-justify-center tw-items-center tw-btn-md tw-text-white tw-bg-primary-1 tw-px-[30px] tw-py-[8.5px] tw-rounded-xl tw-w-fit tw-h-fit">
  34. {{ $t("Explore with ShowEasy") }}
  35. </button>
  36. </div>
  37. </div> -->
  38. <!-- <div v-if="bookingList.length < 1"
  39. class="tw-mb-[60px] tw-py-[60px] tw-pl-[10px] md:tw-body-2">
  40. {{ $t("Sorry, we couldn't find anything for ") + searchQuery }}
  41. {{ $t("Sorry, we couldn't find anything for ") }}
  42. </div> -->
  43. <!-- <div class="tw-flex tw-justify-end" v-if="renderList.length > 0">
  44. <pagination :pageLength="pageLength" @update="updateCurrentPage"></pagination>
  45. </div> -->
  46. <ContactUsModal :ContactUs="contactUs"></ContactUsModal>
  47. <UploadRemittanceSlipModal></UploadRemittanceSlipModal>
  48. </div>
  49. </template>
  50. <script>
  51. import ElementSelect from "@/components/user/userSelect.vue";
  52. import UserServiceItem from "./userServiceItem.vue";
  53. import pagination from "@/components/newComponent/pagination/pagination.vue";
  54. import ContactUsModal from "@/components/booking/Modal/ContactUsModal.vue";
  55. import UploadRemittanceSlipModal from "@/components/booking/Modal/UploadRemittanceSlipModal.vue";
  56. import { Swiper, SwiperSlide } from "vue-awesome-swiper";
  57. export default {
  58. components: {
  59. ElementSelect,
  60. UserServiceItem,
  61. Swiper,
  62. SwiperSlide,
  63. pagination,
  64. ContactUsModal,
  65. UploadRemittanceSlipModal,
  66. },
  67. props: {
  68. // searchQuery: {
  69. // type: String,
  70. // },
  71. width: {
  72. type: Number
  73. },
  74. userData: {
  75. type: Object
  76. }
  77. },
  78. data() {
  79. return {
  80. apiUrl: process.env.SERVICE_CONSOLE,
  81. bookingType: [
  82. this.$t("booking.All"),
  83. this.$t("booking.Unpaid"),
  84. this.$t("booking.Processing"),
  85. this.$t("booking.Completed"),
  86. this.$t("booking.Cancelled"),
  87. ],
  88. previewImage:[],
  89. currentType: "All",
  90. filterList: ["All categories"],
  91. categoryList: [],
  92. categories: [],
  93. emptyImg: require("~/assets/img/companyEmpty.png"),
  94. contactUs: {
  95. Phone: "info@showeasy.com",
  96. Mail: "+886-2-2725-5000",
  97. },
  98. swiperOption: {
  99. slidesPerView: 3,
  100. breakpoints: {
  101. 768: {
  102. slidesPerView: 5,
  103. },
  104. },
  105. },
  106. apiEndPoint: process.env.SERVICE_CONSOLE,
  107. perPageItems: 6,
  108. currentPage: 1,
  109. selectedCategory: 0,
  110. bookingList: [],
  111. bookingStatus: [],
  112. subCategoryIDs:[],
  113. categoryValue: "",
  114. };
  115. },
  116. mounted() {
  117. this.fetchCategory();
  118. },
  119. // watch: {
  120. // searchQuery: {
  121. // handler: function () {
  122. // this.
  123. // },
  124. // },
  125. // },
  126. created(){
  127. this.getUserOrderList();
  128. },
  129. computed: {
  130. // bookingFilter() {
  131. // const categoryList = this.filterByCategory(
  132. // this.bookingList,
  133. // this.selectedCategory
  134. // );
  135. // const tabList = this.filterByTab(categoryList, this.currentType);
  136. // //const searchList = this.filterByQuery(tabList, this.searchQuery);
  137. // //return searchList;
  138. // },
  139. renderList() {
  140. // for (let i in this.bookingList) {
  141. // this.getServiceData(this.bookingList[i], i);
  142. // }
  143. //return this.sliceRenderList(this.bookingFilter);
  144. },
  145. result() {
  146. return this.bookingFilter.length;
  147. },
  148. pageLength() {
  149. return Math.ceil(this.result / this.perPageItems);
  150. },
  151. },
  152. methods: {
  153. getCategory(value){
  154. console.log(value);
  155. this.categoryValue = value;
  156. if(this.categoryValue == 0){
  157. this.subCategoryIDs = [];
  158. }else{
  159. this.subCategoryIDs.push(value);
  160. }
  161. },
  162. slideClicked(swiper) {
  163. this.currentType = this.bookingType[swiper.clickedIndex];
  164. if(this.currentType == "全部"){
  165. this.bookingStatus = [];
  166. }else if(this.currentType == "未付款"){
  167. this.bookingStatus = ["Unpaid"];
  168. }else if(this.currentType == "訂單處理中"){
  169. this.bookingStatus = ["Processing"];
  170. }else if(this.currentType == "訂單完成"){
  171. this.bookingStatus = ["Completed"];
  172. }else if(this.currentType == "訂單取消"){
  173. this.bookingStatus = ["Cancelled"];
  174. }else{
  175. this.bookingStatus = [];
  176. }
  177. this.getUserOrderList();
  178. },
  179. activeContactUs() {
  180. this.$modal.show("ContactUs");
  181. },
  182. activeUploadSlip() {
  183. this.$modal.show("UploadRemittanceSlip");
  184. },
  185. fetchCategory() {
  186. this.$axios
  187. .get(`/trending/api/BookingOnline/GetBookingCategory?LangType=${this.$i18n.localeProperties["langQuery"]}`)
  188. .then((response) => {
  189. //console.log(JSON.stringify(response));
  190. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  191. let data = response.data.DATA.rel
  192. if(data){
  193. this.categories = data;
  194. this.categories = this.categories.map((item) => {
  195. return {
  196. id: item.CategoryID,
  197. name: item.CategoryName,
  198. };
  199. });
  200. // const initial = {
  201. // id: "999",
  202. // name: this.$t("userProfile.allCategory"),
  203. // };
  204. // this.categories.splice(0, 0, initial);
  205. //this.getCategoryList();
  206. }
  207. }
  208. })
  209. .catch((error) => {
  210. console.log(error);
  211. });
  212. },
  213. // getCategoryList() {
  214. // const userCategory = [
  215. // ...new Set(
  216. // this.bookingList.map((item) => {
  217. // return item.categoryId;
  218. // })
  219. // ),
  220. // ];
  221. // this.bookingList = this.bookingList.map((item) => {
  222. // item.categoryName =(this.categories[item.categoryId] && this.categories[item.categoryId].name ) ? this.categories[item.categoryId].name : "";
  223. // return item;
  224. // });
  225. // for (const index of userCategory) {
  226. // this.categoryList.push(this.categories[index]);
  227. // }
  228. // },
  229. // updateCategory(categoryId) {
  230. // this.selectedCategory = Number(categoryId);
  231. // },
  232. filterByCategory(data, categoryId) {
  233. if (categoryId === 0) return data;
  234. return data.filter((item) => item.categoryId === categoryId);
  235. },
  236. // filterByTab(data, type) {
  237. // switch (type) {
  238. // case "All":
  239. // this.currentPage = 1;
  240. // return data;
  241. // case "Unpaid":
  242. // this.currentPage = 1;
  243. // return data.filter((item) => item.order_payment[item.order_payment.length-1].payment_status === 0);
  244. // case "Completed":
  245. // this.currentPage = 1;
  246. // return data.filter((item) => item.order_payment[item.order_payment.length-1].payment_status === 2);
  247. // case "Cancelled":
  248. // this.currentPage = 1;
  249. // return data.filter((item) => item.order_payment[item.order_payment.length-1].payment_status === -1);
  250. // case "Processing":
  251. // this.currentPage = 1;
  252. // return data.filter(
  253. // (item) =>
  254. // item.order_payment[item.order_payment.length-1].payment_status !== -1 &&
  255. // item.order_payment[item.order_payment.length-1].payment_status !== 2 &&
  256. // item.order_payment[item.order_payment.length-1].payment_status !== 0
  257. // );
  258. // default:
  259. // return data;
  260. // }
  261. // },
  262. // updateCurrentPage(value) {
  263. // this.currentPage = value;
  264. // },
  265. // sliceRenderList(data) {
  266. // return data.slice(
  267. // (this.currentPage - 1) * this.perPageItems,
  268. // this.currentPage * this.perPageItems
  269. // );
  270. // },
  271. // filterByQuery(data, query) {
  272. // if (query.length < 1) return data;
  273. // return data.filter((item) => {
  274. // return (
  275. // item.service_name.toLowerCase().includes(query.toLowerCase()) ||
  276. // item.order_display_id.toLowerCase().includes(query.toLowerCase()) ||
  277. // item.partnerName.toLowerCase().includes(query.toLowerCase()) ||
  278. // item.categoryName.toLowerCase().includes(query.toLowerCase())
  279. // );
  280. // });
  281. // },
  282. async getUserOrderList() {
  283. this.$axios
  284. .get(`/trending/api/BookingOnline/BookingCardList?SubCategoryIDs=${JSON.stringify(this.subCategoryIDs)}&BookingStatuses=${JSON.stringify(this.bookingStatus)}&PaymentStatuses&Lang=${this.$i18n.localeProperties["langQuery"]}`)
  285. .then((response) => {
  286. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  287. let data = response.data.DATA.rel
  288. if(data){
  289. this.bookingList = data;
  290. }
  291. }
  292. })
  293. .catch((error) => {
  294. console.log(error);
  295. });
  296. },
  297. // async getServiceData(object,i) {
  298. // this.$axios
  299. // .get(
  300. // `${this.apiUrl}/user-services/content?service_id=${object.service_id}&lang_code=${this.$i18n.localeProperties["langQuery"]}&currency=${object.currency}`
  301. // )
  302. // .then((res) => {
  303. // this.bookingList[i].preview_image = res.data.preview_image
  304. // })
  305. // .catch((error) => console.log(error));
  306. // },
  307. },
  308. };
  309. </script>
  310. <style lang="scss" scoped>
  311. ::-webkit-scrollbar {
  312. display: none;
  313. }
  314. :deep() {
  315. // .v-pagination__navigation{
  316. // background-color: #e5e5e5;
  317. // }
  318. .v-pagination>li>.v-pagination__item {
  319. background-color: inherit;
  320. }
  321. .v-pagination__navigation {
  322. background-color: inherit !important;
  323. }
  324. .v-pagination__navigation--disabled {
  325. opacity: 0;
  326. }
  327. }
  328. </style>