CompanyApplyScreen.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import * as WebBrowser from 'expo-web-browser';
  2. import * as React from 'react';
  3. import { Div, Button, Text } from 'react-native-magnus';
  4. import { ScrollView } from 'react-native-gesture-handler';
  5. import { InputItem, TextareaItem } from '@ant-design/react-native';
  6. import { useRequest, useCreation } from '@umijs/hooks';
  7. import { useTranslation } from 'react-i18next';
  8. import useModel from 'flooks';
  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 CompanyApplyScreen({ 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 [remark, setremark] = 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 && remark) {
  37. return true;
  38. } else {
  39. return false;
  40. }
  41. }, [name, phone, remark]);
  42. return (
  43. <>
  44. <Header title={t('shang-wu-he-zuo-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. >
  60. <Text fontSize="sm">{t('xing-ming')}</Text>
  61. </InputItem>
  62. <InputItem
  63. clear
  64. type="phone"
  65. value={phone}
  66. onChange={setphone}
  67. placeholder={t('shu-ru-lian-xi-dian-hua')}
  68. style={{ fontSize: 14 }}
  69. >
  70. <Text fontSize="sm">{t('lian-xi-dian-hua')}</Text>
  71. </InputItem>
  72. <Text px={15} py={10} fontSize="sm">
  73. {t('qi-wang-he-zuo-de-nei-rong')}
  74. </Text>
  75. <Div px={15}>
  76. <TextareaItem
  77. rows={4}
  78. placeholder={t('tian-jia-shang-pin-jian-jie-bu-chao-guo-50-zi')}
  79. style={{ backgroundColor: '#eee', fontSize: 14, paddingTop: 10 }}
  80. onChange={(text) => setremark(text)}
  81. />
  82. </Div>
  83. </Div>
  84. <Button
  85. my={30}
  86. mx={130}
  87. fontSize="sm"
  88. block
  89. bg="brand500"
  90. disabled={!canSubmit}
  91. onPress={() => {
  92. allpyRequest.run({
  93. name,
  94. phone,
  95. remark,
  96. userId: userInfo.id,
  97. });
  98. }}
  99. >
  100. {t('ti-jiao')}
  101. </Button>
  102. </ScrollView>
  103. </>
  104. );
  105. }