StepStop.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 TextView from '../../components/TextView';
  8. import StatusImage from './StatusImage';
  9. import { PageList } from '../Router';
  10. export default StepStop = ({
  11. chargingPk="",
  12. stationInfo={}
  13. }) => {
  14. const [isStoping, setStoping] = useState(false);
  15. const [loadingEmps, setEmps] = useState("");
  16. useEffect(() => {
  17. if (chargingPk) {
  18. setStoping(true);
  19. } else {
  20. changeEmps();
  21. }
  22. }, [chargingPk]);
  23. useEffect(() => {
  24. if (!isStoping) {
  25. setTimeout(() => {
  26. changeEmps();
  27. }, 500);
  28. }
  29. }, [loadingEmps]);
  30. const changeEmps = () => {
  31. let emp = loadingEmps;
  32. if (loadingEmps.length == 3) {
  33. emp = "";
  34. } else {
  35. emp += ".";
  36. }
  37. setEmps(emp);
  38. }
  39. return (
  40. <View style={styles.container}>
  41. <View style={styles.content}>
  42. <StatusImage
  43. isStop={isStoping}
  44. isLoading={!isStoping}
  45. />
  46. <View style={ui.flexcc}>
  47. <TextView style={styles.stepTitle}>{$t(isStoping ? 'charging.stepStoppedCharge' : 'charging.stepStoppingCharge')}</TextView>
  48. { !isStoping &&
  49. <TextView style={[styles.stepTitle, {width: 30, marginRight: -10}]}>{loadingEmps}</TextView>
  50. }
  51. </View>
  52. <TextView style={styles.stepDesc}>{$t(isStoping ? 'charging.stepStoppedChargeDesc' : 'charging.stepStoppingChargeDesc')}</TextView>
  53. </View>
  54. { isStoping &&
  55. <View style={styles.bottomView}>
  56. <Button
  57. style={styles.buttonView}
  58. text={$t('charging.btnViewReceipt')}
  59. elevation={1.5}
  60. borderRadius={6}
  61. onClick={() => {
  62. startPage(PageList.summary, {
  63. chargingPk: chargingPk,
  64. id: stationInfo.id,
  65. name: stationInfo.name,
  66. address: stationInfo.address
  67. });
  68. }}/>
  69. <Button
  70. style={styles.buttonHomeView}
  71. text={$t('charging.btnHome')}
  72. elevation={1.5}
  73. borderRadius={6}
  74. onClick={() => startPage(PageList.home)}/>
  75. </View>
  76. }
  77. </View>
  78. )
  79. }
  80. const styles = StyleSheet.create({
  81. container: {
  82. flex: 1,
  83. padding: 16
  84. },
  85. content: {
  86. flex: 1,
  87. alignItems: 'center'
  88. },
  89. stepImage: {
  90. width: $vw(70),
  91. height: $vw(16),
  92. margin: 16
  93. },
  94. stepTitle: {
  95. fontSize: 24,
  96. fontWeight: 'bold',
  97. color: colorAccent
  98. },
  99. stepDesc: {
  100. color: textPrimary,
  101. fontSize: 16,
  102. textAlign: 'center',
  103. ...$padding(0, 32, 48)
  104. },
  105. label: {
  106. color: '#000',
  107. fontSize: 14,
  108. fontWeight: 'bold',
  109. paddingTop: 16,
  110. paddingBottom: 8
  111. },
  112. bottomView: {
  113. paddingBottom: 8
  114. },
  115. buttonView: {
  116. marginTop: 8
  117. },
  118. buttonHomeView: {
  119. marginTop: 12,
  120. marginBottom: 8,
  121. backgroundColor: colorPrimary
  122. }
  123. })