TabInfos.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * 新版充电站信息页面
  3. * @邠心vbe on 2023/02/06
  4. */
  5. import React, { Component } from 'react';
  6. import { View, Text, StyleSheet } from 'react-native';
  7. import TextView from '../../components/TextView';
  8. import PagerUtil from './PagerUtil';
  9. export default class TabInfos extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. stationInfo: {}
  14. };
  15. }
  16. componentDidMount() {
  17. PagerUtil.addOnRefresh(this);
  18. this.onRefresh();
  19. }
  20. onRefresh() {
  21. console.log("info刷新", this.props.route.name);
  22. this.setState({
  23. stationInfo: PagerUtil.getStationInfo()
  24. });
  25. }
  26. getOperatingHours() {
  27. if (this.state.stationInfo?.endlessService) {
  28. return "24/7";
  29. } else if (this.state.stationInfo?.operatingHours) {
  30. return this.state.stationInfo?.operatingHours;
  31. } else {
  32. return $t('charging.toBeUpdated');
  33. }
  34. }
  35. getParkingFee() {
  36. if (this.state.stationInfo?.parkingFeeFree) {
  37. return $t('charging.free');
  38. } else if (this.state.stationInfo?.parkingFee) {
  39. return this.state.stationInfo.parkingFee;
  40. } else {
  41. return $t('charging.toBeUpdated');
  42. }
  43. }
  44. render() {
  45. return (
  46. <View style={$padding(0, 16)}>
  47. <TextView style={styles.title}>{$t('charging.siteName')}</TextView>
  48. <View style={styles.infoView}>
  49. <TextView style={styles.infoText}>{this.state.stationInfo?.name}</TextView>
  50. </View>
  51. <TextView style={styles.title}>{$t('charging.siteAddress')}</TextView>
  52. <View style={styles.infoView}>
  53. <TextView style={styles.infoText}>{this.state.stationInfo?.address}</TextView>
  54. </View>
  55. <TextView style={styles.title}>{$t('charging.parkingFees')}</TextView>
  56. <View style={styles.infoView}>
  57. <TextView style={styles.infoText}>{this.getParkingFee()}</TextView>
  58. </View>
  59. <TextView style={styles.title}>{$t('charging.operatingHours')}</TextView>
  60. <View style={styles.infoView}>
  61. <TextView style={styles.infoText}>{this.getOperatingHours()}</TextView>
  62. </View>
  63. <TextView style={styles.title}>{$t('charging.additionalInformation')}</TextView>
  64. <View style={styles.infoView}>
  65. <TextView style={styles.infoText}>{this.state.stationInfo?.additionalNotes}</TextView>
  66. </View>
  67. </View>
  68. );
  69. }
  70. }
  71. const styles = StyleSheet.create({
  72. title: {
  73. color: '#000',
  74. fontSize: 14,
  75. fontWeight: 'bold',
  76. ...$padding(16, 0, 8),
  77. borderBottomColor: '#eee',
  78. borderBottomWidth: 1
  79. },
  80. infoView: {
  81. paddingTop: 8,
  82. paddingBottom: 16
  83. },
  84. infoText: {
  85. color: '#444',
  86. fontSize: 14
  87. }
  88. })