StepChargeView.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /**
  2. * 充电页:扫码认证之后-充电开始之前
  3. * @邠心vbe on 2023/03/10
  4. */
  5. import React from 'react';
  6. import { Pressable, StyleSheet, View } from 'react-native';
  7. import Button, {ElevationObject} from '../../components/Button';
  8. import TextView from '../../components/TextView';
  9. import { circleSize, DashboardView } from '../chargeV2/Charging';
  10. import { PaymentList } from '../chargeV2/Payment';
  11. import StationInfoView from './StationInfoView';
  12. import PaymentListV2 from '../chargeV2/PaymentListV2';
  13. import app from '../../../app.json';
  14. import PagerUtil from '../chargeV2/PagerUtil';
  15. import utils from '../../utils/utils';
  16. export default StepChargeView = ({
  17. isStart=false,
  18. isPending,
  19. isCharging,
  20. connectorInfo,
  21. currentPayment,
  22. curerntPerUser,
  23. lastUpdated,
  24. onStartCharge,
  25. onStopCharge,
  26. selectedVoucher={},
  27. onPaymentMethodChanged
  28. }) => (
  29. <>
  30. <View style={{minHeight: $vht(80)}}>
  31. <DashboardView
  32. isCharging={isCharging}
  33. connectorInfo={connectorInfo}/>
  34. <TextView style={styles.title}>{$t('charging.selectedCharger')}</TextView>
  35. <StationInfoView
  36. isCharging={isCharging}
  37. isPending={isPending}
  38. connectorInfo={connectorInfo}/>
  39. {/* <BatteryView
  40. soc={this.state.connectorInfo.batteryPercent}
  41. isCharging={this.state.isCharging}
  42. isPending={this.state.isPending}
  43. /> */}
  44. {/* <View style={ui.center}>
  45. <ImageBackground
  46. style={styles.batteryBorder}
  47. source={require('../../images/charge/ic-charge-circle.png')}>
  48. <Text style={{
  49. color: textPrimary,
  50. fontSize: 16,
  51. lineHeight: 22,
  52. textAlign: 'center'
  53. }}>
  54. Press<Text style={{padding: 10, fontWeight: 'bold'}}> Start </Text>to begin Charging
  55. </Text>
  56. </ImageBackground>
  57. </View> */}
  58. <TextView style={styles.title}>{$t('charging.selectPaymentMethod')}</TextView>
  59. { app.charge.paymentMethod
  60. ? <PaymentListV2
  61. payType={currentPayment}
  62. isSelect={!isPending && !isCharging}
  63. chargeBoxId={connectorInfo.chargeBoxId}
  64. onMethodChange={onPaymentMethodChanged}/>
  65. : <PaymentList
  66. payType={currentPayment}
  67. payPerUse={curerntPerUser}
  68. onMethodChange={onPaymentMethodChanged}/>
  69. }
  70. {/* <PaymentList
  71. payType={currentPayment}
  72. payPerUse={curerntPerUser}
  73. onMethodChange={onPaymentMethodChanged}
  74. /> */}
  75. { (app.v3.vouchers && (!isPending || !isCharging || utils.isNotEmpty(selectedVoucher.userVoucherId))) && <>
  76. <TextView style={styles.title}>{$t('voucher.selectVoucher')}</TextView>
  77. <Pressable
  78. style={styles.voucherLayout}
  79. onPress={() => (!isPending && !isCharging) && PagerUtil.toSelectVoucher(connectorInfo.chargeBoxId, connectorInfo.connectorId)}>
  80. <MaterialCommunityIcons
  81. name="ticket-percent"
  82. size={35}
  83. color={colorAccent}/>
  84. { utils.isNotEmpty(selectedVoucher.userVoucherId)
  85. ? <View style={styles.vouchersView}>
  86. <TextView
  87. style={styles.voucherName}
  88. numberOfLines={1}>
  89. {selectedVoucher.voucherName}
  90. </TextView>
  91. <TextView
  92. style={styles.voucherDesc}
  93. numberOfLines={1}>
  94. {selectedVoucher.voucherDesc}
  95. </TextView>
  96. </View>
  97. : <View style={styles.vouchersView}>
  98. <TextView style={styles.selectText}>{$t("voucher.selectVoucher")}</TextView>
  99. </View>
  100. }
  101. { (!isPending && !isCharging) &&
  102. <FontAwesome6
  103. name={"angle-right"}
  104. size={16}
  105. color={colorCancel}
  106. />
  107. }
  108. </Pressable>
  109. </>}
  110. { lastUpdated
  111. ? <TextView style={styles.updateTip}>{$t('charging.lastUpdatedAt') + lastUpdated + '\n' + $t('charging.pullDownRefresh')}</TextView>
  112. : <></>
  113. }
  114. </View>
  115. { isStart
  116. ? <Button
  117. style={styles.buttonView}
  118. disabled={isPending}
  119. text={isCharging ? $t('charging.btnStopCharging') : $t('charging.btnComplete')}
  120. elevation={1.5}
  121. onClick={onStopCharge}/>
  122. : <Button
  123. style={styles.buttonView}
  124. text={$t('charging.btnStartCharging')}
  125. elevation={1.5}
  126. onClick={onStartCharge}/>
  127. }
  128. </>
  129. );
  130. const styles = StyleSheet.create({
  131. title: {
  132. color: '#000',
  133. fontSize: 14,
  134. fontWeight: 'bold',
  135. paddingTop: 16,
  136. paddingBottom: 16
  137. },
  138. buttonView: {
  139. marginTop: 16,
  140. marginBottom: 32
  141. },
  142. updateTip: {
  143. color: '#aaa',
  144. fontSize: 10,
  145. textAlign: 'center',
  146. paddingTop: 32,
  147. paddingBottom: 16
  148. },
  149. listView: {
  150. padding: 8,
  151. },
  152. batteryBorder: {
  153. margin: 30,
  154. padding: 32,
  155. width: circleSize,
  156. height: circleSize,
  157. alignItems: 'center',
  158. justifyContent: 'center'
  159. },
  160. voucherLayout: {
  161. padding: 12,
  162. borderRadius: 10,
  163. marginBottom: 12,
  164. alignItems: 'center',
  165. flexDirection: 'row',
  166. ...ElevationObject(5),
  167. backgroundColor: colorLight,
  168. },
  169. vouchersView: {
  170. flex: 1,
  171. paddingLeft: 8,
  172. flexWrap: 'wrap',
  173. alignItems: 'center',
  174. flexDirection: 'row'
  175. },
  176. selectText: {
  177. flex: 1,
  178. color: textSecondary,
  179. fontSize: 15,
  180. fontWeight: 'bold'
  181. },
  182. voucherName: {
  183. flex: 1,
  184. color: textPrimary,
  185. fontSize: 15,
  186. paddingLeft: 8,
  187. fontWeight: 'bold'
  188. },
  189. voucherDesc: {
  190. flex: 1,
  191. color: textSecondary,
  192. fontSize: 12,
  193. paddingLeft: 8,
  194. paddingRight: 16
  195. }
  196. })