RiderApplyScreen.jsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import * as WebBrowser from 'expo-web-browser';
  2. import * as React from 'react';
  3. import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
  4. import { ScrollView } from 'react-native-gesture-handler';
  5. import { InputItem } from '@ant-design/react-native';
  6. import { useRequest, useCreation } from '@umijs/hooks';
  7. import useModel from 'flooks';
  8. import { useTranslation } from 'react-i18next';
  9. import User from '../../flooks/User'; // detail模块通用方法
  10. import Toast from '../../flooks/Toast'; // detail模块通用方法
  11. import Header from '../../components/Header';
  12. import request from '../../Utils/RequestUtils';
  13. function saveRequest(data) {
  14. return request.post('/cooperateApply/save', {
  15. data,
  16. });
  17. }
  18. export default function RiderApplyScreen({ navigation }) {
  19. const { t } = useTranslation();
  20. const { userInfo } = useModel(User, ['id']);
  21. const { warnning, success } = useModel(Toast, []);
  22. const [name, setname] = React.useState('');
  23. const [phone, setphone] = React.useState('');
  24. const [address, setaddress] = React.useState('');
  25. const allpyRequest = useRequest((data) => saveRequest(data), {
  26. manual: true,
  27. onError: (e) => {
  28. warnning(e.error);
  29. },
  30. onSuccess: () => {
  31. success(t('shen-qing-ti-jiao-cheng-gong'));
  32. navigation.goBack();
  33. },
  34. });
  35. const canSubmit = useCreation(() => {
  36. if (name && phone && address) {
  37. return true;
  38. } else {
  39. return false;
  40. }
  41. }, [name, phone, address]);
  42. return (
  43. <>
  44. <Header title={t('qi-shou-shen-qing')} />
  45. <ScrollView
  46. contentContainerStyle={{
  47. backgroundColor: '#fff',
  48. flexGrow: 1,
  49. }}
  50. >
  51. <Div bg="white">
  52. <InputItem
  53. clear
  54. type="phone"
  55. value={name}
  56. onChange={setname}
  57. placeholder={t('shu-ru-lian-xi-ren')}
  58. style={{ fontSize: 14 }}
  59. labelNumber={7}
  60. >
  61. <Text fontSize="sm">{t('xing-ming')}</Text>
  62. </InputItem>
  63. <InputItem
  64. clear
  65. type="phone"
  66. value={phone}
  67. onChange={setphone}
  68. placeholder={t('shu-ru-lian-xi-dian-hua')}
  69. style={{ fontSize: 14 }}
  70. labelNumber={7}
  71. >
  72. <Text fontSize="sm">{t('lian-xi-dian-hua')}</Text>
  73. </InputItem>
  74. <InputItem
  75. clear
  76. value={address}
  77. onChange={setaddress}
  78. placeholder={t('address')}
  79. style={{ fontSize: 14 }}
  80. labelNumber={7}
  81. >
  82. <Text fontSize="sm">{t('addrss2')}</Text>
  83. </InputItem>
  84. </Div>
  85. <Button
  86. my={30}
  87. mx={130}
  88. fontSize="sm"
  89. block
  90. bg="brand500"
  91. disabled={!canSubmit}
  92. onPress={() => {
  93. allpyRequest.run({
  94. name,
  95. phone,
  96. address,
  97. userId: userInfo.id,
  98. });
  99. }}
  100. >
  101. {t('ti-jiao')}
  102. </Button>
  103. </ScrollView>
  104. </>
  105. );
  106. }