|
|
@@ -0,0 +1,200 @@
|
|
|
+import { StackScreenProps } from '@react-navigation/stack';
|
|
|
+import * as React from 'react';
|
|
|
+import * as Animatable from 'react-native-animatable';
|
|
|
+import {
|
|
|
+ Div,
|
|
|
+ Button,
|
|
|
+ Image,
|
|
|
+ Text,
|
|
|
+ Avatar,
|
|
|
+ Icon,
|
|
|
+ Tag,
|
|
|
+} from 'react-native-magnus';
|
|
|
+import { FlatList } from 'react-native-gesture-handler';
|
|
|
+import { RefreshControl } from 'react-native';
|
|
|
+
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
+import { useRequest, useCreation } from 'ahooks';
|
|
|
+
|
|
|
+import { riderScore } from '../utils/RiderInfoUtils';
|
|
|
+
|
|
|
+import { MonthDate, getSearchDate } from '../utils/TimeUtils';
|
|
|
+import request from '../utils/RequestUtils';
|
|
|
+
|
|
|
+const AppraisalCom = ({ info }) => {
|
|
|
+ const {
|
|
|
+ content,
|
|
|
+ date,
|
|
|
+ merShowName,
|
|
|
+ riderAppraise,
|
|
|
+ riderLike,
|
|
|
+ userNickname,
|
|
|
+ } = info;
|
|
|
+ return (
|
|
|
+ <Div mx={14} mb={10} bg="white" rounded="sm">
|
|
|
+ <Div
|
|
|
+ h={50}
|
|
|
+ row
|
|
|
+ alignItems="center"
|
|
|
+ justifyContent="space-between"
|
|
|
+ px={14}
|
|
|
+ borderBottomColor="gray100"
|
|
|
+ borderBottomWidth={1}
|
|
|
+ >
|
|
|
+ <Text fontSize="sm" color="gray500">
|
|
|
+ {userNickname}
|
|
|
+ </Text>
|
|
|
+ <Image w={30} h={30} source={riderScore.get(riderLike).img} />
|
|
|
+ </Div>
|
|
|
+
|
|
|
+ <Div row py={5} px={11} flexWrap="wrap">
|
|
|
+ {content.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <Tag
|
|
|
+ fontSize="xs"
|
|
|
+ key={index}
|
|
|
+ bg="white"
|
|
|
+ borderColor="gray100"
|
|
|
+ borderWidth={1}
|
|
|
+ ml={3}
|
|
|
+ mt={5}
|
|
|
+ color="gray500"
|
|
|
+ >
|
|
|
+ {item}
|
|
|
+ </Tag>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ {riderAppraise && (
|
|
|
+ <Text fontSize="sm" py={5} w="100%" mt={5} color="gray500">
|
|
|
+ {riderAppraise}
|
|
|
+ </Text>
|
|
|
+ )}
|
|
|
+ </Div>
|
|
|
+
|
|
|
+ <Div row justifyContent="space-between" p={14}>
|
|
|
+ <Text fontSize="xs" color="gray500">
|
|
|
+ {merShowName}
|
|
|
+ </Text>
|
|
|
+ <Text fontSize="xs" color="gray500">
|
|
|
+ {date}
|
|
|
+ </Text>
|
|
|
+ </Div>
|
|
|
+ </Div>
|
|
|
+ );
|
|
|
+};
|
|
|
+interface Result {
|
|
|
+ list: Item[];
|
|
|
+ last: boolean;
|
|
|
+ current: number;
|
|
|
+ empty: boolean;
|
|
|
+}
|
|
|
+
|
|
|
+export default function MineAppraisalScreen({ navigation }: StackScreenProps) {
|
|
|
+ const { t } = useTranslation();
|
|
|
+ const [type, settype] = React.useState<string>('');
|
|
|
+
|
|
|
+ const [show, setshow] = React.useState<boolean>(false);
|
|
|
+
|
|
|
+ const monthDate = new MonthDate();
|
|
|
+ const [showDate, setshowDate] = React.useState<string>(monthDate.showList[0]);
|
|
|
+ const [layout, setLayout] = React.useState<any>();
|
|
|
+ const { data, loading, loadMore, loadingMore, reload } = useRequest(
|
|
|
+ (d: Result | undefined) => {
|
|
|
+ return request.get('/appraisal/riderList', {
|
|
|
+ params: { riderId: 2006 },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ {
|
|
|
+ formatResult: (response) => {
|
|
|
+ return {
|
|
|
+ list: response,
|
|
|
+ last: true,
|
|
|
+ empty: response.length === 0,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ isNoMore: (r: Result) => {
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ defaultLoading: true,
|
|
|
+ debounceInterval: 1000,
|
|
|
+ loadMore: true,
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ const showList = useCreation(() => {
|
|
|
+ if (type) {
|
|
|
+ return data.list.filter((item) => {
|
|
|
+ return item.riderLike === type;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return data.list;
|
|
|
+ }
|
|
|
+ }, [data, type]);
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Div bg="gray100" flex={1}>
|
|
|
+ <Div px={15} py={10} bg="white" row>
|
|
|
+ {[...riderScore.keys()].map((item, index) => {
|
|
|
+ const info = riderScore.get(item);
|
|
|
+ return (
|
|
|
+ <Button
|
|
|
+ key={index}
|
|
|
+ bg="white"
|
|
|
+ w="33.33%"
|
|
|
+ onPress={() => settype(item)}
|
|
|
+ >
|
|
|
+ <Div alignItems="center">
|
|
|
+ <Image source={info.img} w={53} h={53} />
|
|
|
+ <Text
|
|
|
+ fontSize="sm"
|
|
|
+ mt={10}
|
|
|
+ color={item === type ? 'yellow500' : 'gray500'}
|
|
|
+ fontWeight={item === type ? 'bold' : 'normal'}
|
|
|
+ >
|
|
|
+ {t(info.name)}
|
|
|
+ </Text>
|
|
|
+ </Div>
|
|
|
+ </Button>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </Div>
|
|
|
+ <FlatList
|
|
|
+ refreshControl={
|
|
|
+ <RefreshControl refreshing={loading} onRefresh={reload} />
|
|
|
+ }
|
|
|
+ contentContainerStyle={{
|
|
|
+ flexGrow: 1,
|
|
|
+ backgroundColor: '#f2f2f2',
|
|
|
+ paddingTop: 10,
|
|
|
+ }}
|
|
|
+ data={showList}
|
|
|
+ renderItem={({ item }) => {
|
|
|
+ return <AppraisalCom info={item} />;
|
|
|
+ }}
|
|
|
+ keyExtractor={(item) => item.id.toString()}
|
|
|
+ ListFooterComponent={() => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {showList.length !== 0 && (
|
|
|
+ <Text p={15} textAlign="center">
|
|
|
+ {data.last ? t('dao-di-le') : t('jia-zai-zhong')}
|
|
|
+ </Text>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ }}
|
|
|
+ ListEmptyComponent={() => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {showList.length === 0 && !loading && (
|
|
|
+ <Text textAlign="center" p={15}>
|
|
|
+ {t('wu-shu-ju')}
|
|
|
+ </Text>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Div>
|
|
|
+ );
|
|
|
+}
|