MerchatApplyScreen.jsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 MerchatApplyScreen({ 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 [merName, setmerName] = React.useState('');
  23. const [category, setcategory] = 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('申请提交成功');
  32. navigation.goBack();
  33. },
  34. });
  35. const canSubmit = useCreation(() => {
  36. if (name && phone && merName && category && address) {
  37. return true;
  38. } else {
  39. return false;
  40. }
  41. }, [name, phone, merName, category, address]);
  42. return (
  43. <>
  44. <Header title="开店申请" />
  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="输入联系人"
  58. style={{ fontSize: 14 }}
  59. >
  60. <Text fontSize="sm">联系人</Text>
  61. </InputItem>
  62. <InputItem
  63. clear
  64. type="phone"
  65. value={phone}
  66. onChange={setphone}
  67. placeholder="输入联系电话"
  68. style={{ fontSize: 14 }}
  69. >
  70. <Text fontSize="sm">联系电话</Text>
  71. </InputItem>
  72. <InputItem
  73. clear
  74. value={merName}
  75. onChange={setmerName}
  76. placeholder="输入店铺名称"
  77. style={{ fontSize: 14 }}
  78. >
  79. <Text fontSize="sm">店铺名称</Text>
  80. </InputItem>
  81. <InputItem
  82. clear
  83. value={category}
  84. onChange={setcategory}
  85. placeholder="输入经营类型"
  86. style={{ fontSize: 14 }}
  87. >
  88. <Text fontSize="sm">经营类型</Text>
  89. </InputItem>
  90. <InputItem
  91. clear
  92. value={address}
  93. onChange={setaddress}
  94. placeholder="请输入店铺地址"
  95. style={{ fontSize: 14 }}
  96. >
  97. <Text fontSize="sm">店铺地址</Text>
  98. </InputItem>
  99. </Div>
  100. <Button
  101. my={30}
  102. mx={130}
  103. fontSize="sm"
  104. block
  105. bg="brand500"
  106. disabled={!canSubmit}
  107. onPress={() => {
  108. allpyRequest.run({
  109. name,
  110. phone,
  111. merName,
  112. category,
  113. address,
  114. userId: userInfo.id,
  115. });
  116. }}
  117. >
  118. 提交
  119. </Button>
  120. </ScrollView>
  121. </>
  122. );
  123. }