CompanyApplyScreen.jsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 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 CompanyApplyScreen({ 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 [remark, setremark] = 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 && remark) {
  35. return true;
  36. } else {
  37. return false;
  38. }
  39. }, [name, phone, remark]);
  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. >
  58. <Text fontSize="sm">姓名</Text>
  59. </InputItem>
  60. <InputItem
  61. clear
  62. type="phone"
  63. value={phone}
  64. onChange={setphone}
  65. placeholder="输入联系电话"
  66. style={{ fontSize: 14 }}
  67. >
  68. <Text fontSize="sm">联系电话</Text>
  69. </InputItem>
  70. <Text px={15} py={10} fontSize="sm">
  71. 期望合作的内容
  72. </Text>
  73. <Div px={15}>
  74. <TextareaItem
  75. rows={4}
  76. placeholder="添加商品简介(不超过50字)"
  77. style={{ backgroundColor: '#eee', fontSize: 14, paddingTop: 10 }}
  78. onChange={(text) => setremark(text)}
  79. />
  80. </Div>
  81. </Div>
  82. <Button
  83. my={30}
  84. mx={130}
  85. fontSize="sm"
  86. block
  87. bg="brand500"
  88. disabled={!canSubmit}
  89. onPress={() => {
  90. allpyRequest.run({
  91. name,
  92. phone,
  93. remark,
  94. userId: userInfo.id,
  95. });
  96. }}
  97. >
  98. 提交
  99. </Button>
  100. </ScrollView>
  101. </>
  102. );
  103. }