RegisterSeScreen.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /* eslint-disable no-shadow */
  2. /* eslint-disable camelcase */
  3. import * as WebBrowser from "expo-web-browser";
  4. import * as React from "react";
  5. import { useModel } from "flooks";
  6. import { StyleSheet } from "react-native";
  7. import {
  8. Layout,
  9. Text,
  10. useTheme,
  11. Button,
  12. Card,
  13. SelectItem,
  14. Icon,
  15. } from "@ui-kitten/components";
  16. import { Div } from "react-native-magnus";
  17. // import { useFocusEffect } from "@react-navigation/native";
  18. import { useMount } from "@umijs/hooks";
  19. import ScrollPage from "../components/ScrollPage";
  20. import FormInput from "../components/FormInput";
  21. import ConnectButton from "../components/ConnectButton";
  22. import GuideHeaderBar from "../components/GuideHeaderBar";
  23. import * as RootNavigation from "../navigation/RootNavigation";
  24. const styles = StyleSheet.create({
  25. container: {
  26. flex: 1,
  27. paddingBottom: 33,
  28. },
  29. tabContent: {
  30. backgroundColor: "#fff",
  31. marginTop: 20,
  32. },
  33. logo: {
  34. width: 100,
  35. height: 100,
  36. alignSelf: "center",
  37. },
  38. logo2: {
  39. width: 97,
  40. height: 21,
  41. alignSelf: "center",
  42. marginTop: 2,
  43. },
  44. text: {
  45. marginTop: 16,
  46. },
  47. layoutLeft: {
  48. flexDirection: "row",
  49. paddingVertical: 10,
  50. justifyContent: "center",
  51. },
  52. form: {
  53. paddingHorizontal: 26,
  54. paddingVertical: 20,
  55. },
  56. });
  57. const ForwardIcon = props => <Icon {...props} name="arrow-ios-forward" />;
  58. export default function RegisterScreen() {
  59. const theme = useTheme();
  60. const { changeBackground } = useModel("barModel");
  61. const { httpGet } = useModel("httpModel", true);
  62. const { mid, registerSecend, registerInfo, userInfo, checkAgain } = useModel(
  63. "userModel"
  64. );
  65. const { verifiedInfo, registerVerifiedInfo } = useModel("verifiedModel");
  66. const {
  67. guideHome_title1,
  68. guideHome_title2,
  69. guideHome_form_1,
  70. guideHome_form_2,
  71. guideHome_form_4,
  72. guideHome_form_5,
  73. guideHome_form_6,
  74. guideHome_form_7,
  75. // guideHome_pla_2,
  76. guideHome_pla_3,
  77. next,
  78. TTBMND,
  79. TVZBVQ,
  80. } = useModel("wordsModel");
  81. const [categoryList, changeCategoryList] = React.useState([]);
  82. const [merchantNatureList, changeMerchantNatureList] = React.useState([]);
  83. const [qualification, changeQualification] = React.useState("");
  84. useMount(() => {
  85. changeBackground(theme["color-primary-500"]);
  86. httpGet("/category/tree", { id: 1 }).then(res => {
  87. changeCategoryList(res);
  88. });
  89. httpGet("/merchantNature/all").then(res => {
  90. changeMerchantNatureList(res.content);
  91. });
  92. });
  93. const [category, changeCategory] = React.useState("");
  94. const [address, changeAddress] = React.useState("");
  95. const [week, changeWeek] = React.useState("");
  96. const [startTime, changeStartTime] = React.useState("08:00:00");
  97. const [endTime, changeEndTime] = React.useState("22:00:00");
  98. const [merchantNatureId, changeMerchantNatureId] = React.useState("");
  99. const [logo, changeLogo] = React.useState();
  100. const [doorHeadImg, changeDoorHeadeImg] = React.useState("");
  101. const [img, changeImg] = React.useState("");
  102. // 法人信息
  103. const [realName, setRealName] = React.useState("");
  104. const [idNo, setIdNo] = React.useState("");
  105. const [idNoImg, setIdNoImg] = React.useState("");
  106. const [handheldIdNo, setHandheldIdNo] = React.useState("");
  107. React.useEffect(() => {
  108. if (registerVerifiedInfo && registerVerifiedInfo.realName) {
  109. setRealName(registerVerifiedInfo.realName);
  110. }
  111. if (registerVerifiedInfo && registerVerifiedInfo.idNo) {
  112. setIdNo(registerVerifiedInfo.idNo);
  113. }
  114. if (registerVerifiedInfo && registerVerifiedInfo.idNoImg) {
  115. setIdNoImg(registerVerifiedInfo.idNoImg);
  116. }
  117. if (registerVerifiedInfo && registerVerifiedInfo.handheldIdNo) {
  118. setHandheldIdNo(registerVerifiedInfo.handheldIdNo);
  119. }
  120. if (verifiedInfo && verifiedInfo.realName) {
  121. setRealName(verifiedInfo.realName);
  122. }
  123. if (verifiedInfo && verifiedInfo.idNo) {
  124. setIdNo(verifiedInfo.idNo);
  125. }
  126. if (verifiedInfo && verifiedInfo.idNoImg) {
  127. setIdNoImg(verifiedInfo.idNoImg);
  128. }
  129. if (verifiedInfo && verifiedInfo.handheldIdNo) {
  130. setHandheldIdNo(verifiedInfo.handheldIdNo);
  131. }
  132. }, [registerVerifiedInfo, verifiedInfo]);
  133. React.useEffect(() => {
  134. if (registerInfo && registerInfo.qualification) {
  135. changeQualification(registerInfo.qualification);
  136. }
  137. if (registerInfo && registerInfo.doorHeadImg) {
  138. changeDoorHeadeImg(registerInfo.doorHeadImg);
  139. }
  140. if (registerInfo && registerInfo.img) {
  141. changeImg(registerInfo.img);
  142. }
  143. if (registerInfo && registerInfo.address) {
  144. changeAddress(registerInfo.address);
  145. }
  146. }, [registerInfo]);
  147. React.useEffect(() => {
  148. if (mid) {
  149. if (userInfo.category.length > 0) {
  150. changeCategory(userInfo.category[0].id);
  151. }
  152. changeAddress(userInfo.address);
  153. changeWeek(userInfo.week);
  154. changeLogo(userInfo.logo);
  155. changeMerchantNatureId(userInfo.merchantNatureId);
  156. changeStartTime(userInfo.startTime);
  157. changeEndTime(userInfo.endTime);
  158. changeQualification(userInfo.qualification);
  159. changeDoorHeadeImg(userInfo.doorHeadImg);
  160. changeImg(userInfo.img);
  161. }
  162. }, [userInfo]);
  163. const timeValue = React.useMemo(() => {
  164. if (week && startTime && endTime) {
  165. return `${week} ${startTime}~${endTime}`;
  166. }
  167. return " ";
  168. }, [week, startTime, endTime]);
  169. const canNext = React.useMemo(() => {
  170. if (
  171. category &&
  172. address &&
  173. merchantNatureId &&
  174. logo &&
  175. week &&
  176. startTime &&
  177. endTime &&
  178. doorHeadImg &&
  179. img &&
  180. realName &&
  181. idNo &&
  182. idNoImg &&
  183. handheldIdNo &&
  184. qualification
  185. ) {
  186. return true;
  187. }
  188. return false;
  189. }, [
  190. category,
  191. address,
  192. merchantNatureId,
  193. logo,
  194. week,
  195. startTime,
  196. endTime,
  197. doorHeadImg,
  198. img,
  199. realName,
  200. idNo,
  201. idNoImg,
  202. handheldIdNo,
  203. qualification,
  204. ]);
  205. return (
  206. <>
  207. <GuideHeaderBar />
  208. <ScrollPage>
  209. <Layout style={styles.container}>
  210. {mid === 0 && (
  211. <Card appearance="headFilled">
  212. <Text category="s1">{guideHome_title1}</Text>
  213. <Text category="s1">{guideHome_title2}</Text>
  214. </Card>
  215. )}
  216. <Card appearance="formFilled">
  217. {/* 输入商家名称 */}
  218. <FormInput
  219. label={guideHome_form_1}
  220. selectTitle={guideHome_form_1}
  221. type="select"
  222. value={category}
  223. onChange={changeCategory}
  224. textAlign="right"
  225. selectList={categoryList}
  226. style={{ paddingVertical: 5 }}
  227. />
  228. {/* <FormInput
  229. label={guideHome_form_2}
  230. value={address}
  231. onChange={changeAddress}
  232. textAlign="right"
  233. /> */}
  234. <FormInput
  235. label={guideHome_form_2}
  236. type="url"
  237. value={address || " "}
  238. textAlign="right"
  239. style={{ paddingVertical: 5 }}
  240. changePath={() => {
  241. RootNavigation.navigate("SearchMap");
  242. }}
  243. />
  244. <FormInput
  245. label={guideHome_form_4}
  246. selectTitle={guideHome_form_4}
  247. type="openTime"
  248. week={week}
  249. startTime={startTime}
  250. endTime={endTime}
  251. onChange={(week, startTime, endTime) => {
  252. changeWeek(week);
  253. changeStartTime(startTime);
  254. changeEndTime(endTime);
  255. }}
  256. textAlign="right"
  257. style={{ paddingVertical: 5 }}
  258. />
  259. <FormInput
  260. label={guideHome_form_5}
  261. type="url"
  262. value={qualification ? TVZBVQ : " "}
  263. textAlign="right"
  264. style={{ paddingVertical: 5 }}
  265. changePath={() => {
  266. RootNavigation.navigate("Qualification");
  267. }}
  268. />
  269. <FormInput
  270. label="门店信息"
  271. type="url"
  272. value={doorHeadImg && img ? TVZBVQ : " "}
  273. textAlign="right"
  274. style={{ paddingVertical: 5 }}
  275. changePath={() => {
  276. RootNavigation.navigate("Store");
  277. }}
  278. />
  279. <FormInput
  280. label="法人信息"
  281. type="url"
  282. value={realName && idNo && idNoImg && handheldIdNo ? TVZBVQ : " "}
  283. textAlign="right"
  284. style={{ paddingVertical: 5 }}
  285. changePath={() => {
  286. RootNavigation.navigate("LegalPerson");
  287. }}
  288. />
  289. <FormInput
  290. label={guideHome_form_6}
  291. sub={guideHome_pla_3}
  292. selectTitle={guideHome_form_6}
  293. type="select"
  294. value={merchantNatureId}
  295. textAlign="right"
  296. style={{ paddingVertical: 5 }}
  297. onChange={changeMerchantNatureId}
  298. selectList={merchantNatureList}
  299. />
  300. <FormInput
  301. label={guideHome_form_7}
  302. type="img"
  303. value={logo}
  304. textAlign="right"
  305. onChange={changeLogo}
  306. />
  307. <Layout style={styles.layoutLeft} level="1">
  308. {mid !== 0 ? (
  309. <Button
  310. status="primary"
  311. disabled={!canNext}
  312. onPress={() => {
  313. const categorys = [...categoryList].filter(item => {
  314. return item.id === category;
  315. });
  316. checkAgain({
  317. category: categorys,
  318. address,
  319. week,
  320. startTime,
  321. endTime,
  322. qualification,
  323. merchantNatureId,
  324. logo,
  325. });
  326. }}
  327. >
  328. {TTBMND}
  329. </Button>
  330. ) : (
  331. <Button
  332. status="primary"
  333. disabled={!canNext}
  334. onPress={() =>
  335. registerSecend({
  336. category,
  337. address,
  338. week,
  339. startTime,
  340. endTime,
  341. qualification,
  342. merchantNatureId,
  343. logo,
  344. img,
  345. doorHeadImg,
  346. })
  347. }
  348. >
  349. {next}
  350. </Button>
  351. )}
  352. </Layout>
  353. </Card>
  354. <ConnectButton />
  355. </Layout>
  356. </ScrollPage>
  357. </>
  358. );
  359. }