MineComplaint.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import { StackScreenProps } from '@react-navigation/stack';
  2. import * as React from 'react';
  3. import * as Animatable from 'react-native-animatable';
  4. import {
  5. Div,
  6. Button,
  7. Image,
  8. Text,
  9. Avatar,
  10. Icon,
  11. Tag,
  12. } from 'react-native-magnus';
  13. import { FlatList } from 'react-native-gesture-handler';
  14. import { RefreshControl } from 'react-native';
  15. import { useTranslation } from 'react-i18next';
  16. import { useRequest, useCreation } from 'ahooks';
  17. import { riderScore } from '../utils/RiderInfoUtils';
  18. import { MonthDate, getSearchDate } from '../utils/TimeUtils';
  19. import request from '../utils/RequestUtils';
  20. const AppraisalCom = ({ info }) => {
  21. const { t } = useTranslation();
  22. const {
  23. content,
  24. enabled,
  25. id,
  26. img,
  27. orderId,
  28. resolve,
  29. solution,
  30. target,
  31. time,
  32. type,
  33. } = info;
  34. const imgs = img ? img.split(',') : [];
  35. return (
  36. <Div mb={10} bg="white" p={15}>
  37. <Text fontSize="sm">
  38. {t('tou-su-lei-xing')}:{type}
  39. </Text>
  40. <Text fontSize="sm">
  41. {t('tou-su-shi-jian')}:{time}
  42. </Text>
  43. <Text
  44. fontSize="sm"
  45. color="gray500"
  46. pt={10}
  47. borderTopColor="gray100"
  48. borderTopWidth={1}
  49. >
  50. {content}
  51. </Text>
  52. <Div row>
  53. {imgs.map((item, index) => {
  54. return (
  55. <Image source={item} key={index} w={36} h={36} mr={13} mt={10} />
  56. );
  57. })}
  58. </Div>
  59. </Div>
  60. );
  61. };
  62. interface Result {
  63. list: Item[];
  64. last: boolean;
  65. current: number;
  66. empty: boolean;
  67. }
  68. export default function MineAppraisalScreen({ navigation }: StackScreenProps) {
  69. const { t } = useTranslation();
  70. const { data, loading, loadMore, loadingMore, reload } = useRequest(
  71. (d: Result | undefined) => {
  72. return request.get(__DEV__ ? '/complaint/all' : '/complaint/my');
  73. },
  74. {
  75. formatResult: (response) => {
  76. return {
  77. list: __DEV__ ? response.content : response,
  78. last: true,
  79. empty: __DEV__ ? response.empty : response.length === 0,
  80. };
  81. },
  82. isNoMore: (r: Result) => {
  83. return false;
  84. },
  85. defaultLoading: false,
  86. debounceInterval: 1000,
  87. loadMore: true,
  88. }
  89. );
  90. return (
  91. <Div bg="gray100" flex={1}>
  92. <FlatList
  93. refreshControl={
  94. <RefreshControl refreshing={loading} onRefresh={reload} />
  95. }
  96. contentContainerStyle={{
  97. flexGrow: 1,
  98. backgroundColor: '#f2f2f2',
  99. paddingTop: 10,
  100. }}
  101. data={data.list}
  102. renderItem={({ item }) => {
  103. return <AppraisalCom info={item} />;
  104. }}
  105. keyExtractor={(item) => item.id.toString()}
  106. ListFooterComponent={() => {
  107. return (
  108. <>
  109. {!data.empty && (
  110. <Text p={15} textAlign="center">
  111. {data.last ? t('dao-di-le') : t('jia-zai-zhong')}
  112. </Text>
  113. )}
  114. </>
  115. );
  116. }}
  117. ListEmptyComponent={() => {
  118. return (
  119. <>
  120. {!loading && (
  121. <Text textAlign="center" p={15}>
  122. {t('wu-shu-ju')}
  123. </Text>
  124. )}
  125. </>
  126. );
  127. }}
  128. />
  129. </Div>
  130. );
  131. }