StepAuth.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**
  2. * 新充电流程:验证插头模块
  3. * @邠心vbe on 2023/06/20
  4. */
  5. import React, { useEffect, useState } from 'react';
  6. import { View, Text, Image, StyleSheet } from 'react-native';
  7. import app from '../../../app.json';
  8. import Button from '../../components/Button';
  9. import TextView from '../../components/TextView';
  10. import { PaymentList } from '../chargeV2/Payment';
  11. import PaymentListV2 from '../chargeV2/PaymentListV2';
  12. export default StepAuth = ({
  13. status="",
  14. currentPayment,
  15. onStartCharge,
  16. onPaymentMethodChanged
  17. }) => {
  18. const [loadingEmps, setEmps] = useState("");
  19. const [isAuthentic, setAuthentic] = useState(false)
  20. useEffect(() => {
  21. if (status == "Preparing") {
  22. setAuthentic(true);
  23. } else {
  24. changeEmps();
  25. }
  26. }, []);
  27. useEffect(() => {
  28. if (status == "Preparing") {
  29. setAuthentic(true);
  30. } else {
  31. setTimeout(() => {
  32. changeEmps();
  33. }, 500);
  34. }
  35. }, [loadingEmps, status]);
  36. const changeEmps = () => {
  37. let emp = loadingEmps;
  38. if (loadingEmps.length == 3) {
  39. emp = "";
  40. } else {
  41. emp += ".";
  42. }
  43. setEmps(emp);
  44. }
  45. return (
  46. <View style={styles.container}>
  47. <View style={styles.content}>
  48. <Image
  49. style={styles.stepImage}
  50. resizeMode="contain"
  51. source={
  52. isAuthentic
  53. ? require('../../images/site/charging-status-auth.png')
  54. : require('../../images/site/charging-status-ready.png')
  55. }/>
  56. { isAuthentic
  57. ? <TextView style={styles.stepTitle}>{$t('charging.stepAuthenticated')}</TextView>
  58. : <View style={ui.flexcc}>
  59. <TextView style={styles.stepTitle}>{$t('charging.stepAuthenticating')}</TextView>
  60. <TextView style={[styles.stepTitle, {width: 30, marginRight: -10}]}>{loadingEmps}</TextView>
  61. </View>
  62. }
  63. <TextView style={styles.stepDesc}>{$t(isAuthentic ? 'charging.stepAuthenticatedDesc' : 'charging.stepAuthenticatingDesc')}</TextView>
  64. </View>
  65. <View style={styles.bottomView}>
  66. <TextView style={styles.label}>{$t('charging.paymentMethod')}</TextView>
  67. {/* <PaymentList
  68. payType={currentPayment}
  69. onMethodChange={onPaymentMethodChanged}
  70. /> */}
  71. { app.v3.paymentMethod
  72. ? <PaymentListV2
  73. isSelect={isAuthentic}
  74. payType={currentPayment}
  75. onMethodChange={onPaymentMethodChanged}/>
  76. : <PaymentList
  77. isSelect={isAuthentic}
  78. payType={currentPayment}
  79. onMethodChange={onPaymentMethodChanged}/>
  80. }
  81. { isAuthentic
  82. ? <Button
  83. style={styles.buttonView}
  84. text={$t('charging.btnStartCharging')}
  85. elevation={1.5}
  86. borderRadius={6}
  87. onClick={onStartCharge}/>
  88. : <View style={{height: 56}}/>
  89. }
  90. </View>
  91. </View>
  92. );
  93. }
  94. const styles = StyleSheet.create({
  95. container: {
  96. flex: 1,
  97. padding: 16
  98. },
  99. content: {
  100. flex: 1,
  101. alignItems: 'center',
  102. justifyContent: 'center'
  103. },
  104. stepImage: {
  105. width: $vw(70),
  106. height: $vw(16),
  107. margin: 16
  108. },
  109. stepTitle: {
  110. fontSize: 24,
  111. fontWeight: 'bold',
  112. color: colorAccent
  113. },
  114. stepDesc: {
  115. color: textPrimary,
  116. fontSize: 16,
  117. textAlign: 'center',
  118. ...$padding(0, 32, 48)
  119. },
  120. label: {
  121. color: '#000',
  122. fontSize: 14,
  123. fontWeight: 'bold',
  124. paddingTop: 16,
  125. paddingBottom: 8
  126. },
  127. bottomView: {
  128. paddingBottom: 16
  129. },
  130. buttonView: {
  131. marginTop: 8
  132. }
  133. })