RiderApplyScreen.jsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 User from '../../flooks/User'; // detail模块通用方法
  9. import Toast from '../../flooks/Toast'; // detail模块通用方法
  10. import Header from '../../components/Header';
  11. import request from '../../Utils/RequestUtils';
  12. function saveRequest(data) {
  13. return request.post('/cooperateApply/save', {
  14. data,
  15. });
  16. }
  17. export default function RiderApplyScreen({ navigation }) {
  18. const { userInfo } = useModel(User, ['id']);
  19. const { warnning, success } = useModel(Toast, []);
  20. const [name, setname] = React.useState('');
  21. const [phone, setphone] = React.useState('');
  22. const [address, setaddress] = React.useState('');
  23. const allpyRequest = useRequest((data) => saveRequest(data), {
  24. manual: true,
  25. onError: (e) => {
  26. warnning(e.error);
  27. },
  28. onSuccess: () => {
  29. success('申请提交成功');
  30. navigation.goBack();
  31. },
  32. });
  33. const canSubmit = useCreation(() => {
  34. if (name && phone && address) {
  35. return true;
  36. } else {
  37. return false;
  38. }
  39. }, [name, phone, address]);
  40. return (
  41. <>
  42. <Header title="骑手申请" />
  43. <ScrollView
  44. contentContainerStyle={{
  45. backgroundColor: '#fff',
  46. flexGrow: 1,
  47. }}
  48. >
  49. <Div bg="white">
  50. <InputItem
  51. clear
  52. type="phone"
  53. value={name}
  54. onChange={setname}
  55. placeholder="输入联系人"
  56. style={{ fontSize: 14 }}
  57. labelNumber={7}
  58. >
  59. <Text fontSize="sm">姓名</Text>
  60. </InputItem>
  61. <InputItem
  62. clear
  63. type="phone"
  64. value={phone}
  65. onChange={setphone}
  66. placeholder="输入联系电话"
  67. style={{ fontSize: 14 }}
  68. labelNumber={7}
  69. >
  70. <Text fontSize="sm">联系电话</Text>
  71. </InputItem>
  72. <InputItem
  73. clear
  74. value={address}
  75. onChange={setaddress}
  76. placeholder="请输入期望的工作地址"
  77. style={{ fontSize: 14 }}
  78. labelNumber={7}
  79. >
  80. <Text fontSize="sm">期望的工作地址</Text>
  81. </InputItem>
  82. </Div>
  83. <Button
  84. my={30}
  85. mx={130}
  86. fontSize="sm"
  87. block
  88. bg="brand500"
  89. disabled={!canSubmit}
  90. onPress={() => {
  91. allpyRequest.run({
  92. name,
  93. phone,
  94. address,
  95. userId: userInfo.id,
  96. });
  97. }}
  98. >
  99. 提交
  100. </Button>
  101. </ScrollView>
  102. </>
  103. );
  104. }