DialogPayPerUse.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import React, { useEffect, useState } from 'react';
  2. import { Modal, View, StyleSheet } from 'react-native';
  3. import apiPayment from '../../api/apiPayment';
  4. import Button from '../../components/Button';
  5. import Dialog from '../../components/Dialog';
  6. import TextView from '../../components/TextView';
  7. import { i18nUtil } from '../../i18n';
  8. const DialogPayPerUse = ({
  9. amount="",
  10. visible,
  11. onClose
  12. }) => {
  13. const [content, setContent] = useState();
  14. useEffect(() => {
  15. if (i18nUtil.isChinese()) {
  16. setContent($t("payment.tipsPayPerUseAmount").replace("{mm}", amount));
  17. } else {
  18. apiPayment.getPayPerUseAlter().then(res => {
  19. if (res.data) {
  20. setContent(res.data);
  21. }
  22. }).catch(err => {
  23. setContent($t("payment.tipsPayPerUseAmount").replace("{mm}", amount));
  24. });
  25. }
  26. }, []);
  27. return (
  28. <Modal
  29. visible={visible}
  30. transparent={true}
  31. animationType="fade"
  32. statusBarTranslucent={true}>
  33. <View style={styles.container}>
  34. <View style={styles.content}>
  35. <TextView style={styles.title}>{$t("payment.titleNote")}</TextView>
  36. <TextView style={styles.message}>{content}</TextView>
  37. <View style={styles.buttonsDivide}></View>
  38. <View style={ui.flexc}>
  39. <Button
  40. style={styles.cancelButton}
  41. text={$t("nav.cancel")}
  42. textColor={textPrimary}
  43. onClick={() => onClose(false)}/>
  44. <Button
  45. style={styles.confirmButton}
  46. text={$t("nav.confirm")}
  47. borderRadius={0}
  48. onClick={() => onClose(true)}/>
  49. </View>
  50. </View>
  51. </View>
  52. </Modal>
  53. )
  54. };
  55. export default DialogPayPerUse;
  56. const styles = StyleSheet.create({
  57. container: {
  58. flex: 1,
  59. alignItems: 'center',
  60. justifyContent: 'center',
  61. backgroundColor: 'rgba(0,0,0,.5)'
  62. },
  63. content: {
  64. width: Dialog.dialogWidth,
  65. borderRadius: 16,
  66. overflow: 'hidden',
  67. backgroundColor: colorLight
  68. },
  69. title: {
  70. paddingTop: 24,
  71. paddingLeft: 24,
  72. color: textPrimary,
  73. fontSize: 16,
  74. fontWeight: 'bold'
  75. },
  76. message: {
  77. color: textPrimary,
  78. fontSize: 14,
  79. paddingTop: 16,
  80. paddingLeft: 24,
  81. paddingRight: 24,
  82. paddingBottom: 32
  83. },
  84. cancelButton: {
  85. flex: 1,
  86. borderRadius: 0,
  87. backgroundColor: "#F0F0F0"
  88. },
  89. confirmButton: {
  90. flex: 1,
  91. borderRadius: 0,
  92. backgroundColor: colorAccent
  93. }
  94. })