DialogPayPerUse.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. <View style={styles.container}>
  32. <View style={styles.content}>
  33. <TextView style={styles.title}>{$t("payment.titleNote")}</TextView>
  34. <TextView style={styles.message}>{content}</TextView>
  35. <View style={styles.buttonsDivide}></View>
  36. <View style={ui.flexc}>
  37. <Button
  38. style={styles.cancelButton}
  39. text={$t("nav.cancel")}
  40. textColor={textPrimary}
  41. onClick={() => onClose(false)}/>
  42. <Button
  43. style={styles.confirmButton}
  44. text={$t("nav.confirm")}
  45. borderRadius={0}
  46. onClick={() => onClose(true)}/>
  47. </View>
  48. </View>
  49. </View>
  50. </Modal>
  51. )
  52. };
  53. export default DialogPayPerUse;
  54. const styles = StyleSheet.create({
  55. container: {
  56. flex: 1,
  57. alignItems: 'center',
  58. justifyContent: 'center',
  59. backgroundColor: 'rgba(0,0,0,.5)'
  60. },
  61. content: {
  62. width: Dialog.dialogWidth,
  63. borderRadius: 16,
  64. overflow: 'hidden',
  65. backgroundColor: colorLight
  66. },
  67. title: {
  68. paddingTop: 24,
  69. paddingLeft: 24,
  70. color: textPrimary,
  71. fontSize: 16,
  72. fontWeight: 'bold'
  73. },
  74. message: {
  75. color: textPrimary,
  76. fontSize: 14,
  77. paddingTop: 16,
  78. paddingLeft: 24,
  79. paddingRight: 24,
  80. paddingBottom: 32
  81. },
  82. cancelButton: {
  83. flex: 1,
  84. borderRadius: 0,
  85. backgroundColor: "#F0F0F0"
  86. },
  87. confirmButton: {
  88. flex: 1,
  89. borderRadius: 0,
  90. backgroundColor: colorAccent
  91. }
  92. })