StoreScreen.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. },
  30. imgItem: {
  31. paddingVertical: 10,
  32. alignItems: "center",
  33. },
  34. imgItem2: {
  35. paddingVertical: 10,
  36. alignItems: "center",
  37. marginRight: 20,
  38. },
  39. text: {
  40. paddingVertical: 15,
  41. },
  42. btn: {
  43. marginVertical: 30,
  44. alignItems: "center",
  45. },
  46. tips: {
  47. paddingVertical: 20,
  48. paddingHorizontal: 40,
  49. },
  50. });
  51. export default function StoreScreen({ navigation }) {
  52. const theme = useTheme();
  53. const { changeBackground } = useModel("barModel", true);
  54. const {
  55. mid,
  56. registerInfo,
  57. userInfo,
  58. updateMerchant,
  59. changeRegisterInfo,
  60. } = useModel("userModel");
  61. const { success, loading } = useModel("loadingModel", true);
  62. const [doorHeadImg, setDoorHeadImg] = React.useState("");
  63. const [img1, setImg1] = React.useState("");
  64. const [img2, setImg2] = React.useState("");
  65. const [img3, setImg3] = React.useState("");
  66. const [img4, setImg4] = React.useState("");
  67. const [img5, setImg5] = React.useState("");
  68. useFocusEffect(
  69. React.useCallback(() => {
  70. changeBackground(theme["color-primary-500"]);
  71. if (mid) {
  72. setDoorHeadImg(userInfo.doorHeadImg || "");
  73. const imgList = new ListUtil(userInfo.img || "");
  74. imgList.setImgVal([setImg1, setImg2, setImg3, setImg4, setImg5]);
  75. } else {
  76. setDoorHeadImg(registerInfo.doorHeadImg || "");
  77. const imgList = new ListUtil(registerInfo.img || "");
  78. imgList.setImgVal([setImg1, setImg2, setImg3, setImg4, setImg5]);
  79. }
  80. }, [])
  81. );
  82. const canSubmit = React.useMemo(() => {
  83. if (doorHeadImg && (img1 || img2 || img3 || img4 || img5)) {
  84. return true;
  85. }
  86. return false;
  87. }, [doorHeadImg, img1, img2, img3, img4, img5]);
  88. function submit() {
  89. const imgList = new ListUtil([img1, img2, img3, img4, img5]);
  90. if (mid) {
  91. loading();
  92. updateMerchant({
  93. doorHeadImg,
  94. img: imgList.getListValue(),
  95. }).then(() => {
  96. success("设置成功");
  97. navigation.goBack();
  98. });
  99. } else {
  100. changeRegisterInfo({
  101. doorHeadImg,
  102. img: imgList.getListValue(),
  103. });
  104. success("设置成功");
  105. navigation.goBack();
  106. }
  107. }
  108. return (
  109. <>
  110. <NavHeaderBar title="编辑门店信息" />
  111. <ScrollPage>
  112. <Layout style={styles.container}>
  113. <FormInput
  114. key="doorHeadImg"
  115. label="店面门头:"
  116. type="label"
  117. textAlign="right"
  118. style={{ paddingVertical: 5 }}
  119. labelStyle={{ width: 100 }}
  120. />
  121. <View style={styles.imgList}>
  122. <View style={styles.imgItem}>
  123. <UpLoadImage
  124. key="handheldIdNo"
  125. value={doorHeadImg}
  126. changeIcon={setDoorHeadImg}
  127. size={67}
  128. />
  129. </View>
  130. </View>
  131. <FormInput
  132. key="img"
  133. label="店面内部环境拍照:(最多五张)"
  134. type="label"
  135. textAlign="right"
  136. style={{ paddingVertical: 5 }}
  137. labelStyle={{ width: 200 }}
  138. />
  139. <View style={styles.imgList2}>
  140. <View style={styles.imgItem2}>
  141. <UpLoadImage
  142. key="img1"
  143. value={img1}
  144. changeIcon={setImg1}
  145. size={67}
  146. />
  147. </View>
  148. <View style={styles.imgItem2}>
  149. <UpLoadImage
  150. key="img2"
  151. value={img2}
  152. changeIcon={setImg2}
  153. size={67}
  154. />
  155. </View>
  156. <View style={styles.imgItem2}>
  157. <UpLoadImage
  158. key="img3"
  159. value={img3}
  160. changeIcon={setImg3}
  161. size={67}
  162. />
  163. </View>
  164. <View style={styles.imgItem2}>
  165. <UpLoadImage
  166. key="img4"
  167. value={img4}
  168. changeIcon={setImg4}
  169. size={67}
  170. />
  171. </View>
  172. <View style={styles.imgItem2}>
  173. <UpLoadImage
  174. key="img5"
  175. value={img5}
  176. changeIcon={setImg5}
  177. size={67}
  178. />
  179. </View>
  180. </View>
  181. <View style={styles.btn}>
  182. <Button onPress={submit} disabled={!canSubmit}>
  183. 上传
  184. </Button>
  185. </View>
  186. </Layout>
  187. <View style={styles.tips}>
  188. <Text category="c1" status="info">
  189. 提示:
  190. </Text>
  191. <Text category="c1" status="info">
  192. 1、需上传店面门头及店铺内部环境照片。
  193. </Text>
  194. <Text category="c1" status="info">
  195. 2、照片需清晰、真实。
  196. </Text>
  197. </View>
  198. </ScrollPage>
  199. </>
  200. );
  201. }