LegalPersonScreen.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /* eslint-disable no-underscore-dangle */
  2. import * as WebBrowser from "expo-web-browser";
  3. import * as React from "react";
  4. import { StyleSheet, View } from "react-native";
  5. import { useModel } from "flooks";
  6. import { useTheme, Text, Button, Layout } from "@ui-kitten/components";
  7. import { useFocusEffect } from "@react-navigation/native";
  8. import NavHeaderBar from "../../components/NavHeaderBar";
  9. import UpLoadImage from "../../components/UpLoadImage";
  10. import FormInput from "../../components/FormInput";
  11. import ListUtil from "../../Utils/ListUtil";
  12. import ScrollPage from "../../components/ScrollPage";
  13. const styles = StyleSheet.create({
  14. container: {
  15. flex: 1,
  16. paddingTop: 10,
  17. paddingBottom: 33,
  18. paddingHorizontal: 20,
  19. },
  20. imgList: {
  21. flexDirection: "row",
  22. justifyContent: "space-around",
  23. },
  24. imgItem: {
  25. paddingVertical: 10,
  26. alignItems: "center",
  27. },
  28. text: {
  29. paddingVertical: 15,
  30. },
  31. btn: {
  32. marginVertical: 30,
  33. alignItems: "center",
  34. },
  35. tips: {
  36. paddingVertical: 20,
  37. paddingHorizontal: 40,
  38. },
  39. });
  40. export default function LegalPersonScreen({ navigation }) {
  41. const theme = useTheme();
  42. const { changeBackground } = useModel("barModel", true);
  43. const { mid } = useModel("userModel");
  44. const { success } = useModel("loadingModel", true);
  45. const {
  46. GCXGVF,
  47. MSEUAP,
  48. LUPPEG,
  49. TWWYNY,
  50. OXLQHX,
  51. AZWBTB,
  52. AZMDQP,
  53. SARAST,
  54. NIOXWF,
  55. KYPQJQ,
  56. WVWTVK,
  57. KMXEBK,
  58. ONBSYL,
  59. NOMPAT,
  60. HMBWUJ,
  61. DTEOMV,
  62. } = useModel("wordsModel");
  63. const {
  64. getVerfied,
  65. verifiedInfo,
  66. registerVerifiedInfo,
  67. saveVeriFied,
  68. } = useModel("verifiedModel");
  69. const [realName, setRealName] = React.useState("");
  70. const [idNo, setIdNo] = React.useState("");
  71. const [idNoImgBefore, setIdNoImgBefore] = React.useState("");
  72. const [idNoImgAfter, setIdNoImgAfter] = React.useState("");
  73. const [handheldIdNo, setHandheldIdNo] = React.useState("");
  74. useFocusEffect(
  75. React.useCallback(() => {
  76. changeBackground(theme["color-primary-500"]);
  77. getVerfied().then(() => {
  78. if (mid) {
  79. setRealName(verifiedInfo.realName || "");
  80. setIdNo(verifiedInfo.idNo || "");
  81. const _imgList = new ListUtil(verifiedInfo.idNoImg || "");
  82. _imgList.getOneTow(setIdNoImgBefore, setIdNoImgAfter);
  83. setHandheldIdNo(verifiedInfo.handheldIdNo || "");
  84. } else {
  85. setRealName(registerVerifiedInfo.realName || "");
  86. setIdNo(registerVerifiedInfo.idNo || "");
  87. const _imgList = new ListUtil(registerVerifiedInfo.idNoImg || "");
  88. _imgList.getOneTow(setIdNoImgBefore, setIdNoImgAfter);
  89. setHandheldIdNo(registerVerifiedInfo.handheldIdNo || "");
  90. }
  91. });
  92. }, [])
  93. );
  94. const canSubmit = React.useMemo(() => {
  95. if (realName && idNo && idNoImgBefore && idNoImgAfter && handheldIdNo) {
  96. return true;
  97. }
  98. return false;
  99. }, [realName, idNo, idNoImgBefore, idNoImgAfter, handheldIdNo]);
  100. function submit() {
  101. const _imgList = new ListUtil([idNoImgBefore, idNoImgAfter]);
  102. const idNoImg = _imgList.getListValue();
  103. saveVeriFied({ realName, idNo, idNoImg, handheldIdNo }).then(() => {
  104. success(DTEOMV);
  105. navigation.goBack();
  106. });
  107. }
  108. return (
  109. <>
  110. <NavHeaderBar title={GCXGVF} />
  111. <ScrollPage>
  112. <Layout style={styles.container}>
  113. <FormInput
  114. key="realName"
  115. label={LUPPEG}
  116. placeholder={TWWYNY}
  117. value={realName}
  118. onChange={setRealName}
  119. textAlign="right"
  120. style={{ paddingVertical: 5 }}
  121. labelStyle={{ width: 100 }}
  122. />
  123. <FormInput
  124. key="idNo"
  125. label={OXLQHX}
  126. placeholder={AZWBTB}
  127. value={idNo}
  128. onChange={setIdNo}
  129. textAlign="right"
  130. style={{ paddingVertical: 5 }}
  131. labelStyle={{ width: 100 }}
  132. />
  133. <FormInput
  134. key="before"
  135. label={AZMDQP}
  136. type="label"
  137. textAlign="right"
  138. style={{ paddingVertical: 5 }}
  139. labelStyle={{ width: 100 }}
  140. />
  141. <View style={styles.imgList}>
  142. <View style={styles.imgItem}>
  143. <UpLoadImage
  144. key="before"
  145. value={idNoImgBefore}
  146. changeIcon={setIdNoImgBefore}
  147. size={67}
  148. aspect={[1, 1]}
  149. />
  150. <Text category="c1" status="info" style={styles.text}>
  151. {SARAST}
  152. </Text>
  153. </View>
  154. <View style={styles.imgItem}>
  155. <UpLoadImage
  156. key="after"
  157. value={idNoImgAfter}
  158. changeIcon={setIdNoImgAfter}
  159. size={67}
  160. aspect={[1, 1]}
  161. />
  162. <Text category="c1" status="info" style={styles.text}>
  163. {NIOXWF}
  164. </Text>
  165. </View>
  166. </View>
  167. <FormInput
  168. key="handheldIdNo"
  169. label={KYPQJQ}
  170. type="label"
  171. textAlign="right"
  172. style={{ paddingVertical: 5 }}
  173. labelStyle={{ width: 100 }}
  174. />
  175. <View style={styles.imgList}>
  176. <View style={styles.imgItem}>
  177. <UpLoadImage
  178. key="handheldIdNo"
  179. value={handheldIdNo}
  180. changeIcon={setHandheldIdNo}
  181. size={67}
  182. aspect={[1, 1]}
  183. />
  184. </View>
  185. </View>
  186. <View style={styles.btn}>
  187. <Button onPress={submit} disabled={!canSubmit}>
  188. {WVWTVK}
  189. </Button>
  190. </View>
  191. </Layout>
  192. <View style={styles.tips}>
  193. <Text category="c1" status="info">
  194. {KMXEBK}
  195. </Text>
  196. <Text category="c1" status="info">
  197. {ONBSYL}
  198. </Text>
  199. <Text category="c1" status="info">
  200. {NOMPAT}
  201. </Text>
  202. <Text category="c1" status="info">
  203. {HMBWUJ}
  204. </Text>
  205. <Text category="c1" status="info">
  206. {MSEUAP}
  207. </Text>
  208. </View>
  209. </ScrollPage>
  210. </>
  211. );
  212. }