MineWalletScreen.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { StackScreenProps } from '@react-navigation/stack';
  2. import * as React from 'react';
  3. import { Div, Button, Image, Text, Avatar, Icon } from 'react-native-magnus';
  4. import { ScrollView } from 'react-native-gesture-handler';
  5. import { RootStackParamList } from '../types';
  6. import { useRequest } from 'ahooks';
  7. import useModel from 'flooks';
  8. import User from '../stores/User';
  9. import { getMoney } from '../utils/SystemUtils';
  10. import request from '../utils/RequestUtils';
  11. import { today } from '../utils/TimeUtils';
  12. import { useTranslation } from 'react-i18next';
  13. import ReacordCom from './ReacordCom';
  14. export default function MineWalletScreen({
  15. navigation,
  16. }: StackScreenProps<RootStackParamList, 'Login'>) {
  17. const { t } = useTranslation();
  18. const { userInfo } = useModel(User, ['userInfo']);
  19. const { data, loading } = useRequest(
  20. () => {
  21. return request.get(__DEV__ ? '/moneyRecord/all' : '/moneyRecord/my', {
  22. params: {
  23. query: {
  24. time: today(),
  25. },
  26. },
  27. });
  28. },
  29. {
  30. formatResult: (response) => response.content,
  31. initialData: [],
  32. defaultLoading: false,
  33. }
  34. );
  35. const { money } = userInfo;
  36. return (
  37. <Div bg="gray100" flex={1}>
  38. <Div bg="yellow500" row>
  39. <Text color="red700" fontSize="sm" flex={1} pl={20} pt={30}>
  40. {t('yu-e')}
  41. </Text>
  42. <Text
  43. flex={1}
  44. textAlign="center"
  45. fontSize="6xl"
  46. color="white"
  47. fontWeight="bold"
  48. py={20}
  49. >
  50. {getMoney(money)}
  51. </Text>
  52. <Button
  53. onPress={() => navigation.navigate('BankCard')}
  54. flex={1}
  55. bg="transparent"
  56. alignSelf="flex-end"
  57. py={30}
  58. >
  59. <Text
  60. textDecorLine="underline"
  61. textDecorColor="white"
  62. color="white"
  63. fontSize="xl"
  64. >
  65. {t('ti-xian')}
  66. </Text>
  67. </Button>
  68. </Div>
  69. <ScrollView
  70. contentContainerStyle={{
  71. flexGrow: 1,
  72. backgroundColor: '#f2f2f2',
  73. }}
  74. stickyHeaderIndices={[0, 2]}
  75. >
  76. <Div row h={40} alignItems="center" bg="gray100" px={20}>
  77. <Text flex={1} fontSize="sm">
  78. {t('jin-ri-zhang-dan')}
  79. </Text>
  80. <Text fontSize="sm" color="gray500">
  81. {t('jin-ri-shou-ru')}¥ 16,752.95
  82. </Text>
  83. <Text fontSize="sm" color="gray500" ml={10}>
  84. {t('jin-ri-zhi-chu')} ¥ 6,752.95
  85. </Text>
  86. </Div>
  87. <Div bg="white" px={15}>
  88. {data.map((item) => {
  89. return <ReacordCom key={item.id} info={item} />;
  90. })}
  91. {data.length == 0 && !loading && (
  92. <Text p={15} textAlign="center">
  93. {t('jin-ri-huan-mei-you-zhang-dan-xin-xio')}
  94. </Text>
  95. )}
  96. </Div>
  97. <Button
  98. p={0}
  99. block
  100. mb={50}
  101. bg="white"
  102. mt={10}
  103. onPress={() => navigation.navigate('MineRecord')}
  104. >
  105. <Div flex={1} row h={52} alignItems="center" px={15}>
  106. <Text flex={1} fontSize="sm">
  107. {t('wo-de-dui-zhang-dan')}
  108. </Text>
  109. <Icon ml={5} name="right" fontSize="sm" />
  110. </Div>
  111. </Button>
  112. </ScrollView>
  113. </Div>
  114. );
  115. }