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.

196 lines
6.9 KiB

2 years ago
  1. <template>
  2. <div
  3. class="tw-px-[15px] tw-mb-[60px] md:tw-px-[60px] xl:tw-max-w-screen-xl xl:tw-mx-auto xl:tw-grid xl:tw-grid-cols-1">
  4. <section class="section section-one tw-my-[40px]">
  5. <StepInfo :step_active="step"></StepInfo>
  6. </section>
  7. <section class="section section-two tw-w-full xl:tw-max-w-[822px] xl:tw-mx-auto xl:tw-mt-[40px]">
  8. <PaymentStatus v-if="methoodType == 'Credit Card'" :status="status"></PaymentStatus>
  9. <WireTransferInfo v-if="methoodType == 'Remittance'"></WireTransferInfo>
  10. <DoneTotalPrice v-if="(methoodType == 'Remittance' || status == 'success') && orderStatus.length > 0"
  11. :subTotal="finalPrice" :orderStatus="orderStatus"></DoneTotalPrice>
  12. <div class="element tw-flex tw-justify-center tw-items-center xl:tw-justify-end tw-mt-[30px]">
  13. <a class="tw-transition tw-btn-md tw-no-underline tw-text-neutrals-0 tw-bg-primary-1 tw-px-[30px] tw-py-[9.5px] tw-rounded-2xl hover:tw-bg-primary-2"
  14. href="#">
  15. {{ $t("Booking Details") }}
  16. </a>
  17. </div>
  18. <div class="element tw-hidden xl:tw-flex xl:tw-justify-center xl:tw-items-center xl:tw-mt-[12px]">
  19. <button v-if="status == 'success'" @click="print()"
  20. class="print tw-transition tw-flex tw-justify-center tw-items-center tw-btn-md tw-text-primary-1 tw-bg-neutrals-0 tw-border tw-border-solid tw-border-primary-1 tw-px-[30px] tw-py-[13.5px] tw-rounded-xl hover:tw-bg-primary-3">
  21. {{ $t("Print this page") }}
  22. </button>
  23. </div>
  24. </section>
  25. <section class="section section-three tw-w-full tw-mt-[60px] xl:tw-max-w-[822px] xl:tw-mx-auto">
  26. <DoneBookingDetails v-if="status == 'success'" :info="content" :orderStatus="orderStatus"
  27. :totalPrice="finalPrice"></DoneBookingDetails>
  28. </section>
  29. </div>
  30. </template>
  31. <script>
  32. import StepInfo from "@/components/service/StepInfo";
  33. import BookingInfoItem from "@/components/service/BookingInfoItem";
  34. import PurchaserInfo from "@/components/service/PurchaserInfo";
  35. import ChooseMethod from "@/components/service/ChooseMethod";
  36. import PriceInfo from "@/components/service/PriceInfo";
  37. import TotalPrice from "@/components/service/TotalPrice";
  38. import DoneTotalPrice from "@/components/service/DoneTotalPrice";
  39. import PaymentStatus from "@/components/service/PaymentStatus";
  40. import WireTransferInfo from "@/components/service/WireTransferInfo";
  41. import DoneBookingDetails from "@/components/service/DoneBookingDetails";
  42. export default {
  43. name: "service",
  44. layout: "service",
  45. auth: false,
  46. components: {
  47. StepInfo,
  48. BookingInfoItem,
  49. PurchaserInfo,
  50. ChooseMethod,
  51. PriceInfo,
  52. TotalPrice,
  53. DoneTotalPrice,
  54. PaymentStatus,
  55. WireTransferInfo,
  56. DoneBookingDetails,
  57. },
  58. data() {
  59. return {
  60. apiUrl: process.env.SERVICE_CONSOLE,
  61. step: "3",
  62. subTotal: 5510,
  63. //Credit Card,Remittance
  64. methoodType: "",
  65. serviceId: "",
  66. status: "success",
  67. content: {
  68. preview_image: "",
  69. country: null,
  70. city: null,
  71. name: "",
  72. highlights: "",
  73. details: "",
  74. cancellation_policy: "",
  75. saved: false,
  76. confirmation_time: 24,
  77. supplier: null,
  78. available_sections: null,
  79. timeStatus: '',
  80. dateStatus: '',
  81. times: [],
  82. start: '',
  83. end: '',
  84. faq: null,
  85. packages: [],
  86. additionalServices: [],
  87. },
  88. orderStatus: {},
  89. totalPrice: 0,
  90. };
  91. },
  92. async created() {
  93. // await this.getStatus();
  94. // await this.getServiceData();
  95. // await this.getPackages();
  96. // await this.getAdditionalServices();
  97. },
  98. mounted() { },
  99. computed: {
  100. currency() {
  101. return this.orderStatus.currency;
  102. },
  103. finalPrice() {
  104. return Number(this.totalPrice.toFixed(2));
  105. },
  106. },
  107. methods: {
  108. async getStatus() {
  109. await this.$axios
  110. .get(
  111. `/order/${this.$route.params.id}?jwt=${this.$auth.$storage.getUniversal("jwt").token
  112. }`
  113. )
  114. .then((result) => {
  115. this.serviceId = result.data[0].service_id;
  116. this.orderStatus = result.data[0];
  117. this.methoodType = result.data[0].order_payment[0].payment_type;
  118. this.orderStatus.order_item.forEach((item) => {
  119. this.totalPrice += Math.round(item.price * item.quantity * 100) / 100;
  120. })
  121. return result.data;
  122. })
  123. .catch((err) => {
  124. console.log(err);
  125. });
  126. },
  127. async getServiceData() {
  128. await this.$axios
  129. .get(
  130. `${this.apiUrl}/user-services/content?service_id=${this.serviceId}&lang_code=${this.$i18n.localeProperties["langQuery"]}&currency=${this.currency}`
  131. )
  132. .then((res) => {
  133. this.content.preview_image = res.data.preview_image;
  134. this.content.name = res.data.name;
  135. this.content.country = res.data.country;
  136. this.content.city = res.data.city;
  137. this.content.highlights = res.data.highlights;
  138. this.content.details = res.data.details;
  139. this.content.cancellation_policy = res.data.cancellation_policy;
  140. this.content.supplier = res.data.supplier;
  141. this.content.available_sections = res.data.available_sections;
  142. this.content.times = res.data.available_sections.times;
  143. this.content.timeStatus = res.data.available_sections.time_status;
  144. this.content.dateStatus = res.data.available_sections.date_status;
  145. this.content.start = res.data.available_sections.start;
  146. this.content.end = res.data.available_sections.end;
  147. this.content.payment_currency = res.data.payment_currency;
  148. })
  149. .catch((error) => console.log(error));
  150. },
  151. async getPackages() {
  152. await this.$axios
  153. .get(
  154. `${this.apiUrl}/user-services/packages?service_id=${this.serviceId}&lang_code=${this.$i18n.localeProperties["langQuery"]}&currency=${this.currency}`
  155. )
  156. .then((res) => {
  157. this.content.packages = res.data;
  158. this.packageId = res.data[0].package_id ? res.data[0].package_id : "";
  159. })
  160. .catch((error) => console.log(error));
  161. },
  162. async getAdditionalServices() {
  163. await this.$axios
  164. .get(
  165. `${this.apiUrl}/user-services/additional?service_id=${this.serviceId}&lang_code=${this.$i18n.localeProperties["langQuery"]}&currency=${this.currency}`
  166. )
  167. .then((res) => {
  168. this.content.additionalServices =
  169. res.data.services == [] ? null : res.data;
  170. })
  171. .catch((error) => console.log(error));
  172. },
  173. print() {
  174. if (process.browser) {
  175. // window.print();
  176. }
  177. }
  178. }
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. .print {
  183. &::before {
  184. content: "";
  185. display: inline-block;
  186. position: relative;
  187. background-image: url("~/assets/svg/print.svg");
  188. background-position: center;
  189. background-repeat: no-repeat;
  190. background-size: cover;
  191. width: 20px;
  192. height: 20px;
  193. margin-right: 14px;
  194. }
  195. }
  196. </style>