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.

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