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.

205 lines
4.3 KiB

2 years ago
  1. <template>
  2. <div class="choose-method tw-p-5 tw-mb-[20px] tw-bg-neutrals-0 tw-rounded-xl">
  3. <h3
  4. :class="[
  5. 'collapse',
  6. 't16',
  7. 'tw-relative',
  8. 'tw-cursor-pointer',
  9. 'xl:tw-text-[18px]',
  10. show ? 'show' : 'hide',
  11. disabled ? 'disabled' : '',
  12. disabled ? 'tw-text-neutrals-300' : 'tw-text-black',
  13. ]"
  14. @click="show = !show"
  15. >
  16. {{ $t("Choose payment method") }}
  17. </h3>
  18. <Transition name="bounce">
  19. <div v-show="show" class="tw-mt-[21px] md:tw-ml-[60px]">
  20. <div class="element tw-w-max tw-flex tw-items-center">
  21. <input
  22. id="CreditCard"
  23. type="radio"
  24. value="Credit Card"
  25. v-model="method"
  26. @change="selectRadio()"
  27. />
  28. <label for="CreditCard" class="t16 tw-font-normal"
  29. ><span>{{ $t("Credit card") }}</span></label
  30. >
  31. </div>
  32. <Transition name="bounce">
  33. <div v-show="method == 'Credit Card'">
  34. <ecpay
  35. ref="ecpay"
  36. :orderNo="orderNo"
  37. :method="method"
  38. @updateToken="updateToken($event)"
  39. ></ecpay>
  40. </div>
  41. </Transition>
  42. <div class="element tw-mt-[15px]">
  43. <input
  44. id="Remittance"
  45. type="radio"
  46. value="Remittance"
  47. v-model="method"
  48. @change="selectRadio()"
  49. />
  50. <label for="Remittance" class="t16 tw-font-normal"
  51. ><span>{{ $t("Remittance") }}</span></label
  52. >
  53. </div>
  54. </div>
  55. </Transition>
  56. </div>
  57. </template>
  58. <script>
  59. import ecpay from "@/components/service/ecpay.vue";
  60. export default {
  61. name: "ChooseMethod",
  62. components: {
  63. ecpay,
  64. },
  65. props: {
  66. orderNo: {
  67. type: String,
  68. },
  69. purchaserInfo_Validation: {
  70. type: Boolean,
  71. },
  72. },
  73. data() {
  74. return {
  75. show: false,
  76. disabled: false,
  77. completed: false,
  78. method: null,
  79. cardNumber: "",
  80. expirationDate: "",
  81. cvc: "",
  82. validation: {
  83. cardNumber: true,
  84. expirationDate: true,
  85. cvc: true,
  86. },
  87. };
  88. },
  89. filters: {
  90. formatCardNumber(value) {
  91. return value ? value.match(/.{1,4}/g).join(" ") : "";
  92. },
  93. },
  94. watch: {
  95. purchaserInfo_Validation: {
  96. handler: function () {
  97. if (this.purchaserInfo_Validation) {
  98. this.show = true;
  99. } else {
  100. this.show = false;
  101. }
  102. },
  103. },
  104. },
  105. methods: {
  106. updateCardNumber(e) {
  107. this.cardNumber = e.target.value.replace(/ /g, "");
  108. },
  109. selectRadio() {
  110. this.$emit("paymentType", this.method);
  111. if (this.method == "Credit Card") {
  112. this.$refs.ecpay.init();
  113. }
  114. },
  115. updateToken(item) {
  116. this.$emit("update", item);
  117. },
  118. },
  119. };
  120. </script>
  121. <style lang="scss" scoped>
  122. .collapse {
  123. &::before {
  124. content: "";
  125. display: inline-block;
  126. position: relative;
  127. left: 0;
  128. top: 0;
  129. background-image: url("~/assets/svg/down-arrow.svg");
  130. background-repeat: no-repeat;
  131. background-position: center;
  132. background-size: 100%;
  133. width: 16px;
  134. height: 10px;
  135. margin-right: 40px;
  136. transform: rotate(-90deg);
  137. transition: all 0.2s linear;
  138. }
  139. &.disabled {
  140. pointer-events: none;
  141. &::before {
  142. background-image: url("~/assets/svg/down-arrow-disabled.svg");
  143. }
  144. }
  145. &.show {
  146. &::before {
  147. transform: rotate(0);
  148. transition: all 0.2s linear;
  149. }
  150. }
  151. }
  152. .card-icon {
  153. background-repeat: no-repeat;
  154. background-position: center;
  155. background-size: 100%;
  156. }
  157. .icon {
  158. &--visa {
  159. background-image: url("~/assets/img/credit-card/Visa.png");
  160. }
  161. &--union-pay {
  162. background-image: url("~/assets/img/credit-card/UnionPay.png");
  163. }
  164. &--mastercard {
  165. background-image: url("~/assets/img/credit-card/Mastercard.png");
  166. }
  167. &--jcb {
  168. background-image: url("~/assets/img/credit-card/JCB.png");
  169. }
  170. }
  171. .bounce-enter-active {
  172. animation: bounce-in 0.3s ease-out;
  173. }
  174. .bounce-leave-active {
  175. animation: bounce-in 0.3s cubic-bezier(1, 0.5, 0.8, 1) reverse;
  176. }
  177. @keyframes bounce-in {
  178. 0% {
  179. opacity: 0;
  180. transform: translateY(-10px);
  181. }
  182. 50% {
  183. opacity: 0.5;
  184. transform: translateY(-5px);
  185. }
  186. 100% {
  187. opacity: 1;
  188. transform: translateY(0);
  189. }
  190. }
  191. </style>