import * as WebBrowser from 'expo-web-browser'; import * as React from 'react'; import { Div, Button, Image, Text, Avatar } from 'react-native-magnus'; import { ScrollView } from 'react-native-gesture-handler'; import { InputItem, TextareaItem } from '@ant-design/react-native'; import { useRequest, useCreation } from '@umijs/hooks'; import { useTranslation } from 'react-i18next'; import useModel from 'flooks'; import User from '../../flooks/User'; // detail模块通用方法 import Toast from '../../flooks/Toast'; // detail模块通用方法 import ImagePicker from '../../components/ImagePicker'; import Header from '../../components/Header'; import request from '../../Utils/RequestUtils'; import { alertWithoutCancel } from '../../Utils/TotastUtils'; function saveRequest(data) { return request.post('/feedback/save', { data, }); } export default function FeedBackScreen({ navigation }) { const { t } = useTranslation(); const { userInfo } = useModel(User, ['id']); const { warnning, success } = useModel(Toast, []); const [name, setname] = React.useState(''); const [phone, setphone] = React.useState(''); const [content, setcontent] = React.useState(''); const [imgList, setimgList] = React.useState(['']); function changeImg(img, index) { const list = [...imgList]; if (!img) { list.splice(index, 1); } else { list.splice(index, 1, img); } if (index === list.length - 1 && list.length < 4) { list.push(''); } setimgList(list); } function deleteImg(index) { const list = [...imgList]; if (!list[index]) { return null; } else { return () => changeImg('', index); } } const allpyRequest = useRequest((data) => saveRequest(data), { manual: true, onError: (e) => { warnning(e.error); }, onSuccess: () => { alertWithoutCancel('', t('fankui1'), false, () => { navigation.goBack(); }); }, }); const img = useCreation(() => { const list = imgList.filter((item) => { return !!item; }); return list.join(','); }, [imgList]); const canSubmit = useCreation(() => { if (content) { return true; } else { return false; } }, [name, phone, content, img]); return ( <>
{t('fankui2')}
setcontent(text)} />
{imgList.map((item, index) => { return ( changeImg(img1, index)} cancelEvent={deleteImg(index)} /> ); })}
{t('qing-shu-ru-lian-xi-xin-xi-xuan-tian')} {t('xing-ming')} {t('lian-xi-dian-hua')} {t('tips8')}
); }