ViewHistory.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * 钱包交易历史
  3. * @邠心vbe on 2025/01/17
  4. */
  5. import React from 'react';
  6. import { StyleSheet } from 'react-native';
  7. import { Pressable } from 'react-native';
  8. import { View } from 'react-native';
  9. import TextView from '../../components/TextView';
  10. import { PageList } from '../Router';
  11. const getTransTitle = (item) => {
  12. let title = "";
  13. if (item.remarks) {
  14. title += item.remarks;
  15. } else if (item.amountSymbol == 'M') {
  16. title +=(item.siteName || "Charging");
  17. } else {
  18. title += $t('wallet.topUp');
  19. }
  20. return title;
  21. }
  22. const toSummary = (item) => {
  23. if (item.refPk) {
  24. startPage(PageList.summary, { action: 'view', chargingPk: item.refPk });
  25. }
  26. }
  27. const ViewHistory = ({
  28. item,
  29. index,
  30. separators
  31. }) => (
  32. <Pressable
  33. style={styles.historyItem}
  34. android_ripple={ripple}
  35. onPress={() => toSummary(item)}>
  36. <View style={styles.itemContent}>
  37. <TextView style={styles.textDesc}>{item.createTime}</TextView>
  38. <TextView style={styles.textId}>{$t("receipt.labelTransactionID")}{item.creditHistoryPk}</TextView>
  39. <TextView style={styles.textTitle}>{getTransTitle(item)}</TextView>
  40. </View>
  41. { item.amountSymbol == 'M'
  42. ? <TextView style={styles.amountDuct}>- {item.amount}</TextView>
  43. : <TextView style={styles.amountText}>+ {item.amount}</TextView>
  44. }
  45. </Pressable>
  46. );
  47. export default ViewHistory;
  48. const styles = StyleSheet.create({
  49. historyItem: {
  50. padding: 16,
  51. alignItems: 'center',
  52. flexDirection: 'row'
  53. },
  54. itemContent: {
  55. flex: 1,
  56. paddingRight: 16
  57. },
  58. textTitle: {
  59. color: textPrimary,
  60. fontSize: 15,
  61. fontWeight: 'bold'
  62. },
  63. textDesc: {
  64. color: textSecondary,
  65. fontSize: 13
  66. },
  67. textId: {
  68. color: textSecondary,
  69. fontSize: 14,
  70. paddingTop: 2,
  71. paddingBottom: 2
  72. },
  73. amountDuct: {
  74. color: '#FF2E00',
  75. fontSize: 14
  76. },
  77. amountText: {
  78. color: colorAccent,
  79. fontSize: 14
  80. }
  81. })