ViewHistory.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. <View style={styles.rightTextView}>
  42. { item.hasSettle && (item.amountSymbol == 'M'
  43. ? <TextView style={styles.amountDuct}>- {item.amount}</TextView>
  44. : <TextView style={styles.amountText}>+ {item.amount}</TextView>
  45. )}
  46. { item.hasSettle
  47. ? <TextView style={styles.amountText}>Successful</TextView>
  48. : <TextView style={styles.amountDuct}>Pending</TextView>
  49. }
  50. </View>
  51. </Pressable>
  52. );
  53. export default ViewHistory;
  54. const styles = StyleSheet.create({
  55. historyItem: {
  56. padding: 16,
  57. alignItems: 'center',
  58. flexDirection: 'row'
  59. },
  60. itemContent: {
  61. flex: 1,
  62. paddingRight: 16
  63. },
  64. textTitle: {
  65. color: textPrimary,
  66. fontSize: 15,
  67. fontWeight: 'bold'
  68. },
  69. textDesc: {
  70. color: textSecondary,
  71. fontSize: 13
  72. },
  73. textId: {
  74. color: textSecondary,
  75. fontSize: 14,
  76. paddingTop: 2,
  77. paddingBottom: 2
  78. },
  79. amountDuct: {
  80. color: '#FF2E00',
  81. fontSize: 14
  82. },
  83. amountText: {
  84. color: colorAccent,
  85. fontSize: 14
  86. },
  87. rightTextView: {
  88. alignItems: "flex-end"
  89. }
  90. })