설명 없음

index.tsx 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. import React, { PureComponent } from "react";
  2. import classnames from "classnames";
  3. import { FormattedMessage } from "react-intl";
  4. import iconAlipay from "../assets/kcxq_popovers_icon_alipay@2x.png";
  5. import iconWechatpay from "../assets/kcxq_popovers_icon_wechatpay@2x.png";
  6. import iconPaypal from "../assets/kcxq_popovers_icon_paypal@2x.png";
  7. import mobileIconAlipay from "../assets/payment_btn_pay_alipay@2x.png";
  8. import mobileIconWechatpay from "../assets/payment_btn_pay_wechatpay@2x.png";
  9. import mobileIconPaypal from "../assets/payment_btn_pay_paypal@2x.png";
  10. import styles from "./PayPlatformOptions.less";
  11. type PAY_CHANNEL_VALUE =
  12. | "PAYPAL_PAYPAL"
  13. | "ALI_WEB"
  14. | "ALI_WAP"
  15. | "WX_WAP"
  16. | "WX_NATIVE";
  17. type PAY_CHANNEL_TYPE = {
  18. PAYPAL: PAY_CHANNEL_VALUE;
  19. ALI_WEB: PAY_CHANNEL_VALUE;
  20. ALI_WAP: PAY_CHANNEL_VALUE;
  21. WX_WAP: PAY_CHANNEL_VALUE;
  22. WX_NATIVE: PAY_CHANNEL_VALUE;
  23. };
  24. type Props = {
  25. payitem: PAY_CHANNEL_VALUE;
  26. onPayItemChange: (value: PAY_CHANNEL_VALUE) => void;
  27. isMobile: boolean;
  28. size: "small" | "normal" | "large";
  29. withTitle: boolean;
  30. locale: "zh" | "en";
  31. };
  32. export const PAY_CHANNEL: PAY_CHANNEL_TYPE = {
  33. PAYPAL: "PAYPAL_PAYPAL", // PAYPAL_LIVE
  34. ALI_WEB: "ALI_WEB",
  35. ALI_WAP: "ALI_WAP",
  36. WX_WAP: "WX_WAP",
  37. WX_NATIVE: "WX_NATIVE"
  38. };
  39. class PayPlatformOptions extends PureComponent<Props, {}> {
  40. render() {
  41. const {
  42. payitem,
  43. onPayItemChange,
  44. isMobile = false,
  45. size = "normal",
  46. withTitle = true,
  47. locale = "zh"
  48. } = this.props;
  49. let titleDOM = null;
  50. if (withTitle) {
  51. titleDOM = (
  52. <div className={styles.label}>
  53. <FormattedMessage id="pay.channel.select.text" />
  54. </div>
  55. );
  56. }
  57. if (isMobile) {
  58. return (
  59. <div>
  60. {titleDOM}
  61. <div
  62. className={classnames(styles["payment-method-box"], {
  63. [styles.mobile]: isMobile
  64. })}
  65. >
  66. <div className={styles.flexContainer}>
  67. <div className={styles.flexItem}>
  68. <div
  69. className={classnames(
  70. {
  71. [styles.payitem]: true,
  72. [styles.active]: payitem === PAY_CHANNEL.ALI_WEB,
  73. [styles.small]: size === "small"
  74. },
  75. styles[locale]
  76. )}
  77. onClick={() => {
  78. onPayItemChange(PAY_CHANNEL.ALI_WEB);
  79. }}
  80. >
  81. <img
  82. src={mobileIconAlipay}
  83. alt="alipay"
  84. className={styles["payment-method"]}
  85. />
  86. <div className={styles.platformName}>
  87. <FormattedMessage id="pay.channel.ali" />
  88. </div>
  89. </div>
  90. </div>
  91. <div className={styles.flexItem}>
  92. <div
  93. className={classnames(
  94. {
  95. [styles.payitem]: true,
  96. [styles.active]: payitem === PAY_CHANNEL.WX_NATIVE,
  97. [styles.small]: size === "small"
  98. },
  99. styles[locale]
  100. )}
  101. onClick={() => {
  102. onPayItemChange(PAY_CHANNEL.WX_NATIVE);
  103. }}
  104. >
  105. <img
  106. src={mobileIconWechatpay}
  107. alt="wechatpay"
  108. className={styles["payment-method"]}
  109. />
  110. <div className={styles.platformName}>
  111. <FormattedMessage id="pay.channel.wechat" />
  112. </div>
  113. </div>
  114. </div>
  115. <div className={styles.flexItem}>
  116. <div
  117. className={classnames(
  118. {
  119. [styles.payitem]: true,
  120. [styles.active]: payitem === PAY_CHANNEL.PAYPAL,
  121. [styles.small]: size === "small"
  122. },
  123. styles[locale]
  124. )}
  125. onClick={() => {
  126. onPayItemChange(PAY_CHANNEL.PAYPAL);
  127. }}
  128. >
  129. <img
  130. src={mobileIconPaypal}
  131. alt="paypal"
  132. className={styles["payment-method"]}
  133. />
  134. <div className={styles.platformName}>
  135. <FormattedMessage id="pay.channel.paypal" />
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. );
  143. }
  144. return (
  145. <div>
  146. {titleDOM}
  147. <div className={styles["payment-method-box"]}>
  148. <div className={styles.flexContainer}>
  149. <div className={styles.flexItem}>
  150. <div
  151. className={classnames(
  152. {
  153. [styles.payitem]: true,
  154. [styles.active]: payitem === PAY_CHANNEL.ALI_WEB,
  155. [styles.small]: size === "small"
  156. },
  157. styles[locale]
  158. )}
  159. onClick={() => {
  160. onPayItemChange(PAY_CHANNEL.ALI_WEB);
  161. }}
  162. >
  163. <span className={styles["payment-method-before"]} />
  164. <img
  165. src={iconAlipay}
  166. alt="alipay"
  167. className={styles["payment-method"]}
  168. />
  169. </div>
  170. </div>
  171. <div className={styles.flexItem}>
  172. <div
  173. className={classnames(
  174. {
  175. [styles.payitem]: true,
  176. [styles.active]: payitem === PAY_CHANNEL.WX_NATIVE,
  177. [styles.small]: size === "small"
  178. },
  179. styles[locale]
  180. )}
  181. onClick={() => {
  182. onPayItemChange(PAY_CHANNEL.WX_NATIVE);
  183. }}
  184. >
  185. <span className={styles["payment-method-before"]} />
  186. <img
  187. src={iconWechatpay}
  188. alt="wechatpay"
  189. className={styles["payment-method"]}
  190. />
  191. </div>
  192. </div>
  193. <div className={styles.flexItem}>
  194. <div
  195. className={classnames(
  196. {
  197. [styles.payitem]: true,
  198. [styles.active]: payitem === PAY_CHANNEL.PAYPAL,
  199. [styles.small]: size === "small"
  200. },
  201. styles[locale]
  202. )}
  203. onClick={() => {
  204. onPayItemChange(PAY_CHANNEL.PAYPAL);
  205. }}
  206. >
  207. <span className={styles["payment-method-before"]} />
  208. <img
  209. src={iconPaypal}
  210. alt="paypal"
  211. className={styles["payment-method"]}
  212. />
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. </div>
  218. );
  219. }
  220. }
  221. export default PayPlatformOptions;