/** * 新版充电结算页面 * @邠心vbe on 2023/02/08 */ import React, { Component } from 'react'; import { View, Text, StyleSheet, ScrollView, RefreshControl } from 'react-native'; import apiCharge from '../../api/apiCharge'; import Button from '../../components/Button'; import Dialog from '../../components/Dialog'; import { MyRefreshProps } from '../../components/ThemesConfig'; import utils from '../../utils/utils'; import { PageList } from '../Router'; export default class Summary extends Component { constructor(props) { super(props); this.state = { isActully: true, refreshing: false, summaryInfo: { top: {}, station: {}, connector: {}, chargingFee: {}, idleFee: {}, reservationFee: {}, payment: {} }, chargingPk: "" }; this.canBack = false; } componentDidMount() { const params = this.props.route.params; if (params.chargingPk) { Dialog.showProgressDialog(); this.setState({ chargingPk: params.chargingPk }) if (params.action && params.action == "view") { this.setState({ isActully: false }); this.getSummaryData(params.chargingPk); } else { setTimeout(() => { this.getSummaryData(params.chargingPk); }, 3000); } } this.props.navigation.addListener('focus', e => { this.canBack = false; }); this.props.navigation.addListener('beforeRemove', e => { if (this.state.isActully && !this.canBack) { this.toRating(); e.preventDefault(); } }); } getSummaryData(chargingPk) { apiCharge.getChargeSummaryV2({ chargingPk: chargingPk }).then(res => { Dialog.dismissLoading(); if (res.data) { this.setState({ refreshing: false, summaryInfo: res.data }); } }).catch((err) => { Dialog.dismissLoading(); toastShort(err); this.setState({ refreshing: false }); }); } onRefresh() { if (this.state.chargingPk) { this.setState({ refreshing: true }); this.getSummaryData(this.state.chargingPk); } } toRating() { this.canBack = true; //goBack(); //routeUtil.resetToHome(this.props); startPage(PageList.home); //startPage(PageList.rating, this.state.stationInfo); } getSummaryText(data) { if (this.state.summaryInfo?.paymentType == 'Fleet Credit') { return '-'; } else { return currency + '' + (data ?? '0'); } } render() { return ( this.onRefresh()} /> }> { utils.isNotEmpty(this.state.summaryInfo.top) && {$t('receipt.successful')} {$t('receipt.chargingSessionComplete')} { utils.isNotEmpty(this.state.summaryInfo.top.company) && {$t('sign.labelCompany')}: {this.state.summaryInfo.top.company} } { utils.isNotEmpty(this.state.summaryInfo.top.registrationNo) && {$t('receipt.labelRegistrationNo')} {this.state.summaryInfo.top.registrationNo} } {$t('receipt.labelTransactionID')} {this.state.summaryInfo.top.transactionId} {$t('receipt.labelReferenceID')} {this.state.summaryInfo.top.referenceId} {$t('receipt.labelDateTime')} {this.state.summaryInfo.top.dateTime} } {/* {$t('wallet.labelTransactionId')} {this.state.summaryInfo.transactionPk} {$t('wallet.labelReferenceId')} {this.state.summaryInfo.chargingPk} {$t('wallet.labelDateTime')} {this.state.summaryInfo.dateTime} */} { utils.isNotEmpty(this.state.summaryInfo.station) && {$t('wallet.labelYourStation')} {$t('wallet.labelStationId')} {this.state.summaryInfo.station.stationId} {$t('receipt.labelSiteName')} {this.state.summaryInfo.station.siteName ?? "-"} } { utils.isNotEmpty(this.state.summaryInfo.connector) && {$t('wallet.labelYourConnector')} {$t('charging.labelType')} {this.state.summaryInfo.connector.type} {$t('charging.labelPower')} {this.state.summaryInfo.connector.power} {$t('charging.labelRates')} {this.state.summaryInfo.connector.rates} } { utils.isNotEmpty(this.state.summaryInfo.chargingFee) && {$t('receipt.breakdownChargingFees')} {$t('wallet.labelChargeTime')} {this.state.summaryInfo.chargingFee.chargeTime ?? "-"} {$t('wallet.labelChargeDelivered')} {this.state.summaryInfo.chargingFee.chargeDelivered ?? 0} {$t('receipt.labelChargTransSubtotal')} {this.state.summaryInfo.chargingFee.transactionSubtotal} } { utils.isNotEmpty(this.state.summaryInfo.idleFee) && {$t('receipt.breakdownIdlesFees')} {$t('receipt.labelIdleStartTime')} {this.state.summaryInfo.idleFee.startTime} {$t('receipt.labelIdleDuration')} {this.state.summaryInfo.idleFee.duration} {$t('receipt.labelIdleFeeSubtotal')} {this.state.summaryInfo.idleFee.subtotal} } { utils.isNotEmpty(this.state.summaryInfo.reservationFee) && {$t('receipt.breakdownReservationFees')} {$t('receipt.labelTimeReservation')} {this.state.summaryInfo.reservationFee.reservationTime} {$t('receipt.labelDurationReservation')} {this.state.summaryInfo.reservationFee.reservationDuration} {$t('receipt.labelReservationFeeSubtotal')} {this.state.summaryInfo.reservationFee.reservationFeeSubtotal} } { utils.isNotEmpty(this.state.summaryInfo.payment) && {$t('receipt.breakdownPayment')} {$t('wallet.labelPaymentMadeBy')} {this.state.summaryInfo.payment.paymentMadeBy ?? "-"} { utils.isNotEmpty(this.state.summaryInfo.payment.transactionSubtotal) && {$t('receipt.labelChargTransSubtotal')} {this.state.summaryInfo.payment.transactionSubtotal} } { utils.isNotEmpty(this.state.summaryInfo.payment.idleFeeSubtotal) && {$t('receipt.labelIdleFeeSubtotal')} {this.state.summaryInfo.payment.idleFeeSubtotal} } { utils.isNotEmpty(this.state.summaryInfo.payment.reservationFeeSubtotal) && {$t('receipt.labelReservationFeeSubtotal')} {this.state.summaryInfo.payment.reservationFeeSubtotal} } {$t('receipt.labelFinalPaymentAmount')} {this.state.summaryInfo.payment.finalPayment ?? "-"} {/* {$t('wallet.labelChargeRates')} {currency}{this.state.summaryInfo.chargeRates ?? '0.0'} */} {$t('wallet.labelExchangeRate')} {this.state.summaryInfo.payment.exchangeRate ?? "-"} {/* {$t('wallet.labelPreviousBalance')} {this.getSummaryText(this.state.summaryInfo.previousBalance)} */} {$t('wallet.labelResultingBalance')} {this.state.summaryInfo.payment.resultingBalance ?? "-"} } { this.state.isActully && startPage(PageList.feedback)}>{$t('wallet.linkSubmitFeedback')} {/* {$t('wallet.tipsReceipt')} */}