| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- /* eslint-disable no-underscore-dangle */
- import * as WebBrowser from "expo-web-browser";
- import * as React from "react";
- import { StyleSheet, View } from "react-native";
- import { useModel, setModel } from "flooks";
- import { useTheme, Text, Button, Layout } from "@ui-kitten/components";
- import { useFocusEffect } from "@react-navigation/native";
- import verifiedModel from "../../models/verifiedModel";
- import NavHeaderBar from "../../components/NavHeaderBar";
- import UpLoadImage from "../../components/UpLoadImage";
- import FormInput from "../../components/FormInput";
- import ListUtil from "../../Utils/ListUtil";
- import ScrollPage from "../../components/ScrollPage";
- setModel("verifiedModel", verifiedModel);
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- paddingTop: 10,
- paddingBottom: 33,
- paddingHorizontal: 20,
- },
- imgList: {
- flexDirection: "row",
- justifyContent: "space-around",
- },
- imgList2: {
- flexDirection: "row",
- flexWrap: "wrap",
- },
- imgItem: {
- paddingVertical: 10,
- alignItems: "center",
- },
- imgItem2: {
- paddingVertical: 10,
- alignItems: "center",
- marginRight: 20,
- },
- text: {
- paddingVertical: 15,
- },
- btn: {
- marginVertical: 30,
- alignItems: "center",
- },
- tips: {
- paddingVertical: 20,
- paddingHorizontal: 40,
- },
- });
- export default function StoreScreen({ navigation }) {
- const theme = useTheme();
- const { changeBackground } = useModel("barModel", true);
- const {
- mid,
- registerInfo,
- userInfo,
- updateMerchant,
- changeRegisterInfo,
- } = useModel("userModel");
- const { success, loading } = useModel("loadingModel", true);
- const [doorHeadImg, setDoorHeadImg] = React.useState("");
- const [img1, setImg1] = React.useState("");
- const [img2, setImg2] = React.useState("");
- const [img3, setImg3] = React.useState("");
- const [img4, setImg4] = React.useState("");
- const [img5, setImg5] = React.useState("");
- useFocusEffect(
- React.useCallback(() => {
- changeBackground(theme["color-primary-500"]);
- if (mid) {
- setDoorHeadImg(userInfo.doorHeadImg || "");
- const imgList = new ListUtil(userInfo.img || "");
- imgList.setImgVal([setImg1, setImg2, setImg3, setImg4, setImg5]);
- } else {
- setDoorHeadImg(registerInfo.doorHeadImg || "");
- const imgList = new ListUtil(registerInfo.img || "");
- imgList.setImgVal([setImg1, setImg2, setImg3, setImg4, setImg5]);
- }
- }, [])
- );
- const canSubmit = React.useMemo(() => {
- if (doorHeadImg && (img1 || img2 || img3 || img4 || img5)) {
- return true;
- }
- return false;
- }, [doorHeadImg, img1, img2, img3, img4, img5]);
- function submit() {
- const imgList = new ListUtil([img1, img2, img3, img4, img5]);
- if (mid) {
- loading();
- updateMerchant({
- doorHeadImg,
- img: imgList.getListValue(),
- }).then(() => {
- success("设置成功");
- navigation.goBack();
- });
- } else {
- changeRegisterInfo({
- doorHeadImg,
- img: imgList.getListValue(),
- });
- success("设置成功");
- navigation.goBack();
- }
- }
- return (
- <>
- <NavHeaderBar title="编辑门店信息" />
- <ScrollPage>
- <Layout style={styles.container}>
- <FormInput
- key="doorHeadImg"
- label="店面门头:"
- type="label"
- textAlign="right"
- style={{ paddingVertical: 5 }}
- labelStyle={{ width: 100 }}
- />
- <View style={styles.imgList}>
- <View style={styles.imgItem}>
- <UpLoadImage
- key="handheldIdNo"
- value={doorHeadImg}
- changeIcon={setDoorHeadImg}
- size={67}
- />
- </View>
- </View>
- <FormInput
- key="img"
- label="店面内部环境拍照:(最多五张)"
- type="label"
- textAlign="right"
- style={{ paddingVertical: 5 }}
- labelStyle={{ width: 200 }}
- />
- <View style={styles.imgList2}>
- <View style={styles.imgItem2}>
- <UpLoadImage
- key="img1"
- value={img1}
- changeIcon={setImg1}
- size={67}
- />
- </View>
- <View style={styles.imgItem2}>
- <UpLoadImage
- key="img2"
- value={img2}
- changeIcon={setImg2}
- size={67}
- />
- </View>
- <View style={styles.imgItem2}>
- <UpLoadImage
- key="img3"
- value={img3}
- changeIcon={setImg3}
- size={67}
- />
- </View>
- <View style={styles.imgItem2}>
- <UpLoadImage
- key="img4"
- value={img4}
- changeIcon={setImg4}
- size={67}
- />
- </View>
- <View style={styles.imgItem2}>
- <UpLoadImage
- key="img5"
- value={img5}
- changeIcon={setImg5}
- size={67}
- />
- </View>
- </View>
- <View style={styles.btn}>
- <Button onPress={submit} disabled={!canSubmit}>
- 上传
- </Button>
- </View>
- </Layout>
- <View style={styles.tips}>
- <Text category="c1" status="info">
- 提示:
- </Text>
- <Text category="c1" status="info">
- 1、需上传店面门头及店铺内部环境照片。
- </Text>
- <Text category="c1" status="info">
- 2、照片需清晰、真实。
- </Text>
- </View>
- </ScrollPage>
- </>
- );
- }
|