StepStart.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /**
  2. * 新充电流程:充电前的模块
  3. * @邠心vbe on 2023/06/20
  4. */
  5. import React from 'react';
  6. import { View, Image, StyleSheet, ScrollView, Pressable } from 'react-native';
  7. import app from '../../../app.json';
  8. import Button, { ElevationObject } from '../../components/Button';
  9. import TextView from '../../components/TextView';
  10. import { ChargeStyle } from '../chargeV2/Charging';
  11. import { PaymentList } from '../chargeV2/Payment';
  12. import DiscountView from './DiscountView';
  13. import PaymentListV2 from '../chargeV2/PaymentListV2';
  14. import PagerUtil from '../chargeV2/PagerUtil';
  15. import utils from '../../utils/utils';
  16. import DialogIdleFee from './DialogIdleFee';
  17. export default StepStart = ({
  18. idleFeeConfig,
  19. connectorInfo={},
  20. currentPayment,
  21. onPaymentMethodChanged,
  22. onAuthenticate,
  23. selectedVoucher={}
  24. }) => {
  25. return (
  26. <ScrollView
  27. style={ui.flex1}
  28. contentContainerStyle={$padding(16)}>
  29. <View style={ui.center}>
  30. <Image
  31. style={styles.stepImage}
  32. resizeMode="contain"
  33. source={require('../../images/site/charging-status-unknow.png')}/>
  34. <TextView style={styles.stepTitle}>{$t('charging.stepInsertConnector')}</TextView>
  35. <TextView style={styles.stepDesc}>{$t('charging.stepInsertConnectorDesc')}</TextView>
  36. </View>
  37. <View style={styles.infoRow}>
  38. <View style={styles.infoCard}>
  39. <TextView style={styles.infoTitle}>{$t('charging.labelType')}</TextView>
  40. <TextView
  41. numberOfLines={1}
  42. ellipsizeMode="tail"
  43. style={styles.infoText}>{connectorInfo.chargeType}{connectorInfo.wattage || "AC22"}</TextView>
  44. <TextView style={styles.infoDesc}></TextView>
  45. </View>
  46. <View style={styles.infoCard}>
  47. <TextView style={styles.infoTitle}>{$t('charging.labelPower')}</TextView>
  48. <TextView
  49. numberOfLines={1}
  50. ellipsizeMode="tail"
  51. style={styles.infoText}>{connectorInfo.wattage || "0"} kW{/*connectorInfo.rateType*/}</TextView>
  52. <TextView style={styles.infoDesc}></TextView>
  53. </View>
  54. </View>
  55. <View style={styles.infoRow}>
  56. <View style={styles.infoCard}>
  57. <DiscountView visible={connectorInfo.hasDiscount}/>
  58. <TextView style={styles.infoTitle}>{$t('charging.labelRate')}</TextView>
  59. {/* <Text
  60. numberOfLines={1}
  61. ellipsizeMode="tail"
  62. style={styles.infoText}>{connectorInfo.rate || "0.00"}/{connectorInfo.rateType || "kWh"}</Text> */}
  63. <TextView
  64. numberOfLines={2}
  65. ellipsizeMode="tail"
  66. style={styles.infoText}>{connectorInfo.rates || "S$0.00/kWh"}</TextView>
  67. {(app.modules.nationally && connectorInfo.rates != connectorInfo.userRates) && (
  68. <TextView
  69. numberOfLines={1}
  70. ellipsizeMode="tail"
  71. style={styles.infoDesc}>({connectorInfo.userRates || "S$0.00/kWh"})</TextView>)
  72. }
  73. </View>
  74. <View style={styles.infoCard}>
  75. <TextView style={styles.infoTitle}>{$t('charging.labelStatus')}</TextView>
  76. <TextView
  77. style={[ChargeStyle.statusAuthenticated, styles.infoStatus]}>
  78. {$t('charging.statusAvailable')}
  79. </TextView>
  80. </View>
  81. </View>
  82. <EndView/>
  83. { (idleFeeConfig && idleFeeConfig.idleFee) &&
  84. <DialogIdleFee idleFeeConfig={idleFeeConfig}/>
  85. }
  86. <View style={ui.flexc}>
  87. <TextView style={[styles.label, ui.flex1]}>{$t('charging.paymentMethod')}</TextView>
  88. { app.v3.vouchers &&
  89. <TextView style={[styles.label, {flex: 1, paddingLeft: 16}]}>{$t('voucher.vouchers')}</TextView>
  90. }
  91. </View>
  92. <View style={ui.flexc}>
  93. <View style={ui.flex1}>
  94. { app.charge.paymentMethod
  95. ? <PaymentListV2
  96. payType={currentPayment}
  97. chargeBoxId={connectorInfo.chargeBoxId}
  98. onMethodChange={onPaymentMethodChanged}/>
  99. : <PaymentList
  100. payType={currentPayment}
  101. onMethodChange={onPaymentMethodChanged}/>
  102. }
  103. </View>
  104. { app.v3.vouchers &&
  105. <Pressable
  106. style={styles.voucherLayout}
  107. onPress={() => PagerUtil.toSelectVoucher(connectorInfo.chargeBoxId, connectorInfo.connectorId)}>
  108. <MaterialCommunityIcons
  109. name="ticket-percent"
  110. size={35}
  111. color={colorAccent}/>
  112. { utils.isNotEmpty(selectedVoucher.userVoucherId)
  113. ? <View style={styles.vouchersView}>
  114. <TextView
  115. style={styles.voucherName}
  116. numberOfLines={1}>
  117. {selectedVoucher.voucherName}
  118. </TextView>
  119. <TextView
  120. style={styles.voucherDesc}
  121. numberOfLines={1}>
  122. {selectedVoucher.voucherDesc}
  123. </TextView>
  124. </View>
  125. : <View style={styles.vouchersView}>
  126. <TextView style={styles.selectText}>{$t("voucher.selectVoucher")}</TextView>
  127. </View>
  128. }
  129. <FontAwesome6
  130. name={"angle-right"}
  131. size={16}
  132. color={colorCancel}
  133. />
  134. </Pressable>
  135. }
  136. </View>
  137. <Button
  138. style={styles.buttonView}
  139. text={$t('charging.btnAuthenticate')}
  140. elevation={1.5}
  141. borderRadius={6}
  142. onClick={onAuthenticate}/>
  143. </ScrollView>
  144. );
  145. }
  146. const styles = StyleSheet.create({
  147. stepImage: {
  148. width: $vw(70),
  149. height: $vw(16),
  150. margin: 16
  151. },
  152. stepTitle: {
  153. fontSize: 24,
  154. fontWeight: 'bold',
  155. color: colorAccent
  156. },
  157. stepDesc: {
  158. color: textPrimary,
  159. fontSize: 16,
  160. textAlign: 'center',
  161. ...$padding(0, 32, 48)
  162. },
  163. infoRow: {
  164. marginLeft: 16,
  165. marginBottom: 16,
  166. flexDirection: 'row'
  167. },
  168. infoCard: {
  169. flex: 1,
  170. paddingTop: 12,
  171. paddingBottom: 12,
  172. borderRadius: 10,
  173. marginRight: 16,
  174. overflow: 'hidden',
  175. alignItems: 'center',
  176. ...ElevationObject(5),
  177. backgroundColor: colorLight,
  178. },
  179. infoTitle: {
  180. color: textPrimary,
  181. fontSize: 12,
  182. paddingTop: 1
  183. },
  184. infoText: {
  185. color: textPrimary,
  186. fontSize: 15,
  187. textAlign: 'center',
  188. fontWeight: 'bold',
  189. ...$padding(12, 6)
  190. },
  191. infoDesc: {
  192. color: textPrimary,
  193. fontSize: 12,
  194. marginTop: -12,
  195. paddingBottom: 8
  196. },
  197. infoStatus: {
  198. fontSize: 16,
  199. fontWeight: 'bold',
  200. ...$padding(16, 8)
  201. },
  202. label: {
  203. color: '#000',
  204. fontSize: 14,
  205. fontWeight: 'bold',
  206. paddingTop: 16,
  207. paddingBottom: 8
  208. },
  209. buttonView: {
  210. marginTop: 8,
  211. marginBottom: 16
  212. },
  213. voucherLayout: {
  214. flex: 1,
  215. padding: 12,
  216. maxWidth: $vw(50) - 24,
  217. borderRadius: 10,
  218. marginLeft: 16,
  219. marginBottom: 12,
  220. alignItems: 'center',
  221. flexDirection: 'row',
  222. ...ElevationObject(5),
  223. backgroundColor: colorLight,
  224. },
  225. vouchersView: {
  226. flex: 1,
  227. paddingLeft: 8,
  228. flexWrap: 'wrap',
  229. alignItems: 'center',
  230. flexDirection: 'row'
  231. },
  232. selectText: {
  233. flex: 1,
  234. color: textSecondary,
  235. fontSize: 15,
  236. fontWeight: 'bold'
  237. },
  238. voucherName: {
  239. color: textPrimary,
  240. fontSize: 15,
  241. paddingLeft: 8,
  242. fontWeight: 'bold'
  243. },
  244. voucherDesc: {
  245. color: textSecondary,
  246. fontSize: 12,
  247. paddingLeft: 8,
  248. paddingRight: 16
  249. }
  250. })