/** * 新版充电站信息页面 * @邠心vbe on 2023/02/06 */ import React, { Component } from 'react'; import { View, Text, StyleSheet } from 'react-native'; import PagerUtil from './PagerUtil'; export default class TabInfos extends Component { constructor(props) { super(props); this.state = { stationInfo: {} }; } componentDidMount() { PagerUtil.addOnRefresh(this); this.onRefresh(); } onRefresh() { console.log("info刷新", this.props.route.name); this.setState({ stationInfo: PagerUtil.getStationInfo() }); } getOperatingHours() { if (this.state.stationInfo?.endlessService) { return "24/7"; } else if (this.state.stationInfo?.operatingHours) { return this.state.stationInfo?.operatingHours; } else { return 'To be updated'; } } getParkingFee() { if (this.state.stationInfo?.parkingFeeFree) { return "Free"; } else if (this.state.stationInfo?.parkingFee) { return this.state.stationInfo.parkingFee; } else { return 'To be updated'; } } render() { return ( Site Name {this.state.stationInfo?.name} Address {this.state.stationInfo?.address} Parking Fees {this.getParkingFee()} Operating Hours {this.getOperatingHours()} Additional Information {this.state.stationInfo?.additionalNotes} ); } } const styles = StyleSheet.create({ title: { color: '#000', fontSize: 14, fontWeight: 'bold', ...$padding(16, 0, 8), borderBottomColor: '#eee', borderBottomWidth: 1 }, infoView: { paddingTop: 8, paddingBottom: 16 }, infoText: { color: '#444', fontSize: 14 } })