StoreScreen.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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, setModel } from "flooks";
  6. import { useTheme, Text, Button, Layout } from "@ui-kitten/components";
  7. import { useFocusEffect } from "@react-navigation/native";
  8. import verifiedModel from "../../models/verifiedModel";
  9. import NavHeaderBar from "../../components/NavHeaderBar";
  10. import UpLoadImage from "../../components/UpLoadImage";
  11. import FormInput from "../../components/FormInput";
  12. import ListUtil from "../../Utils/ListUtil";
  13. import ScrollPage from "../../components/ScrollPage";
  14. setModel("verifiedModel", verifiedModel);
  15. const styles = StyleSheet.create({
  16. container: {
  17. flex: 1,
  18. paddingTop: 10,
  19. paddingBottom: 33,
  20. paddingHorizontal: 20,
  21. },
  22. imgList: {
  23. flexDirection: "row",
  24. justifyContent: "space-around",
  25. },
  26. imgList2: {
  27. flexDirection: "row",
  28. flexWrap: "wrap",
  29. justifyContent: "center",
  30. },
  31. imgItem: {
  32. paddingVertical: 10,
  33. alignItems: "center",
  34. },
  35. imgItem2: {
  36. paddingVertical: 10,
  37. alignItems: "center",
  38. marginRight: 20,
  39. },
  40. text: {
  41. paddingVertical: 15,
  42. },
  43. btn: {
  44. marginVertical: 30,
  45. alignItems: "center",
  46. },
  47. tips: {
  48. paddingVertical: 20,
  49. paddingHorizontal: 40,
  50. },
  51. });
  52. export default function StoreScreen({ navigation }) {
  53. const theme = useTheme();
  54. const { changeBackground } = useModel("barModel", true);
  55. const {
  56. mid,
  57. registerInfo,
  58. userInfo,
  59. updateMerchant,
  60. changeRegisterInfo,
  61. } = useModel("userModel");
  62. const {
  63. WVWTVK,
  64. KMXEBK,
  65. RGKJPS,
  66. FQIZGN,
  67. HMBWUJ,
  68. MSEUAP,
  69. ONBSYL,
  70. NOMPAT,
  71. YBCDKV,
  72. } = useModel("wordsModel");
  73. const { success, loading } = useModel("loadingModel", true);
  74. const [doorHeadImg, setDoorHeadImg] = React.useState("");
  75. const [img1, setImg1] = React.useState("");
  76. const [img2, setImg2] = React.useState("");
  77. const [img3, setImg3] = React.useState("");
  78. const [img4, setImg4] = React.useState("");
  79. const [img5, setImg5] = React.useState("");
  80. useFocusEffect(
  81. React.useCallback(() => {
  82. changeBackground(theme["color-primary-500"]);
  83. if (mid) {
  84. setDoorHeadImg(userInfo.doorHeadImg || "");
  85. const imgList = new ListUtil(userInfo.img || "");
  86. imgList.setImgVal([setImg1, setImg2, setImg3, setImg4, setImg5]);
  87. } else {
  88. setDoorHeadImg(registerInfo.doorHeadImg || "");
  89. const imgList = new ListUtil(registerInfo.img || "");
  90. imgList.setImgVal([setImg1, setImg2, setImg3, setImg4, setImg5]);
  91. }
  92. }, [])
  93. );
  94. const canSubmit = React.useMemo(() => {
  95. if (doorHeadImg && (img1 || img2 || img3 || img4 || img5)) {
  96. return true;
  97. }
  98. return false;
  99. }, [doorHeadImg, img1, img2, img3, img4, img5]);
  100. function submit() {
  101. const imgList = new ListUtil([img1, img2, img3, img4, img5]);
  102. if (mid) {
  103. loading();
  104. updateMerchant({
  105. doorHeadImg,
  106. img: imgList.getListValue(),
  107. }).then(() => {
  108. success("设置成功");
  109. navigation.goBack();
  110. });
  111. } else {
  112. changeRegisterInfo({
  113. doorHeadImg,
  114. img: imgList.getListValue(),
  115. });
  116. success("设置成功");
  117. navigation.goBack();
  118. }
  119. }
  120. return (
  121. <>
  122. <NavHeaderBar title={YBCDKV} />
  123. <ScrollPage>
  124. <Layout style={styles.container}>
  125. <FormInput
  126. key="doorHeadImg"
  127. label={FQIZGN}
  128. type="label"
  129. textAlign="right"
  130. style={{ paddingVertical: 5 }}
  131. labelStyle={{ width: 100 }}
  132. />
  133. <View style={styles.imgList}>
  134. <View style={styles.imgItem}>
  135. <UpLoadImage
  136. key="handheldIdNo"
  137. value={doorHeadImg}
  138. changeIcon={setDoorHeadImg}
  139. size={67}
  140. aspect={[1, 1]}
  141. />
  142. </View>
  143. </View>
  144. <FormInput
  145. key="img"
  146. label={RGKJPS}
  147. type="label"
  148. textAlign="right"
  149. style={{ paddingVertical: 5 }}
  150. labelStyle={{ width: 200 }}
  151. />
  152. <View style={styles.imgList2}>
  153. <View style={styles.imgItem2}>
  154. <UpLoadImage
  155. key="img1"
  156. value={img1}
  157. changeIcon={setImg1}
  158. size={67}
  159. aspect={[1, 1]}
  160. />
  161. </View>
  162. <View style={styles.imgItem2}>
  163. <UpLoadImage
  164. key="img2"
  165. value={img2}
  166. changeIcon={setImg2}
  167. size={67}
  168. aspect={[1, 1]}
  169. />
  170. </View>
  171. <View style={styles.imgItem2}>
  172. <UpLoadImage
  173. key="img3"
  174. value={img3}
  175. changeIcon={setImg3}
  176. size={67}
  177. aspect={[1, 1]}
  178. />
  179. </View>
  180. <View style={styles.imgItem2}>
  181. <UpLoadImage
  182. key="img4"
  183. value={img4}
  184. changeIcon={setImg4}
  185. size={67}
  186. aspect={[1, 1]}
  187. />
  188. </View>
  189. <View style={styles.imgItem2}>
  190. <UpLoadImage
  191. key="img5"
  192. value={img5}
  193. changeIcon={setImg5}
  194. size={67}
  195. aspect={[1, 1]}
  196. />
  197. </View>
  198. </View>
  199. <View style={styles.btn}>
  200. <Button onPress={submit} disabled={!canSubmit}>
  201. {WVWTVK}
  202. </Button>
  203. </View>
  204. </Layout>
  205. <View style={styles.tips}>
  206. <Text category="c1" status="info">
  207. {KMXEBK}
  208. </Text>
  209. <Text category="c1" status="info">
  210. {ONBSYL}
  211. </Text>
  212. <Text category="c1" status="info">
  213. {NOMPAT}
  214. </Text>
  215. <Text category="c1" status="info">
  216. {HMBWUJ}
  217. </Text>
  218. <Text category="c1" status="info">
  219. {MSEUAP}
  220. </Text>
  221. </View>
  222. </ScrollPage>
  223. </>
  224. );
  225. }