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.

222 lines
4.7 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
  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">
  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]" v-for="(item,index) in payTypes" :key="index">
  43. <input
  44. :id="item.id"
  45. type="radio"
  46. :value="item.id"
  47. v-model="method"
  48. @change="selectRadio()"
  49. />
  50. <label :for="item.id" class="t16 tw-font-normal"
  51. ><span>{{ item.name }}</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. payTypes:{
  73. type: Array
  74. },
  75. chooseMethod: {
  76. type: String,
  77. }
  78. },
  79. data() {
  80. return {
  81. show: false,
  82. disabled: false,
  83. completed: false,
  84. method: null,
  85. cardNumber: "",
  86. expirationDate: "",
  87. cvc: "",
  88. validation: {
  89. cardNumber: true,
  90. expirationDate: true,
  91. cvc: true,
  92. },
  93. };
  94. },
  95. filters: {
  96. formatCardNumber(value) {
  97. return value ? value.match(/.{1,4}/g).join(" ") : "";
  98. },
  99. },
  100. watch: {
  101. purchaserInfo_Validation: {
  102. handler: function () {
  103. if (this.purchaserInfo_Validation) {
  104. this.show = true;
  105. } else {
  106. this.show = false;
  107. }
  108. },
  109. },
  110. chooseMethod:{
  111. handler: function () {
  112. if (this.chooseMethod!="") {
  113. this.method = this.chooseMethod;
  114. this.$emit("paymentType", this.method);
  115. }
  116. },
  117. }
  118. },
  119. // async created(){
  120. // this.method = this.payTypes.length > 0 ? this.payTypes[0].id : null;
  121. // },
  122. methods: {
  123. updateCardNumber(e) {
  124. this.cardNumber = e.target.value.replace(/ /g, "");
  125. },
  126. selectRadio() {
  127. this.$emit("paymentType", this.method);
  128. // if (this.method == "Credit Card") {
  129. // this.$refs.ecpay.init();
  130. // }
  131. },
  132. updateToken(item) {
  133. this.$emit("update", item);
  134. },
  135. },
  136. };
  137. </script>
  138. <style lang="scss" scoped>
  139. .collapse {
  140. &::before {
  141. content: "";
  142. display: inline-block;
  143. position: relative;
  144. left: 0;
  145. top: 0;
  146. background-image: url("~/assets/svg/down-arrow.svg");
  147. background-repeat: no-repeat;
  148. background-position: center;
  149. background-size: 100%;
  150. width: 16px;
  151. height: 10px;
  152. margin-right: 40px;
  153. transform: rotate(-90deg);
  154. transition: all 0.2s linear;
  155. }
  156. &.disabled {
  157. pointer-events: none;
  158. &::before {
  159. background-image: url("~/assets/svg/down-arrow-disabled.svg");
  160. }
  161. }
  162. &.show {
  163. &::before {
  164. transform: rotate(0);
  165. transition: all 0.2s linear;
  166. }
  167. }
  168. }
  169. .card-icon {
  170. background-repeat: no-repeat;
  171. background-position: center;
  172. background-size: 100%;
  173. }
  174. .icon {
  175. &--visa {
  176. background-image: url("~/assets/img/credit-card/Visa.png");
  177. }
  178. &--union-pay {
  179. background-image: url("~/assets/img/credit-card/UnionPay.png");
  180. }
  181. &--mastercard {
  182. background-image: url("~/assets/img/credit-card/Mastercard.png");
  183. }
  184. &--jcb {
  185. background-image: url("~/assets/img/credit-card/JCB.png");
  186. }
  187. }
  188. .bounce-enter-active {
  189. animation: bounce-in 0.3s ease-out;
  190. }
  191. .bounce-leave-active {
  192. animation: bounce-in 0.3s cubic-bezier(1, 0.5, 0.8, 1) reverse;
  193. }
  194. @keyframes bounce-in {
  195. 0% {
  196. opacity: 0;
  197. transform: translateY(-10px);
  198. }
  199. 50% {
  200. opacity: 0.5;
  201. transform: translateY(-5px);
  202. }
  203. 100% {
  204. opacity: 1;
  205. transform: translateY(0);
  206. }
  207. }
  208. </style>