TabInfos.js 2.5 KB

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