StepAuth.js 3.5 KB

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