panhui 5 年之前
父節點
當前提交
4e8399901e

+ 89 - 62
App.js

@@ -8,11 +8,12 @@ import {
   Layout,
   Layout,
   IconRegistry,
   IconRegistry,
 } from "@ui-kitten/components";
 } from "@ui-kitten/components";
+import { Provider } from "@ant-design/react-native";
 import { EvaIconsPack } from "@ui-kitten/eva-icons";
 import { EvaIconsPack } from "@ui-kitten/eva-icons";
 import { SplashScreen } from "expo";
 import { SplashScreen } from "expo";
 import * as Font from "expo-font";
 import * as Font from "expo-font";
 import { Ionicons } from "@expo/vector-icons";
 import { Ionicons } from "@expo/vector-icons";
-import { NavigationContainer } from "@react-navigation/native";
+import { NavigationContainer, CommonActions } from "@react-navigation/native";
 import {
 import {
   createStackNavigator,
   createStackNavigator,
   CardStyleInterpolators,
   CardStyleInterpolators,
@@ -24,7 +25,6 @@ import * as model from "./models";
 import { default as theme } from "./theme.json"; // <-- Import app theme
 import { default as theme } from "./theme.json"; // <-- Import app theme
 import { default as customMapping } from "./mapping.json"; // <-- Import app theme
 import { default as customMapping } from "./mapping.json"; // <-- Import app theme
 import Dialog from "./components/Dialog";
 import Dialog from "./components/Dialog";
-import Loading from "./components/Loading";
 
 
 import BottomTabNavigator from "./navigation/BottomTabNavigator";
 import BottomTabNavigator from "./navigation/BottomTabNavigator";
 import LoginStackNavigator from "./navigation/LoginStackNavigator";
 import LoginStackNavigator from "./navigation/LoginStackNavigator";
@@ -41,6 +41,7 @@ const fontFile = require("./assets/fonts/SpaceMono-Regular.ttf");
 export default function App(props) {
 export default function App(props) {
   const [isLoadingComplete, setLoadingComplete] = React.useState(false);
   const [isLoadingComplete, setLoadingComplete] = React.useState(false);
   const { getWords } = useModel("wordsModel", true);
   const { getWords } = useModel("wordsModel", true);
+  const { loading, clearLoading } = useModel("loadingModel", true);
 
 
   // Load any resources or data that we need prior to rendering the app
   // Load any resources or data that we need prior to rendering the app
   React.useEffect(() => {
   React.useEffect(() => {
@@ -79,65 +80,104 @@ export default function App(props) {
     loadResourcesAndDataAsync();
     loadResourcesAndDataAsync();
   }, []);
   }, []);
 
 
-  const [loginState, setLogin] = React.useState("loading");
+  const [initRouteName, setInit] = React.useState("");
   const {
   const {
     getUserInfo,
     getUserInfo,
     getGuideStep,
     getGuideStep,
     initApp,
     initApp,
     refreashReason,
     refreashReason,
     changeInIt,
     changeInIt,
+    setinitRoute,
   } = useModel("userModel");
   } = useModel("userModel");
 
 
   React.useEffect(() => {
   React.useEffect(() => {
-    if (initApp && refreashReason !== "guideStep") {
-      setLogin("loading");
-      getUserInfo()
+    function getLogin() {
+      if (refreashReason !== "guideStep") {
+        return getUserInfo();
+      }
+      return Promise.resolve();
+    }
+
+    if (initApp && initRouteName) {
+      loading();
+    }
+
+    if (initApp) {
+      getLogin()
         .then(() => {
         .then(() => {
-          getGuideStep().then(res => {
-            if (res === "finish") {
-              setLogin("login");
-            } else {
-              setLogin(res);
-            }
-          });
+          return getGuideStep();
         })
         })
-        .catch(() => {
-          setLogin("loginOut");
-        })
-        .finally(() => {
-          changeInIt();
-        });
-    } else if (initApp && refreashReason === "guideStep") {
-      setLogin("loading");
-      getGuideStep()
         .then(res => {
         .then(res => {
-          if (res === "finish") {
-            setLogin("login");
-          } else {
-            setLogin(res);
+          switch (res) {
+            case "finish":
+              setInit("Root");
+              break;
+            case "ComeBack":
+              setinitRoute("RegisterSe");
+              setInit("Login");
+              break;
+            case "1":
+              setInit("Guide1");
+              break;
+            case "2":
+              setInit("Guide2");
+              break;
+            case "3":
+              setInit("Guide3");
+              break;
+            case "4":
+              setInit("Guide4");
+              break;
+            case "5":
+              setInit("StoreAudit");
+              break;
+            default:
+              setInit("Guide1");
+              break;
           }
           }
         })
         })
+        .catch(() => {
+          //  未登录
+          setinitRoute("Login");
+          setInit("Login");
+        })
         .finally(() => {
         .finally(() => {
           changeInIt();
           changeInIt();
         });
         });
     }
     }
   }, [initApp]);
   }, [initApp]);
 
 
-  if (!isLoadingComplete && !props.skipLoadingScreen) {
+  React.useEffect(() => {
+    const { name } = navigationRef.current.getCurrentRoute();
+    if (name !== initRouteName && initRouteName) {
+      navigationRef.current.dispatch(
+        CommonActions.reset({
+          index: 0,
+          routes: [
+            {
+              name: initRouteName,
+            },
+          ],
+        })
+      );
+      clearLoading();
+    }
+  }, [initRouteName]);
+
+  if (!isLoadingComplete && !props.skipLoadingScreen && initRouteName !== "") {
     return null;
     return null;
   }
   }
   return (
   return (
     <>
     <>
       <IconRegistry icons={EvaIconsPack} />
       <IconRegistry icons={EvaIconsPack} />
-      <ApplicationProvider
-        {...eva}
-        theme={{ ...eva.light, ...theme }}
-        customMapping={customMapping}
-      >
-        <Loading />
-        <Dialog />
-        <Layout style={{ flex: 1 }}>
-          {loginState !== "loading" && (
+      <Provider>
+        <ApplicationProvider
+          {...eva}
+          theme={{ ...eva.light, ...theme }}
+          customMapping={customMapping}
+        >
+          <Dialog />
+          <Layout style={{ flex: 1 }}>
             <NavigationContainer ref={navigationRef}>
             <NavigationContainer ref={navigationRef}>
               <Stack.Navigator
               <Stack.Navigator
                 headerMode="none"
                 headerMode="none"
@@ -146,38 +186,25 @@ export default function App(props) {
                   cardStyleInterpolator:
                   cardStyleInterpolator:
                     CardStyleInterpolators.forHorizontalIOS,
                     CardStyleInterpolators.forHorizontalIOS,
                 }}
                 }}
-                // initialRouteName="GoodsSpecification"
+                initialRouteName={initRouteName}
               >
               >
-                {GuideScreens(Stack.Screen, loginState)}
-
-                {loginState === "login" && (
-                  <Stack.Screen
-                    name="Root"
-                    component={BottomTabNavigator}
-                    options={{
-                      animationTypeForReplace:
-                        loginState === "login" ? "pop" : "push",
-                    }}
-                  />
-                )}
-                {loginState === "loginOut" && (
-                  <Stack.Screen
-                    name="Login"
-                    component={LoginStackNavigator}
-                    options={{
-                      animationTypeForReplace:
-                        loginState === "loginOut" ? "pop" : "push",
-                    }}
-                  />
-                )}
+                {GuideScreens(Stack.Screen)}
+
+                <Stack.Screen
+                  name="Root"
+                  component={BottomTabNavigator}
+                  options={{}}
+                />
+
+                <Stack.Screen name="Login" component={LoginStackNavigator} />
 
 
                 {/* 基础功能页面 */}
                 {/* 基础功能页面 */}
                 {BasicScreens(Stack.Screen)}
                 {BasicScreens(Stack.Screen)}
               </Stack.Navigator>
               </Stack.Navigator>
             </NavigationContainer>
             </NavigationContainer>
-          )}
-        </Layout>
-      </ApplicationProvider>
+          </Layout>
+        </ApplicationProvider>
+      </Provider>
     </>
     </>
   );
   );
 }
 }

+ 49 - 52
Utils/OpenTimeUtil.js

@@ -2,56 +2,53 @@
 import moment from "moment";
 import moment from "moment";
 
 
 export default class OpenTimeUtil {
 export default class OpenTimeUtil {
-    constructor(startTime, endTime, week, weekWords) {
-        this.startTime = startTime || "08:00:00";
-        this.endTime = endTime || "23:00:00";
-        this.week = week || "";
-        this.weekWords = weekWords || {};
-    }
-
-    getStartTimeStr() {
-        return moment(this.startTime, "HH:mm:ss").format("HH:mm");
-    }
-
-    getEndTimeStr() {
-        return moment(this.endTime, "HH:mm:ss").format("HH:mm");
-    }
-
-    getWeekStr() {
-        let _weeks = this.week.split(",");
-        if (_weeks.length === 7) {
-            return this.weekWords.all;
-        } 
-            _weeks = _weeks.map(item => {
-                return this.weekWords[item];
-            });
-            return _weeks.join(",");
-        
-    }
-
-    getShowStr() {
-        return (
-            `${this.getStartTimeStr() 
-            }~${ 
-            this.getEndTimeStr() 
-            } ${ 
-            this.getWeekStr()}`
-        );
-    }
-
-    setStartTime(startTime) {
-        this.startTime = moment(startTime, "HH:mm").format("HH:mm:ss");
-    }
-
-    setEndTime(endTime) {
-        this.endTime = moment(endTime, "HH:mm").format("HH:mm:ss");
-    }
-
-    setWeek(week) {
-        this.week = week || [];
-    }
-
-    setWeekWords(weekWords) {
-        this.weekWords = weekWords || {};
-    }
+  constructor(startTime, endTime, week, weekWords) {
+    this.startTime = startTime || "08:00:00";
+    this.endTime = endTime || "23:00:00";
+    this.week = week || "";
+    this.weekWords = weekWords || {};
+  }
+
+  getStartTimeStr() {
+    return moment(this.startTime, "HH:mm:ss").format("HH:mm");
+  }
+
+  getEndTimeStr() {
+    return moment(this.endTime, "HH:mm:ss").format("HH:mm");
+  }
+
+  getWeekStr() {
+    let _weeks = this.week.split(",");
+    if (_weeks.length === 7) {
+      return this.weekWords.all;
+    }
+    _weeks = _weeks.map(item => {
+      return this.weekWords[item];
+    });
+    return _weeks.join(",");
+  }
+
+  getTimeStr() {
+    return `${this.getStartTimeStr()}~${this.getEndTimeStr()}`;
+  }
+
+  getShowStr() {
+    return `${this.getStartTimeStr()}~${this.getEndTimeStr()} ${this.getWeekStr()}`;
+  }
+
+  setStartTime(startTime) {
+    this.startTime = moment(startTime, "HH:mm").format("HH:mm:ss");
+  }
+
+  setEndTime(endTime) {
+    this.endTime = moment(endTime, "HH:mm").format("HH:mm:ss");
+  }
+
+  setWeek(week) {
+    this.week = week || [];
+  }
+
+  setWeekWords(weekWords) {
+    this.weekWords = weekWords || {};
+  }
 }
 }

二進制
assets/images/shehe2.png


+ 309 - 314
components/FormInput.js

@@ -6,12 +6,12 @@ import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
 import * as React from "react";
 import { View, StyleSheet, TouchableWithoutFeedback } from "react-native";
 import { View, StyleSheet, TouchableWithoutFeedback } from "react-native";
 import {
 import {
-    Layout,
-    Input,
-    Button,
-    Icon,
-    Text,
-    SelectItem,
+  Layout,
+  Input,
+  Button,
+  Icon,
+  Text,
+  SelectItem,
 } from "@ui-kitten/components";
 } from "@ui-kitten/components";
 import { Cascader, BottomModal } from "beeshell";
 import { Cascader, BottomModal } from "beeshell";
 import { useModel } from "flooks";
 import { useModel } from "flooks";
@@ -21,342 +21,337 @@ import Datepicker from "./Datepicker";
 import UpLoadImage from "./UpLoadImage";
 import UpLoadImage from "./UpLoadImage";
 import Actionsheet from "./Actionsheet";
 import Actionsheet from "./Actionsheet";
 
 
-
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
-    inputContainer: {
-        flexDirection: "row",
-        alignItems: "center",
-        paddingVertical: 10,
-        paddingHorizontal: 4,
-    },
-    input: {
-        flex: 1,
-    },
-    label: {
-        width: 80,
-        marginRight: 19,
-        flexShrink: 0,
-    },
-    labelleft: {
-        width: 73,
-        flexShrink: 0,
-    },
-    right: {
-        flexDirection: "row",
-    },
-    code: {
-        paddingHorizontal: 5,
-        marginLeft: 5,
-    },
-    selectContent: {
-        backgroundColor: "#F0F0F0",
-    },
-    titleStyle: {
-        fontSize: 15,
-    },
-    leftLabelTextStyle: {
-        fontSize: 13,
-    },
-    rightLabelTextStyle: {
-        fontSize: 13,
-    },
-    sub: {
-        color: "#787878",
-        position: "absolute",
-        left: 90,
-        zIndex: 2,
-    },
-    upload: {
-        marginTop: 20,
-        width: 67,
-        height: 67,
-    },
+  inputContainer: {
+    flexDirection: "row",
+    alignItems: "center",
+    paddingVertical: 10,
+    paddingHorizontal: 4,
+  },
+  input: {
+    flex: 1,
+  },
+  label: {
+    width: 80,
+    marginRight: 19,
+    flexShrink: 0,
+  },
+  labelleft: {
+    width: 73,
+    flexShrink: 0,
+  },
+  right: {
+    flexDirection: "row",
+  },
+  code: {
+    paddingHorizontal: 5,
+    marginLeft: 5,
+  },
+  selectContent: {
+    backgroundColor: "#F0F0F0",
+  },
+  titleStyle: {
+    fontSize: 15,
+  },
+  leftLabelTextStyle: {
+    fontSize: 13,
+  },
+  rightLabelTextStyle: {
+    fontSize: 13,
+  },
+  sub: {
+    color: "#787878",
+    position: "absolute",
+    left: 90,
+    zIndex: 2,
+  },
+  upload: {
+    marginTop: 20,
+    width: 67,
+    height: 67,
+  },
 });
 });
 
 
-
-
 function* flattenSelect(array, key) {
 function* flattenSelect(array, key) {
-    for (const item of array) {
-        const _array = key ? item[key] : item;
-        if (Array.isArray(_array) && _array.length > 0) {
-            yield* flattenSelect(_array, key);
-        } else {
-            yield item;
-        }
+  for (const item of array) {
+    const _array = key ? item[key] : item;
+    if (Array.isArray(_array) && _array.length > 0) {
+      yield* flattenSelect(_array, key);
+    } else {
+      yield item;
     }
     }
+  }
 }
 }
 
 
 const FormInput = React.memo(props => {
 const FormInput = React.memo(props => {
-    const { appearance,type } = props;
-    const [secureTextEntry, setSecureTextEntry] = React.useState(true);
-    const { cancel, confirm } = useModel("wordsModel");
-    const toggleSecureEntry = () => {
-        setSecureTextEntry(!secureTextEntry);
-    };
-
-    // eslint-disable-next-line no-shadow
-    const renderIcon = props => (
-      <TouchableWithoutFeedback onPress={toggleSecureEntry}>
-        <Icon {...props} name={secureTextEntry ? "eye-off" : "eye"} />
-      </TouchableWithoutFeedback>
-    );
-    function getInputProps(props) {
-        let _props = {
-            value: props.value || "",
-            placeholder: props.placeholder,
-        };
-        if (type === "phone") {
-            _props = {
-                ..._props,
-                dataDetectorTypes: "phoneNumber",
-                maxLength: 11,
-                keyboardType: "phone-pad",
-            };
-        } else if (type === "password") {
-            _props = {
-                ..._props,
-                accessoryRight: ImageProps => renderIcon(ImageProps),
-                secureTextEntry,
-            };
-        } else if (type === "code") {
-            _props = {
-                ..._props,
-                maxLength: 6,
-                keyboardType: "numeric",
-            };
-        } else if (type === "amount" || props.type === "money") {
-            _props = {
-                ..._props,
-                keyboardType: "numeric",
-            };
-        }
-        if (props.onChange) {
-            _props = {
-                ..._props,
-                onChangeText: nextValue => props.onChange(nextValue),
-            };
-        }
+  const { appearance, type } = props;
+  const [secureTextEntry, setSecureTextEntry] = React.useState(true);
+  const { cancel, confirm } = useModel("wordsModel");
+  const toggleSecureEntry = () => {
+    setSecureTextEntry(!secureTextEntry);
+  };
 
 
-        return _props;
+  // eslint-disable-next-line no-shadow
+  const renderIcon = props => (
+    <TouchableWithoutFeedback onPress={toggleSecureEntry}>
+      <Icon {...props} name={secureTextEntry ? "eye-off" : "eye"} />
+    </TouchableWithoutFeedback>
+  );
+  function getInputProps(props) {
+    let _props = {
+      value: props.value || "",
+      placeholder: props.placeholder,
+    };
+    if (type === "phone") {
+      _props = {
+        ..._props,
+        dataDetectorTypes: "phoneNumber",
+        maxLength: 11,
+        keyboardType: "phone-pad",
+      };
+    } else if (type === "password") {
+      _props = {
+        ..._props,
+        accessoryRight: ImageProps => renderIcon(ImageProps),
+        secureTextEntry,
+      };
+    } else if (type === "code") {
+      _props = {
+        ..._props,
+        maxLength: 6,
+        keyboardType: "numeric",
+      };
+    } else if (type === "amount" || props.type === "money") {
+      _props = {
+        ..._props,
+        keyboardType: "numeric",
+      };
+    }
+    if (props.onChange) {
+      _props = {
+        ..._props,
+        onChangeText: nextValue => props.onChange(nextValue),
+      };
     }
     }
 
 
-    const inputProps = getInputProps(props);
+    return _props;
+  }
 
 
-    // const myInput = () => {
-    //     if (inputProps != null) {
-    //         return;
-    //     }
-    // };
+  const inputProps = getInputProps(props);
 
 
-    const Label = ({type,labelStyle,label}) => {
-        return (
-          <View
-            style={[
-                    appearance === "inner" ? styles.labelleft : styles.label,
-                    type === "img" ? { alignSelf: "flex-start" } : {},
-                    labelStyle || {},
-                ]}
-          >
-            <Text
-              category='c1'
-              style={{
-                        textAlign: appearance !== "inner" ? "right" : "left",
-                    }}
-            >
-              {label}
-            </Text>
-          </View>
-        );
-    };
-    const ForwardIcon = props => <Icon {...props} name='arrow-ios-forward' />;
+  // const myInput = () => {
+  //     if (inputProps != null) {
+  //         return;
+  //     }
+  // };
 
 
-    const selectList = props.selectList ? props.selectList : [];
+  const Label = ({ type, labelStyle, label }) => {
+    return (
+      <View
+        style={[
+          appearance === "inner" ? styles.labelleft : styles.label,
+          type === "img" ? { alignSelf: "flex-start" } : {},
+          labelStyle || {},
+        ]}
+      >
+        <Text
+          category="c1"
+          style={{
+            textAlign: appearance !== "inner" ? "right" : "left",
+          }}
+        >
+          {label}
+        </Text>
+      </View>
+    );
+  };
+  const ForwardIcon = props => <Icon {...props} name="arrow-ios-forward" />;
 
 
-    const [bottomModalX, changeBottomModalx] = React.useState("");
-    const [selectVal, setSelectVal] = React.useState("");
+  const selectList = props.selectList ? props.selectList : [];
 
 
-    const selectInfo = React.useMemo(() => {
-        if (type === "select" && props.value && selectList.length > 0) {
-            const childrens = [...flattenSelect(selectList, "children")];
-            return (
-                childrens.find(item => {
-                    return item.id === props.value;
-                }) || { name: " " }
-            );
-        } 
-            return { name: " " };
-        
-    }, [props.value, props.type, selectList]);
+  const [bottomModalX, changeBottomModalx] = React.useState("");
+  const [selectVal, setSelectVal] = React.useState("");
 
 
-    const [open, ChangeOpen] = React.useState(false);
+  const selectInfo = React.useMemo(() => {
+    if (type === "select" && props.value && selectList.length > 0) {
+      const childrens = [...flattenSelect(selectList, "children")];
+      return (
+        childrens.find(item => {
+          return item.id === props.value;
+        }) || { name: " " }
+      );
+    }
+    return { name: " " };
+  }, [props.value, props.type, selectList]);
 
 
-  
-    const Btn = ({ btnText }) => (
-      <Button
-        appearance='ghost'
-        size='tiny'
-        style={{ paddingVertical: 8, marginLeft: 5 }}
-      >
-        {btnText}
-      </Button>
-    );
+  const [open, ChangeOpen] = React.useState(false);
 
 
+  const Btn = ({ btnText }) => (
+    <Button
+      appearance="ghost"
+      size="tiny"
+      style={{ paddingVertical: 8, marginLeft: 5 }}
+    >
+      {btnText}
+    </Button>
+  );
 
 
-    function getMain(type, props) {
-        if (type === "select") {
-            return (
-              <>
-                <SelectItem
-                  appearance='form'
-                  style={{ flex: 1 }}
-                  accessoryRight={ForwardIcon}
-                  title={selectInfo.name}
-                  onPress={() => {
-                            bottomModalX.open();
-                        }}
-                />
-                <BottomModal
-                  ref={c => {
-                            changeBottomModalx(c);
-                        }}
-                  title={props.selectTitle}
-                  titleStyle={styles.titleStyle}
-                  cancelable
-                  leftLabelText={cancel}
-                  leftLabelTextStyle={styles.leftLabelTextStyle}
-                  rightLabelText={confirm}
-                  rightLabelTextStyle={styles.rightLabelTextStyle}
-                  rightCallback={() => {
-                            props.onChange(selectVal);
-                        }}
-                >
-                  <Cascader
-                    style={{
-                                width: "100%",
-                                height: 200,
-                                marginBottom: 50,
-                                minHeight: 200,
-                            }}
-                    data={selectList}
-                    fieldKeys={{
-                                labelKey: "name",
-                                idKey: "id",
-                                activeKey: "choose",
-                            }}
-                    onChange={(value) => {
-                                setSelectVal(value[0]);
-                            }}
-                  />
-                </BottomModal>
-              </>
-            );
-        } if (type === "openTime") {
-            return (
-              <OpenTime
-                open={open}
-                submit={(start, end, week) => {
-                        ChangeOpen(false);
-                        props.onChange(
-                            week.join(","),
-                            moment(start, "HH:mm").format("HH:mm:ss"),
-                            moment(end, "HH:mm").format("HH:mm:ss")
-                        );
-                    }}
-                cancelEvent={() => {
-                        ChangeOpen(false);
-                    }}
-                openModal={() => {
-                        ChangeOpen(true);
-                    }}
-                defaultValue={props.defaultValue}
-              />
-            );
-        } if (type === "date") {
-            return (
-              <Datepicker chooseDate={props.onChange} value={props.value} />
-            );
-        } if (type === "url") {
-            return (
-              <SelectItem
-                appearance='form'
-                style={{ flex: 1 }}
-                accessoryRight={ForwardIcon}
-                title={props.value || " "}
-                onPress={props.changePath}
-              />
-            );
-        } if (type === "actionSheet") {
-            return (
-              <>
-                <Actionsheet
-                  list={props.list}
-                  value={props.value}
-                  onChange={props.onChange}
-                />
-              </>
-            );
-        } if (type === "img") {
-            return (
-              <UpLoadImage
-                style={styles.upload}
-                value={props.value}
-                changeIcon={props.onChange}
-              />
-            );
-        } if (appearance === "inner" && type === "code") {
-            return (
-              <Input
-                {...inputProps}
-                accessoryLeft={leftprops => (
-                  <Label {...props} {...leftprops} />
-                    )}
-                accessoryRight={() => <Btn btnText={props.btnText} />}
-                size='small'
-                style={styles.input}
-                appearance='innerCode'
-              />
-            );
-        } if (appearance === "inner") {
-            return (
-              <Input
-                {...inputProps}
-                accessoryLeft={leftprops => (
-                  <Label {...props} {...leftprops} />
-                    )}
-                size='small'
-                style={styles.input}
-                appearance='inner'
-              />
+  function getMain(type, props) {
+    if (type === "select") {
+      return (
+        <>
+          <SelectItem
+            appearance="form"
+            style={{ flex: 1 }}
+            accessoryRight={ForwardIcon}
+            title={selectInfo.name}
+            onPress={() => {
+              bottomModalX.open();
+            }}
+          />
+          <BottomModal
+            ref={c => {
+              changeBottomModalx(c);
+            }}
+            title={props.selectTitle}
+            titleStyle={styles.titleStyle}
+            cancelable
+            leftLabelText={cancel}
+            leftLabelTextStyle={styles.leftLabelTextStyle}
+            rightLabelText={confirm}
+            rightLabelTextStyle={styles.rightLabelTextStyle}
+            rightCallback={() => {
+              props.onChange(selectVal);
+            }}
+          >
+            <Cascader
+              style={{
+                width: "100%",
+                height: 200,
+                marginBottom: 50,
+                minHeight: 200,
+              }}
+              data={selectList}
+              fieldKeys={{
+                labelKey: "name",
+                idKey: "id",
+                activeKey: "choose",
+              }}
+              onChange={value => {
+                setSelectVal(value[0]);
+              }}
+            />
+          </BottomModal>
+        </>
+      );
+    }
+    if (type === "openTime") {
+      return (
+        <OpenTime
+          open={open}
+          submit={(start, end, week) => {
+            ChangeOpen(false);
+            props.onChange(
+              week.join(","),
+              moment(start, "HH:mm").format("HH:mm:ss"),
+              moment(end, "HH:mm").format("HH:mm:ss")
             );
             );
-        } 
-            return <Input {...inputProps} size='small' style={styles.input} />;
-        
+          }}
+          cancelEvent={() => {
+            ChangeOpen(false);
+          }}
+          openModal={() => {
+            ChangeOpen(true);
+          }}
+          week={props.week}
+          startTime={props.startTime}
+          endTime={props.endTime}
+        />
+      );
+    }
+    if (type === "date") {
+      return <Datepicker chooseDate={props.onChange} value={props.value} />;
     }
     }
+    if (type === "url") {
+      return (
+        <SelectItem
+          appearance="form"
+          style={{ flex: 1 }}
+          accessoryRight={ForwardIcon}
+          title={props.value || " "}
+          onPress={props.changePath}
+        />
+      );
+    }
+    if (type === "actionSheet") {
+      return (
+        <>
+          <Actionsheet
+            list={props.list}
+            value={props.value}
+            onChange={props.onChange}
+          />
+        </>
+      );
+    }
+    if (type === "img") {
+      return (
+        <UpLoadImage
+          style={styles.upload}
+          value={props.value}
+          changeIcon={props.onChange}
+        />
+      );
+    }
+    if (appearance === "inner" && type === "code") {
+      return (
+        <Input
+          {...inputProps}
+          accessoryLeft={leftprops => <Label {...props} {...leftprops} />}
+          accessoryRight={() => <Btn btnText={props.btnText} />}
+          size="small"
+          style={styles.input}
+          appearance="innerCode"
+        />
+      );
+    }
+    if (appearance === "inner") {
+      return (
+        <Input
+          {...inputProps}
+          accessoryLeft={leftprops => <Label {...props} {...leftprops} />}
+          size="small"
+          style={styles.input}
+          appearance="inner"
+        />
+      );
+    }
+    return <Input {...inputProps} size="small" style={styles.input} />;
+  }
 
 
-    return (
-      <Layout
-        level='1'
-        style={[
-                styles.inputContainer,
-                { ...props.style },
-                props.type === "img" ? { flexDirection: "column" } : {},
-                { paddingVertical: appearance === "inner" ? 0 : 10 },
-            ]}
-      >
-        {appearance !== "inner" && <Label {...props} />}
+  return (
+    <Layout
+      level="1"
+      style={[
+        styles.inputContainer,
+        { ...props.style },
+        props.type === "img" ? { flexDirection: "column" } : {},
+        { paddingVertical: appearance === "inner" ? 0 : 10 },
+      ]}
+    >
+      {appearance !== "inner" && <Label {...props} />}
 
 
-        {(!props.value || props.value === " ") && (
-        <Text category='c1' style={styles.sub}>
+      {(!props.value || props.value === " ") && (
+        <Text category="c1" style={styles.sub}>
           {props.sub}
           {props.sub}
         </Text>
         </Text>
-            )}
+      )}
 
 
-        {getMain(props.type, props)}
+      {getMain(props.type, props)}
 
 
-        {appearance !== "inner" && props.type === "code" && Btn(props)}
-      </Layout>
-    );
+      {appearance !== "inner" && props.type === "code" && Btn(props)}
+    </Layout>
+  );
 });
 });
 
 
-
 export default FormInput;
 export default FormInput;

+ 35 - 39
components/GuideHeaderBar.js

@@ -1,50 +1,46 @@
 import React from "react";
 import React from "react";
-import {  Layout, useTheme, Text } from "@ui-kitten/components";
+import { Layout, useTheme, Text } from "@ui-kitten/components";
 import { useModel } from "flooks";
 import { useModel } from "flooks";
 import { Image, StyleSheet } from "react-native";
 import { Image, StyleSheet } from "react-native";
 
 
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
-    container: {
-        height: 70,
-        flexDirection: "row",
-        paddingVertical: 10,
-        paddingHorizontal: 65,
-        alignItems: "center",
-        justifyContent: "center",
-    },
-    icon: { width: 49, height: 49, position: "absolute", left: 15, top: 10 },
-    text: {
-        color: "#fff",
-    },
+  container: {
+    height: 70,
+    flexDirection: "row",
+    paddingVertical: 10,
+    paddingHorizontal: 65,
+    alignItems: "center",
+    justifyContent: "center",
+  },
+  icon: { width: 49, height: 49, position: "absolute", left: 15, top: 10 },
+  text: {
+    color: "#fff",
+  },
 });
 });
 
 
-const img1=require("../assets/images/logo_bai.png")
+const img1 = require("../assets/images/logo_bai.png");
 
 
 export default function GuideHeaderBar() {
 export default function GuideHeaderBar() {
-    const theme = useTheme();
-    const { registerInfo, showName, mid } = useModel("userModel");
+  const theme = useTheme();
+  const { registerInfo, showName, mid } = useModel("userModel");
 
 
-    const title = React.useMemo(() => {
-        if (mid) {
-            return showName;
-        } 
-            return registerInfo.showName;
-        
-    }, [showName, registerInfo]);
-    return (
-      <Layout
-        style={[
-                styles.container,
-                { backgroundColor: theme["color-primary-500"] },
-            ]}
-      >
-        <Image
-          source={img1}
-          style={styles.icon}
-        />
-        <Text style={styles.text} category='h6'>
-          {title}
-        </Text>
-      </Layout>
-    );
+  const title = React.useMemo(() => {
+    if (mid) {
+      return showName;
+    }
+    return registerInfo ? registerInfo.showName : "";
+  }, [showName, registerInfo]);
+  return (
+    <Layout
+      style={[
+        styles.container,
+        { backgroundColor: theme["color-primary-500"] },
+      ]}
+    >
+      <Image source={img1} style={styles.icon} />
+      <Text style={styles.text} category="h6">
+        {title}
+      </Text>
+    </Layout>
+  );
 }
 }

+ 53 - 64
components/Loading.js

@@ -1,77 +1,66 @@
 import React from "react";
 import React from "react";
 import { StyleSheet } from "react-native";
 import { StyleSheet } from "react-native";
-import {
-    Modal,
-    Text,
-    Layout,
-    Spinner,
-    Icon,
-} from "@ui-kitten/components";
+import { Modal, Text, Layout, Spinner, Icon } from "@ui-kitten/components";
 import { useModel, setModel } from "flooks";
 import { useModel, setModel } from "flooks";
-import loadingModel from "../models/loadingModel";
-
-setModel("loadingModel", loadingModel);
 
 
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
-    backdrop: {
-        // backgroundColor: "rgba(0, 0, 0, 0.5)",
-    },
-    loadingBox: {
-        width: 120,
-        height: 120,
-        borderRadius: 10,
-        backgroundColor: "rgba(0,0,0,0.8)",
-        alignItems: "center",
-        justifyContent: "center",
-    },
-    text: {
-        color: "#fff",
-        marginTop: 10,
-    },
-    icon: {
-        width: 60,
-        height: 60,
-    },
-    warning: {
-        paddingHorizontal: 15,
-        paddingVertical: 5,
-        backgroundColor: "rgba(0,0,0,0.8)",
-        borderRadius: 3,
-        marginHorizontal: 20,
-    },
+  backdrop: {
+    // backgroundColor: "rgba(0, 0, 0, 0.5)",
+  },
+  loadingBox: {
+    width: 120,
+    height: 120,
+    borderRadius: 10,
+    backgroundColor: "rgba(0,0,0,0.8)",
+    alignItems: "center",
+    justifyContent: "center",
+  },
+  text: {
+    color: "#fff",
+    marginTop: 10,
+  },
+  icon: {
+    width: 60,
+    height: 60,
+  },
+  warning: {
+    paddingHorizontal: 15,
+    paddingVertical: 5,
+    backgroundColor: "rgba(0,0,0,0.8)",
+    borderRadius: 3,
+    marginHorizontal: 20,
+  },
 });
 });
 
 
-
-
 export default function Loading() {
 export default function Loading() {
-    const {  getWordsStr } = useModel("wordsModel");
+  const { getWordsStr } = useModel("wordsModel");
 
 
-    const { show, title, status } = useModel("loadingModel");
+  const { show, title, status } = useModel("loadingModel");
 
 
-    return (
-      <Modal visible={show} backdropStyle={styles.backdrop}>
-        {status === "loading" && (
-        <Layout style={styles.loadingBox}>
-          <Spinner size='giant' status='control' />
-          <Text style={styles.text}>{getWordsStr("loading")}</Text>
-        </Layout>
-            )}
+  return (
+    <Text>加载中...</Text>
+    //   <Modal visible={show} backdropStyle={styles.backdrop}>
+    //     {status === "loading" && (
+    //     <Layout style={styles.loadingBox}>
+    //       <Spinner size='giant' status='control' />
+    //       <Text style={styles.text}>{getWordsStr("loading")}</Text>
+    //     </Layout>
+    //         )}
 
 
-        {status === "success" && (
-        <Layout style={styles.loadingBox}>
-          <Icon style={styles.icon} name='checkmark' fill='#fff' />
-          <Text style={styles.text}>{title}</Text>
-        </Layout>
-            )}
+    //     {status === "success" && (
+    //     <Layout style={styles.loadingBox}>
+    //       <Icon style={styles.icon} name='checkmark' fill='#fff' />
+    //       <Text style={styles.text}>{title}</Text>
+    //     </Layout>
+    //         )}
 
 
-        {status === "warn" && (
-        <Layout style={styles.warning}>
-          <Text style={{ color: "#fff", textAlign: "center" }}>
-            {title}
-          </Text>
-        </Layout>
-            )}
-      </Modal>
-    );
+    //     {status === "warn" && (
+    //     <Layout style={styles.warning}>
+    //       <Text style={{ color: "#fff", textAlign: "center" }}>
+    //         {title}
+    //       </Text>
+    //     </Layout>
+    //         )}
+    //   </Modal>
+  );
 }
 }
-

+ 323 - 344
components/OpenTime.js

@@ -1,389 +1,368 @@
+/* eslint-disable prefer-const */
 /* eslint-disable no-underscore-dangle */
 /* eslint-disable no-underscore-dangle */
 import React from "react";
 import React from "react";
-import {
-    StyleSheet,
-    LayoutAnimation,
-    Platform,
-    UIManager,
-} from "react-native";
+import { StyleSheet, LayoutAnimation, Platform, UIManager } from "react-native";
 import { range, convert2Digit } from "beeshell/dist/common/utils";
 import { range, convert2Digit } from "beeshell/dist/common/utils";
 import {
 import {
-    CheckBox,
-    Layout,
-    Modal,
-    Button,
-    Card,
-    Text,
-    MenuItem,
-    Icon,
-    SelectItem,
+  CheckBox,
+  Layout,
+  Modal,
+  Button,
+  Card,
+  Text,
+  MenuItem,
+  Icon,
+  SelectItem,
 } from "@ui-kitten/components";
 } from "@ui-kitten/components";
 import { Scrollpicker } from "beeshell";
 import { Scrollpicker } from "beeshell";
 import { useModel } from "flooks";
 import { useModel } from "flooks";
 import moment from "moment";
 import moment from "moment";
+import OpenTimeUtil from "../Utils/OpenTimeUtil";
 
 
 if (Platform.OS === "android") {
 if (Platform.OS === "android") {
-    if (UIManager.setLayoutAnimationEnabledExperimental) {
-        UIManager.setLayoutAnimationEnabledExperimental(true);
-    }
+  if (UIManager.setLayoutAnimationEnabledExperimental) {
+    UIManager.setLayoutAnimationEnabledExperimental(true);
+  }
 }
 }
 
 
-
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
-    checkBoxAll: {
-        paddingVertical: 10,
-    },
-    checkBoxItem: {
-        paddingVertical: 2,
-        paddingHorizontal: 10,
-    },
-    time: {
-        // width: 100,
-        // height: 300,
-    },
-    backdrop: {
-        backgroundColor: "rgba(0, 0, 0, 0.5)",
-    },
-    btnList: {
-        flexDirection: "row",
-        justifyContent: "space-between",
-        paddingTop: 15,
-    },
-    hideHeight: {
-        height: 0,
-        borderWidth: 0,
-    },
-    btn: {
-        flex: 1,
-        minWidth: 50,
-    },
+  checkBoxAll: {
+    paddingVertical: 10,
+  },
+  checkBoxItem: {
+    paddingVertical: 2,
+    paddingHorizontal: 10,
+  },
+  time: {
+    // width: 100,
+    // height: 300,
+  },
+  backdrop: {
+    backgroundColor: "rgba(0, 0, 0, 0.5)",
+  },
+  btnList: {
+    flexDirection: "row",
+    justifyContent: "space-between",
+    paddingTop: 15,
+  },
+  hideHeight: {
+    height: 0,
+    borderWidth: 0,
+  },
+  btn: {
+    flex: 1,
+    minWidth: 50,
+  },
 });
 });
 
 
-
-const ForwardIcon = (props) => <Icon {...props} name='arrow-ios-forward' />;
+const ForwardIcon = props => <Icon {...props} name="arrow-ios-forward" />;
 
 
 const titleText = (props, title, value) => (
 const titleText = (props, title, value) => (
-  <Text {...props} category='s1' numberOfLines={1} ellipsizeMode='tail'>
+  <Text {...props} category="s1" numberOfLines={1} ellipsizeMode="tail">
     {title}
     {title}
-    <Text category='c1' style={{ paddingLeft: 10 }}>
+    <Text category="c1" style={{ paddingLeft: 10 }}>
       {value}
       {value}
     </Text>
     </Text>
   </Text>
   </Text>
 );
 );
 
 
 export default function OpenTime({
 export default function OpenTime({
-    open,
-    submit,
-    cancelEvent,
-    openModal,
-    defaultValue,
+  open,
+  submit,
+  cancelEvent,
+  openModal,
+  week,
+  startTime,
+  endTime,
 }) {
 }) {
-    const {
-        MONDAY,
-        TUESDAY,
-        WEDNESDAY,
-        THURSDAY,
-        FRIDAY,
-        SATURDAY,
-        SUNDAY,
-        every,
-        confirm,
-        cancel,
-        start,
-        end,
-        hour,
-        min,
-        weekName,
-    } = useModel("wordsModel");
-    const weeks = [
-        {
-            key: "MONDAY",
-            label: MONDAY,
-        },
-        {
-            key: "TUESDAY",
-            label: TUESDAY,
-        },
-        {
-            key: "WEDNESDAY",
-            label: WEDNESDAY,
-        },
-        {
-            key: "THURSDAY",
-            label: THURSDAY,
-        },
-        {
-            key: "FRIDAY",
-            label: FRIDAY,
-        },
-        {
-            key: "SATURDAY",
-            label: SATURDAY,
-        },
-        {
-            key: "SUNDAY",
-            label: SUNDAY,
-        },
-    ];
-    const [checkList, changeChecked] = React.useState([]);
-    const listItems = weeks.map((item, index) => (
-      <CheckBox
-        style={styles.checkBoxItem}
-        key={index}
-        checked={checkList.includes(item.key)}
-        onChange={(checked) => {
-                const _checkList = [...checkList];
-                if (checked) {
-                    _checkList.push(item.key);
-                } else {
-                    _checkList.splice(_checkList.indexOf(item.key), 1);
-                }
-                changeChecked(_checkList);
-            }}
-      >
-        {item.label}
-      </CheckBox>
-    ));
-    const list = React.useMemo(() => {
-        const hourSum = 24;
-        const minuteSum = 60;
-        const hours = range(hourSum / 1).map((item) => {
-            item = convert2Digit(item * 1);
-            return {
-                label: `${item} ${hour}`,
-                value: item,
-            };
-        });
-        const minutes = range(minuteSum / 10).map((item) => {
-            item = convert2Digit(item * 10);
-            return {
-                label: `${item} ${min}`,
-                value: item,
-            };
-        });
-        return [hours, minutes];
-    }, [open]);
+  const {
+    MONDAY,
+    TUESDAY,
+    WEDNESDAY,
+    THURSDAY,
+    FRIDAY,
+    SATURDAY,
+    SUNDAY,
+    every,
+    confirm,
+    cancel,
+    start,
+    end,
+    hour,
+    min,
+    weekName,
+    weekWords,
+  } = useModel("wordsModel");
+  const weeks = [
+    {
+      key: "MONDAY",
+      label: MONDAY,
+    },
+    {
+      key: "TUESDAY",
+      label: TUESDAY,
+    },
+    {
+      key: "WEDNESDAY",
+      label: WEDNESDAY,
+    },
+    {
+      key: "THURSDAY",
+      label: THURSDAY,
+    },
+    {
+      key: "FRIDAY",
+      label: FRIDAY,
+    },
+    {
+      key: "SATURDAY",
+      label: SATURDAY,
+    },
+    {
+      key: "SUNDAY",
+      label: SUNDAY,
+    },
+  ];
+  const [checkList, changeChecked] = React.useState([]);
+  const listItems = weeks.map((item, index) => (
+    <CheckBox
+      style={styles.checkBoxItem}
+      key={index}
+      checked={checkList.includes(item.key)}
+      onChange={checked => {
+        const _checkList = [...checkList];
+        if (checked) {
+          _checkList.push(item.key);
+        } else {
+          _checkList.splice(_checkList.indexOf(item.key), 1);
+        }
+        changeChecked(_checkList);
+      }}
+    >
+      {item.label}
+    </CheckBox>
+  ));
+  const list = React.useMemo(() => {
+    const hourSum = 24;
+    const minuteSum = 60;
+    const hours = range(hourSum / 1).map(item => {
+      item = convert2Digit(item * 1);
+      return {
+        label: `${item} ${hour}`,
+        value: item,
+      };
+    });
+    const minutes = range(minuteSum / 10).map(item => {
+      item = convert2Digit(item * 10);
+      return {
+        label: `${item} ${min}`,
+        value: item,
+      };
+    });
+    return [hours, minutes];
+  }, [open]);
 
 
-    const [time1, setTime1] = React.useState([8, 0]);
-    const [time2, setTime2] = React.useState([20, 0]);
+  const [time1, setTime1] = React.useState([8, 0]);
+  const [time2, setTime2] = React.useState([20, 0]);
 
 
-    const [showTime1, changeShowTime1] = React.useState(true);
-    const [showTime2, changeShowTime2] = React.useState(false);
-    const [showWeek, changeShowWeek] = React.useState(false);
+  const [showTime1, changeShowTime1] = React.useState(true);
+  const [showTime2, changeShowTime2] = React.useState(false);
+  const [showWeek, changeShowWeek] = React.useState(false);
 
 
-    const allChecked = React.useMemo(() => {
-        if (weeks.length === checkList.length) {
-            return true;
-        } 
-            return false;
-        
-    }, [weeks, checkList]);
+  const allChecked = React.useMemo(() => {
+    if (weeks.length === checkList.length) {
+      return true;
+    }
+    return false;
+  }, [weeks, checkList]);
 
 
-    const indeterminate = React.useMemo(() => {
-        if (!allChecked && checkList.length > 0) {
-            return true;
-        } 
-            return false;
-        
-    }, [allChecked, checkList]);
+  const indeterminate = React.useMemo(() => {
+    if (!allChecked && checkList.length > 0) {
+      return true;
+    }
+    return false;
+  }, [allChecked, checkList]);
 
 
-    const canSubmit = React.useMemo(() => {
-        if (time1.length === 2 && time2.length === 2 && checkList.length > 0) {
-            return true;
-        } 
-            return false;
-        
-    }, [time1, time2, checkList]);
+  const canSubmit = React.useMemo(() => {
+    if (time1.length === 2 && time2.length === 2 && checkList.length > 0) {
+      return true;
+    }
+    return false;
+  }, [time1, time2, checkList]);
 
 
-    const time1Str = React.useMemo(() => {
-        if (time1.length === 2) {
-            const str = `${time1[0]  }:${  time1[1] * 10}`;
-            return moment(str, "H:m").format("HH:mm");
-        } 
-            return "";
-        
-    }, [time1]);
+  const time1Str = React.useMemo(() => {
+    if (time1.length === 2) {
+      const str = `${time1[0]}:${time1[1] * 10}`;
+      return moment(str, "H:m").format("HH:mm");
+    }
+    return "";
+  }, [time1]);
 
 
-    const time2Str = React.useMemo(() => {
-        if (time2.length === 2) {
-            const str = `${time2[0]  }:${  time2[1] * 10}`;
-            return moment(str, "H:m").format("HH:mm");
-        } 
-            return "";
-        
-    }, [time2]);
+  const time2Str = React.useMemo(() => {
+    if (time2.length === 2) {
+      const str = `${time2[0]}:${time2[1] * 10}`;
+      return moment(str, "H:m").format("HH:mm");
+    }
+    return "";
+  }, [time2]);
 
 
-    const weekStr = React.useMemo(() => {
-        if (allChecked) {
-            return every;
-        } 
-            const _weeks = weeks.filter((item) => {
-                return checkList.includes(item.key);
-            });
-            return _weeks
-                .map((item) => {
-                    return item.label;
-                })
-                .join(",");
-        
-    }, []);
+  const weekStr = React.useMemo(() => {
+    if (allChecked) {
+      return every;
+    }
+    const _weeks = weeks.filter(item => {
+      return checkList.includes(item.key);
+    });
+    return _weeks
+      .map(item => {
+        return item.label;
+      })
+      .join(",");
+  }, []);
 
 
-    const [showName, setShowName] = React.useState([" ", ""]);
+  const [showName, setShowName] = React.useState([" ", ""]);
 
 
-    React.useEffect(() => {
-        if (defaultValue && defaultValue.length > 0) {
-            setShowName(defaultValue);
-        }
-    }, [defaultValue]);
+  React.useEffect(() => {
+    if (week && endTime && startTime) {
+      let _openTimeUtil = new OpenTimeUtil(startTime, endTime, week, weekWords);
+      setShowName([_openTimeUtil.getTimeStr(), _openTimeUtil.getWeekStr()]);
+    }
+  }, [week, endTime, startTime]);
 
 
-    function hideElseShow(key) {
-        changeShowTime1(key === 1);
-        changeShowTime2(key === 2);
-        changeShowWeek(key === 3);
+  function hideElseShow(key) {
+    changeShowTime1(key === 1);
+    changeShowTime2(key === 2);
+    changeShowWeek(key === 3);
 
 
-        LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
-    }
+    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
+  }
 
 
-    return (
-      <>
-        <SelectItem
-          appearance='form'
-          style={{ flex: 1, height: 32 }}
-          accessoryRight={ForwardIcon}
-          title={(props) => titleText(props, showName[0], showName[1])}
-          onPress={openModal}
-        />
-        <Modal
-          visible={open && list.length > 0}
-          backdropStyle={styles.backdrop}
-          onBackdropPress={cancelEvent}
-        >
+  return (
+    <>
+      <SelectItem
+        appearance="form"
+        style={{ flex: 1, height: 32 }}
+        accessoryRight={ForwardIcon}
+        title={props => titleText(props, showName[0], showName[1])}
+        onPress={openModal}
+      />
+      <Modal
+        visible={open && list.length > 0}
+        backdropStyle={styles.backdrop}
+        onBackdropPress={cancelEvent}
+      >
+        <Card disabled appearance="modalCrad" style={{ width: 242 }}>
+          <Layout>
+            <MenuItem
+              appearance="cardContent"
+              title={props => titleText(props, start, time1Str)}
+              accessoryRight={ForwardIcon}
+              onPress={() => {
+                hideElseShow(1);
+              }}
+            />
+          </Layout>
           <Card
           <Card
             disabled
             disabled
-            appearance='modalCrad'
-            style={{ width: 242 }}
+            appearance="modalCrad"
+            style={[{ width: 222 }, showTime1 ? {} : styles.hideHeight]}
           >
           >
-            <Layout>
-              <MenuItem
-                appearance='cardContent'
-                title={(props) => titleText(props, start, time1Str)}
-                accessoryRight={ForwardIcon}
-                onPress={() => {
-                                hideElseShow(1);
-                            }}
-              />
-            </Layout>
-            <Card
-              disabled
-              appearance='modalCrad'
-              style={[
-                            { width: 222 },
-                            showTime1 ? {} : styles.hideHeight,
-                        ]}
-            >
-              <Scrollpicker
-                key='time1'
-                list={list}
-                proportion={[1, 1]}
-                offsetCount={1}
-                value={time1}
-                onChange={(index, value) => {
-                                const _time1 = [...time1];
-                                _time1[index] = value;
-                                setTime1(_time1);
-                            }}
-              />
-            </Card>
-            <Layout>
-              <MenuItem
-                appearance='cardContent'
-                title={(props) => titleText(props, end, time2Str)}
-                accessoryRight={ForwardIcon}
-                onPress={() => {
-                                hideElseShow(2);
-                            }}
-              />
-            </Layout>
-            <Card
-              disabled
-              appearance='modalCrad'
-              style={[
-                            { width: 222 },
-                            showTime2 ? {} : styles.hideHeight,
-                        ]}
-            >
-              <Scrollpicker
-                key='time2'
-                list={list}
-                proportion={[1, 1]}
-                offsetCount={1}
-                value={time2}
-                onChange={(index, value) => {
-                                const _time2 = [...time2];
-                                _time2[index] = value;
-                                setTime2(_time2);
-                            }}
-              />
-            </Card>
-            <Layout>
-              <MenuItem
-                appearance='cardContent'
-                title={(props) =>
-                                titleText(props, weekName, weekStr)}
-                accessoryRight={ForwardIcon}
-                onPress={() => {
-                                hideElseShow(3);
-                            }}
-              />
-            </Layout>
-            <Card
-              appearance='modalCrad'
-              style={[showWeek ? {} : styles.hideHeight]}
+            <Scrollpicker
+              key="time1"
+              list={list}
+              proportion={[1, 1]}
+              offsetCount={1}
+              value={time1}
+              onChange={(index, value) => {
+                const _time1 = [...time1];
+                _time1[index] = value;
+                setTime1(_time1);
+              }}
+            />
+          </Card>
+          <Layout>
+            <MenuItem
+              appearance="cardContent"
+              title={props => titleText(props, end, time2Str)}
+              accessoryRight={ForwardIcon}
+              onPress={() => {
+                hideElseShow(2);
+              }}
+            />
+          </Layout>
+          <Card
+            disabled
+            appearance="modalCrad"
+            style={[{ width: 222 }, showTime2 ? {} : styles.hideHeight]}
+          >
+            <Scrollpicker
+              key="time2"
+              list={list}
+              proportion={[1, 1]}
+              offsetCount={1}
+              value={time2}
+              onChange={(index, value) => {
+                const _time2 = [...time2];
+                _time2[index] = value;
+                setTime2(_time2);
+              }}
+            />
+          </Card>
+          <Layout>
+            <MenuItem
+              appearance="cardContent"
+              title={props => titleText(props, weekName, weekStr)}
+              accessoryRight={ForwardIcon}
+              onPress={() => {
+                hideElseShow(3);
+              }}
+            />
+          </Layout>
+          <Card
+            appearance="modalCrad"
+            style={[showWeek ? {} : styles.hideHeight]}
+          >
+            <CheckBox
+              style={styles.checkBoxAll}
+              checked={allChecked}
+              indeterminate={indeterminate}
+              onChange={checked => {
+                changeChecked(
+                  checked
+                    ? weeks.map(item => {
+                        return item.key;
+                      })
+                    : []
+                );
+              }}
             >
             >
-              <CheckBox
-                style={styles.checkBoxAll}
-                checked={allChecked}
-                indeterminate={indeterminate}
-                onChange={(checked) => {
-                                changeChecked(
-                                    checked
-                                        ? weeks.map((item) => {
-                                              return item.key;
-                                          })
-                                        : []
-                                );
-                            }}
-              >
-                {every}
-              </CheckBox>
+              {every}
+            </CheckBox>
 
 
-              {listItems}
-            </Card>
-            <Layout style={styles.btnList}>
-              <Button
-                style={styles.btn}
-                appearance='outline'
-                status='info'
-                onPress={cancelEvent}
-              >
-                {cancel}
-              </Button>
-              <Button
-                style={[styles.btn, { marginLeft: 10 }]}
-                disabled={!canSubmit}
-                onPress={() => {
-                                submit(time1Str, time2Str, checkList);
-                                setShowName([
-                                    `${time1Str  }~${  time2Str}`,
-                                    weekStr,
-                                ]);
-                            }}
-              >
-                {confirm}
-              </Button>
-            </Layout>
+            {listItems}
           </Card>
           </Card>
-        </Modal>
-      </>
-    );
+          <Layout style={styles.btnList}>
+            <Button
+              style={styles.btn}
+              appearance="outline"
+              status="info"
+              onPress={cancelEvent}
+            >
+              {cancel}
+            </Button>
+            <Button
+              style={[styles.btn, { marginLeft: 10 }]}
+              disabled={!canSubmit}
+              onPress={() => {
+                submit(time1Str, time2Str, checkList);
+                setShowName([`${time1Str}~${time2Str}`, weekStr]);
+              }}
+            >
+              {confirm}
+            </Button>
+          </Layout>
+        </Card>
+      </Modal>
+    </>
+  );
 }
 }

+ 3 - 0
models/index.js

@@ -9,7 +9,10 @@ import couponModel from "./couponModel";
 import complaintModel from "./complaintModel";
 import complaintModel from "./complaintModel";
 import emailModel from "./emailModel";
 import emailModel from "./emailModel";
 import moenyRecordModel from "./moenyRecordModel";
 import moenyRecordModel from "./moenyRecordModel";
+import loadingModel from "./loadingModel";
 
 
+
+setModel("loadingModel", loadingModel);
 setModel("emailModel", emailModel);
 setModel("emailModel", emailModel);
 setModel("complaintModel", complaintModel);
 setModel("complaintModel", complaintModel);
 setModel("goodsModel", goodsModel);
 setModel("goodsModel", goodsModel);

+ 50 - 50
models/loadingModel.js

@@ -1,54 +1,54 @@
-
+import { Toast, Portal } from "@ant-design/react-native";
 // 加载页
 // 加载页
 export default {
 export default {
-    state: {
-        status: "loading",
-        title: "成功",
-        show: false,
-        time: -1,
+  state: {
+    status: "loading",
+    title: "成功",
+    show: false,
+    time: -1,
+  },
+  actions: ({ model, setState }) => ({
+    loading() {
+      const key = Toast.loading("Loading...", 0);
+      setState({
+        key,
+      });
     },
     },
-    actions: ({ model, setState }) => ({
-        loading() {
-            setState({
-                status: "loading",
-                show: true,
-                time: -1,
-            });
-        },
-        success(title) {
-            setState({
-                status: "success",
-                title,
-                show: true,
-                time: 3000,
-            });
-            const { setTime } = model();
-            setTime();
-        },
-        warnning(title) {
-            setState({
-                status: "warn",
-                title,
-                show: true,
-                time: 3000,
-            });
-            const { setTime } = model();
-            setTime();
-        },
-        setTime() {
-            const { time, show, clear } = model();
-            if (time > 0 && show) {
-                setTimeout(() => {
-                    if (show) {
-                        clear();
-                    }
-                }, time);
-            }
-        },
-        clear() {
-            setState({
-                show: false,
-            });
-        },
-    }),
+    success(title) {
+      setState({
+        status: "success",
+        title,
+        show: true,
+        time: 3000,
+      });
+      const { setTime } = model();
+      setTime();
+    },
+    warnning(title) {
+      setState({
+        status: "warn",
+        title,
+        show: true,
+        time: 3000,
+      });
+      const { setTime } = model();
+      setTime();
+    },
+    setTime() {
+      const { time, show, clear } = model();
+      if (time > 0 && show) {
+        setTimeout(() => {
+          if (show) {
+            clear();
+          }
+        }, time);
+      }
+    },
+    clearLoading() {
+      const { key } = model();
+      if (key) {
+        Portal(key);
+      }
+    },
+  }),
 };
 };

+ 269 - 242
models/userModel.js

@@ -4,257 +4,284 @@
 import * as RootNavigation from "../navigation/RootNavigation";
 import * as RootNavigation from "../navigation/RootNavigation";
 
 
 export default {
 export default {
-    state: {
-        mid: 0,
-        name: "未登录",
-        showName: "未登录",
-        phone: "",
-        isLogin: false,
-        guideStep: 0,
-        registerInfo: null,
-        initApp: true,
-        refreashReason: "login",
+  state: {
+    mid: 0,
+    name: "未登录",
+    showName: "未登录",
+    phone: "",
+    isLogin: false,
+    guideStep: 0,
+    registerInfo: null,
+    initApp: true,
+    refreashReason: "login",
+    initRoute: "Login",
+  },
+  actions: ({ model, setState }) => ({
+    updateUser(userInfo) {
+      setState({ ...userInfo });
     },
     },
-    actions: ({ model, setState }) => ({
-        updateUser(userInfo) {
-            setState({ ...userInfo });
-        },
-        getUserInfo() {
-            setState({ initApp: false });
-            const { updateUser } = model();
-            const { httpGet } = model("httpModel");
-            return httpGet("/merchant/my").then(res => {
-                const _res = { ...res };
-                if (_res) {
-                    updateUser(_res);
-                }
-            });
-        },
-        changeInIt() {
-            setState({ initApp: false });
-        },
-        checkLogin() {
-            const { getUserInfo, status } = model();
-            const { getAsyncStorage } = model("httpModel");
-            return new Promise(resolve => {
-                getUserInfo()
-                    .then(async () => {
-                        let guideStep = await getAsyncStorage("guideStep");
-                        if (status === "PASS") {
-                            guideStep = "4";
-                        }
-                        if (guideStep) {
-                            setState({ guideStep, isLogin: true });
-                        } else {
-                            setState({ isLogin: true });
-                        }
-                        resolve();
-                    })
-                    .catch(() => {
-                        setState({ isLogin: false });
-                        resolve();
-                    });
-            });
-        },
-        loginByPassword(phone, password) {
-            const { httpPost, addAsyncStorage } = model("httpModel");
-            const {  success, warnning } = model("loadingModel");
+    getUserInfo() {
+      setState({ initApp: false });
+      const { updateUser } = model();
+      const { httpGet } = model("httpModel");
+      return httpGet("/merchant/my").then(res => {
+        const _res = { ...res };
+        if (_res) {
+          updateUser(_res);
+        }
+      });
+    },
+    changeInIt() {
+      setState({ initApp: false });
+    },
+    checkLogin() {
+      const { getUserInfo, status } = model();
+      const { getAsyncStorage } = model("httpModel");
+      return new Promise(resolve => {
+        getUserInfo()
+          .then(async () => {
+            let guideStep = await getAsyncStorage("guideStep");
+            if (status === "PASS") {
+              guideStep = "4";
+            }
+            if (guideStep) {
+              setState({ guideStep, isLogin: true });
+            } else {
+              setState({ isLogin: true });
+            }
+            resolve();
+          })
+          .catch(() => {
+            setState({ isLogin: false });
+            resolve();
+          });
+      });
+    },
+    loginByPassword(phone, password) {
+      const { httpPost, addAsyncStorage } = model("httpModel");
+      const { success, warnning } = model("loadingModel");
 
 
-            return httpPost("/auth/login", {
-                username: phone,
-                password,
-            })
-                .then(res => {
-                    if (res) {
-                        addAsyncStorage("token", res);
-                        success("登录成功");
-                        setState({ initApp: true });
-                    }
-                })
-                .catch(e => {
-                    warnning(e.error);
-                });
-        },
-        loginByCode(phone, code) {
-			console.log(phone,code);
-            // httpPost("/auth/phoneLogin", {
-            //     phone,
-            //     code,
-            // })
-            //     .then(res => {
-            //         if (res) {
-            //             updateUser(res);
-            //         }
-            //     })
-            //     .catch(e => {
-            //         console.log(e);
-            //     });
-        },
-        registerFirst({ ...data }) {
-            setState({ registerInfo: data });
-            RootNavigation.navigate("RegisterSe");
-        },
-        registerUser({ ...data }) {
-            const { success } = model("loadingModel");
-            const { httpPost, addAsyncStorage } = model("httpModel");
-            httpPost("/auth/merchantRegister", data, {}, true).then(res => {
-                addAsyncStorage("token", res).then(() => {
-                    if (res) {
-                        success("注册成功");
-                        addAsyncStorage("guideStep", "1").then(() => {
-                            setState({ initApp: true });
-                        });
-                    }
-                });
+      return httpPost("/auth/login", {
+        username: phone,
+        password,
+      })
+        .then(res => {
+          if (res) {
+            addAsyncStorage("token", res);
+            success("登录成功");
+            setState({ initApp: true });
+          }
+        })
+        .catch(e => {
+          warnning(e.error);
+        });
+    },
+    loginByCode(phone, code) {
+      console.log(phone, code);
+      // httpPost("/auth/phoneLogin", {
+      //     phone,
+      //     code,
+      // })
+      //     .then(res => {
+      //         if (res) {
+      //             updateUser(res);
+      //         }
+      //     })
+      //     .catch(e => {
+      //         console.log(e);
+      //     });
+    },
+    registerFirst({ ...data }) {
+      setState({ registerInfo: data });
+      RootNavigation.navigate("RegisterSe");
+    },
+    registerUser({ ...data }) {
+      const { success } = model("loadingModel");
+      const { httpPost, addAsyncStorage } = model("httpModel");
+      httpPost("/auth/merchantRegister", data, {}, true).then(res => {
+        addAsyncStorage("token", res).then(() => {
+          if (res) {
+            success("注册成功");
+            addAsyncStorage("guideStep", "1").then(() => {
+              setState({ initApp: true });
             });
             });
-            // setTimeout(() => {
-            //     success("注册成功");
-            // }, 1000);
-            // getUserInfo().then(_=>{
+          }
+        });
+      });
+      // setTimeout(() => {
+      //     success("注册成功");
+      // }, 1000);
+      // getUserInfo().then(_=>{
 
 
-            // })
-        },
-        registerSecend({ ...data }) {
-            const { registerInfo, registerUser } = model();
-            const _registerInfo = {
-                ...registerInfo,
-                ...data,
-            };
-            registerUser(_registerInfo);
-        },
-        changeGuideStep(step) {
-            console.log("a");
-            console.log(step);
-            const { addAsyncStorage } = model("httpModel");
-            addAsyncStorage("guideStep", step.toString()).then(() => {
-                setState({ initApp: true, refreashReason: "guideStep" });
+      // })
+    },
+    registerSecend({ ...data }) {
+      const { registerInfo, registerUser } = model();
+      const _registerInfo = {
+        ...registerInfo,
+        ...data,
+      };
+      registerUser(_registerInfo);
+    },
+    changeGuideStep(step) {
+      const { addAsyncStorage } = model("httpModel");
+      addAsyncStorage("guideStep", step.toString()).then(() => {
+        setState({ initApp: true, refreashReason: "guideStep" });
 
 
-                setTimeout(() => {
-                    setState({ initApp: false });
-                }, 500);
-            });
-        },
-        saveMerchant({ ...data }) {
-            const { mid, changeGuideStep } = model();
-            const { httpPost } = model("httpModel");
-            httpPost(
-                "/merchant/saveDTO",
-                {
-                    ...data,
-                    mid,
-                },
-                { body: "json" }
-            ).then(() => {
-                changeGuideStep("5");
-            });
-        },
-        checkInfo({ aliAccountEvent, aliNameEvent }) {
-            const { aliAccount, aliName } = model();
-            aliAccountEvent(aliAccount);
-            aliNameEvent(aliName);
+        setTimeout(() => {
+          setState({ initApp: false });
+        }, 500);
+      });
+    },
+    saveMerchant({ ...data }) {
+      const { mid, changeGuideStep } = model();
+      const { httpPost } = model("httpModel");
+      httpPost(
+        "/merchant/saveDTO",
+        {
+          ...data,
+          mid,
         },
         },
-        updateMerchant({ ...data }) {
-            const { mid, getUserInfo } = model();
-            const { httpPost } = model("httpModel");
-            return httpPost(
-                "/merchant/saveDTO",
-                {
-                    ...data,
-                    mid,
-                },
-                { body: "json" },
-                true
-            ).then(res => {
-                // success("修改成功");
-                if (res) {
-                    getUserInfo();
-                }
-            });
+        { body: "json" }
+      ).then(() => {
+        changeGuideStep("5");
+      });
+    },
+    checkInfo({ aliAccountEvent, aliNameEvent }) {
+      const { aliAccount, aliName } = model();
+      aliAccountEvent(aliAccount);
+      aliNameEvent(aliName);
+    },
+    updateMerchant({ ...data }) {
+      const { mid, getUserInfo } = model();
+      const { httpPost } = model("httpModel");
+      return httpPost(
+        "/merchant/saveDTO",
+        {
+          ...data,
+          mid,
         },
         },
-        uploadStoreImg(img, type) {
-            const { updateMerchant, mid, registerInfo } = model();
-            if (mid !== 0) {
-                if (type === "banner") {
-                    return updateMerchant({ banner: img });
-                } if (type === "qualification") {
-                    return updateMerchant({ qualification: img });
-                } 
-                    return updateMerchant({ logo: img });
-                
-            } if (type === "qualification") {
-                const _registerInfo = { ...registerInfo };
-                _registerInfo.qualification = img;
-                console.log(_registerInfo);
-                setState({
-                    registerInfo: _registerInfo,
-                });
+        { body: "json" },
+        true
+      ).then(res => {
+        // success("修改成功");
+        if (res) {
+          getUserInfo();
+        }
+      });
+    },
+    uploadStoreImg(img, type) {
+      const { updateMerchant, mid, registerInfo } = model();
+      if (mid !== 0) {
+        if (type === "banner") {
+          return updateMerchant({ banner: img });
+        }
+        if (type === "qualification") {
+          return updateMerchant({ qualification: img });
+        }
+        return updateMerchant({ logo: img });
+      }
+      if (type === "qualification") {
+        const _registerInfo = { ...registerInfo };
+        _registerInfo.qualification = img;
+        console.log(_registerInfo);
+        setState({
+          registerInfo: _registerInfo,
+        });
 
 
-                return Promise.resolve();
-			}
-			return Promise.reject();
-        },
-        userLogout() {
-            const { removeAsyncStorage } = model("httpModel");
-            const { success } = model("loadingModel");
+        return Promise.resolve();
+      }
+      return Promise.reject();
+    },
+    userLogout() {
+      const { removeAsyncStorage } = model("httpModel");
+      const { success } = model("loadingModel");
 
 
-            return removeAsyncStorage("token").then(() => {
-                setState({
-                    mid: 0,
-                    name: "未登录",
-                    showName: "未登录",
-                    phone: "",
-                    isLogin: false,
-                    guideStep: 0,
-                    registerInfo: null,
-                    initApp: true,
-                    refreashReason: "loginOut",
-                });
-                success("退出成功");
-            });
-        },
-        getGuideStep() {
-            const { mid, status } = model();
-            const { getAsyncStorage } = model("httpModel");
+      return removeAsyncStorage("token").then(() => {
+        setState({
+          mid: 0,
+          name: "未登录",
+          showName: "未登录",
+          phone: "",
+          isLogin: false,
+          guideStep: 0,
+          registerInfo: null,
+          initApp: true,
+          refreashReason: "loginOut",
+        });
+        success("退出成功");
+      });
+    },
+    getGuideStep() {
+      const { mid, status } = model();
+      const { getAsyncStorage } = model("httpModel");
 
 
-            return new Promise(resolve => {
-                if (mid === 0) {
-                    resolve("");
-                } else {
-                    getAsyncStorage("guideStep").then(res => {
-                        console.log(res);
-                        let guideStep = res;
-                        if (status === "PASS" && !guideStep) {
-                            guideStep = "5";
-                        }
-                        setState({ guideStep, isLogin: true });
-                        resolve(guideStep || "1");
-                    });
-                }
-            });
-        },
-        closeMer() {
-            const { isOpening, getUserInfo } = model();
-            const { httpGet } = model("httpModel");
-            const { success } = model("loadingModel");
-            const { showDialog } = model("dialogModel");
-            if (isOpening) {
-                showDialog({
-                    bodyText: "停止当前营业,直到下次营业开启",
-                    status: "danger",
-                    cancelable: true,
-                    confirmCallback: () => {
-                        httpGet("/merchant/closeMer", {}, true).then(() => {
-                            success("操作成功");
-                            getUserInfo();
-                        });
-                    },
-                });
-            } else {
-                httpGet("/merchant/closeMer", {}, true).then(() => {
-                    success("操作成功");
-                    getUserInfo();
-                });
+      return new Promise(resolve => {
+        if (mid === 0) {
+          resolve("");
+        } else {
+          getAsyncStorage("guideStep").then(res => {
+            console.log(res);
+            let guideStep = res;
+            if (status === "PASS" && !guideStep) {
+              guideStep = "5";
             }
             }
-        },
-    }),
+            setState({ guideStep, isLogin: true });
+            resolve(guideStep || "1");
+          });
+        }
+      });
+    },
+    closeMer() {
+      const { isOpening, getUserInfo } = model();
+      const { httpGet } = model("httpModel");
+      const { success } = model("loadingModel");
+      const { showDialog } = model("dialogModel");
+      if (isOpening) {
+        showDialog({
+          bodyText: "停止当前营业,直到下次营业开启",
+          status: "danger",
+          cancelable: true,
+          confirmCallback: () => {
+            httpGet("/merchant/closeMer", {}, true).then(() => {
+              success("操作成功");
+              getUserInfo();
+            });
+          },
+        });
+      } else {
+        httpGet("/merchant/closeMer", {}, true).then(() => {
+          success("操作成功");
+          getUserInfo();
+        });
+      }
+    },
+    setinitRoute(name) {
+      setState({ initRoute: name });
+    },
+    getNowUser() {
+      const {
+        mid,
+        category,
+        address,
+        week,
+        startTime,
+        endTime,
+		merchantNatureId,
+		qualification,
+        logo,
+      } = model();
+      return {
+        mid,
+        category,
+        address,
+        week,
+        startTime,
+        endTime,
+		merchantNatureId,
+		qualification,
+        logo,
+      };
+    },
+  }),
 };
 };

+ 10 - 55
navigation/GuideStackNavigator.js

@@ -1,4 +1,3 @@
-
 import * as React from "react";
 import * as React from "react";
 
 
 import Guide1Screen from "../screens/Guide1Screen";
 import Guide1Screen from "../screens/Guide1Screen";
@@ -7,58 +6,14 @@ import Guide3Screen from "../screens/Guide3Screen";
 import Guide4Screen from "../screens/Guide4Screen";
 import Guide4Screen from "../screens/Guide4Screen";
 import StoreAudit from "../screens/StoreAudit";
 import StoreAudit from "../screens/StoreAudit";
 
 
-export default function GuideScreens(Screen, guideStep) {
-    if (guideStep === "1") {
-        return (
-          <Screen
-            name='Guide1'
-            component={Guide1Screen}
-            options={{
-                    animationTypeForReplace: guideStep === "1" ? "pop" : "push",
-                }}
-          />
-        );
-    } if (guideStep === "2") {
-        return (
-          <Screen
-            name='Guide2'
-            component={Guide2Screen}
-            options={{
-                    animationTypeForReplace: guideStep === "2" ? "pop" : "push",
-                }}
-          />
-        );
-    } if (guideStep === "3") {
-        return (
-          <Screen
-            name='Guide3'
-            component={Guide3Screen}
-            options={{
-                    animationTypeForReplace: guideStep === "3" ? "pop" : "push",
-                }}
-          />
-        );
-    } if (guideStep === "4") {
-        return (
-          <Screen
-            name='Guide4'
-            component={Guide4Screen}
-            options={{
-                    animationTypeForReplace: guideStep === "4" ? "pop" : "push",
-                }}
-          />
-        );
-    } if (guideStep === "5") {
-        return (
-          <Screen
-            name='StoreAudit'
-            component={StoreAudit}
-            options={{
-                    animationTypeForReplace: guideStep === "5" ? "pop" : "push",
-                }}
-          />
-        );
-    } 
-        return <></>;
-    
+export default function GuideScreens(Screen) {
+  return (
+    <>
+      <Screen name="Guide1" component={Guide1Screen} />
+      <Screen name="Guide2" component={Guide2Screen} />
+      <Screen name="Guide3" component={Guide3Screen} />
+      <Screen name="Guide4" component={Guide4Screen} />
+      <Screen name="StoreAudit" component={StoreAudit} />
+    </>
+  );
 }
 }

+ 11 - 8
navigation/LoginStackNavigator.js

@@ -3,6 +3,7 @@ import {
     CardStyleInterpolators,
     CardStyleInterpolators,
 } from "@react-navigation/stack";
 } from "@react-navigation/stack";
 import * as React from "react";
 import * as React from "react";
+import { useModel } from "flooks";
 
 
 import LoginScreen from "../screens/LoginScreen";
 import LoginScreen from "../screens/LoginScreen";
 import RegisterScreen from "../screens/RegisterScreen";
 import RegisterScreen from "../screens/RegisterScreen";
@@ -12,18 +13,20 @@ const LoginStack = createStackNavigator();
 
 
 
 
 export default function LoginStackNavigator() {
 export default function LoginStackNavigator() {
+	const {initRoute}=useModel('userModel')
+
     return (
     return (
       <LoginStack.Navigator
       <LoginStack.Navigator
-        headerMode='none'
+        headerMode="none"
         screenOptions={{
         screenOptions={{
-                gestureEnabled: true,
-                cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
-            }}
-        initialRouteName='Login'
+          gestureEnabled: true,
+          cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
+        }}
+        initialRouteName={initRoute}
       >
       >
-        <LoginStack.Screen name='Login' component={LoginScreen} />
-        <LoginStack.Screen name='Register' component={RegisterScreen} />
-        <LoginStack.Screen name='RegisterSe' component={RegisterSeScreen} />
+        <LoginStack.Screen name="Login" component={LoginScreen} />
+        <LoginStack.Screen name="Register" component={RegisterScreen} />
+        <LoginStack.Screen name="RegisterSe" component={RegisterSeScreen} />
       </LoginStack.Navigator>
       </LoginStack.Navigator>
     );
     );
 }
 }

+ 2 - 2
screens/HomeScreen.js

@@ -94,7 +94,7 @@ const styles = StyleSheet.create({
     textAlign: "left",
     textAlign: "left",
     fontSize: 13,
     fontSize: 13,
     paddingHorizontal: 10,
     paddingHorizontal: 10,
-    minWidth: 120,
+	minWidth: 120,
   },
   },
   homeCard: {
   homeCard: {
     position: "absolute",
     position: "absolute",
@@ -104,7 +104,7 @@ const styles = StyleSheet.create({
     zIndex: 2,
     zIndex: 2,
   },
   },
   mainContent: {
   mainContent: {
-    marginTop: 100,
+    marginTop: 120,
     backgroundColor: "transparent",
     backgroundColor: "transparent",
   },
   },
   tab: {
   tab: {

+ 217 - 206
screens/RegisterSeScreen.js

@@ -3,16 +3,8 @@
 import * as WebBrowser from "expo-web-browser";
 import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
 import * as React from "react";
 import { useModel } from "flooks";
 import { useModel } from "flooks";
-import {
-    StyleSheet,
-} from "react-native";
-import {
-    Layout,
-    Text,
-    useTheme,
-    Button,
-    Card,
-} from "@ui-kitten/components";
+import { StyleSheet } from "react-native";
+import { Layout, Text, useTheme, Button, Card } from "@ui-kitten/components";
 
 
 import { useFocusEffect } from "@react-navigation/native";
 import { useFocusEffect } from "@react-navigation/native";
 
 
@@ -23,204 +15,223 @@ import GuideHeaderBar from "../components/GuideHeaderBar";
 import * as RootNavigation from "../navigation/RootNavigation";
 import * as RootNavigation from "../navigation/RootNavigation";
 
 
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
-    container: {
-        flex: 1,
-        paddingBottom: 33,
-    },
-    tabContent: {
-        backgroundColor: "#fff",
-        marginTop: 20,
-    },
-    logo: {
-        width: 100,
-        height: 100,
-        alignSelf: "center",
-    },
-    logo2: {
-        width: 97,
-        height: 21,
-        alignSelf: "center",
-        marginTop: 2,
-    },
-    text: {
-        marginTop: 16,
-    },
-    layoutLeft: {
-        flexDirection: "row",
-        paddingVertical: 10,
-        justifyContent: "center",
-    },
-    form: {
-        paddingHorizontal: 26,
-        paddingVertical: 20,
-    },
+  container: {
+    flex: 1,
+    paddingBottom: 33,
+  },
+  tabContent: {
+    backgroundColor: "#fff",
+    marginTop: 20,
+  },
+  logo: {
+    width: 100,
+    height: 100,
+    alignSelf: "center",
+  },
+  logo2: {
+    width: 97,
+    height: 21,
+    alignSelf: "center",
+    marginTop: 2,
+  },
+  text: {
+    marginTop: 16,
+  },
+  layoutLeft: {
+    flexDirection: "row",
+    paddingVertical: 10,
+    justifyContent: "center",
+  },
+  form: {
+    paddingHorizontal: 26,
+    paddingVertical: 20,
+  },
 });
 });
 
 
 export default function RegisterScreen() {
 export default function RegisterScreen() {
-    const theme = useTheme();
-    const { changeBackground } = useModel("barModel");
-    const { httpGet } = useModel("httpModel", true);
-    const { registerSecend, registerInfo } = useModel("userModel");
-    const {
-        guideHome_title1,
-        guideHome_title2,
-        guideHome_form_1,
-        guideHome_form_2,
-        guideHome_form_4,
-        guideHome_form_5,
-        guideHome_form_6,
-        guideHome_form_7,
-        guideHome_pla_2,
-        guideHome_pla_3,
-        next,
-    } = useModel("wordsModel");
-    const [categoryList, changeCategoryList] = React.useState([]);
-    const [merchantNatureList, changeMerchantNatureList] = React.useState([]);
-    const [qualification, changeQualification] = React.useState("");
-    useFocusEffect(
-        React.useCallback(() => {
-            changeBackground(theme["color-primary-500"]);
-            httpGet("/category/tree", { id: 1 }).then(res => {
-                changeCategoryList(res);
-            });
-
-            httpGet("/merchantNature/all").then(res => {
-                changeMerchantNatureList(res.content);
-            });
-        }, [])
-    );
-
-    React.useEffect(() => {
-        if (registerInfo && registerInfo.qualification) {
-            changeQualification(registerInfo.qualification);
-        }
-    }, [registerInfo]);
-
-    const [category, changeCategory] = React.useState("");
-    const [address, changeAddress] = React.useState("");
-    const [week, changeWeek] = React.useState("");
-    const [startTime, changeStartTime] = React.useState("08:00:00");
-    const [endTime, changeEndTime] = React.useState("22:00:00");
-    const [merchantNatureId, changeMerchantNatureId] = React.useState("");
-    const [logo, changeLogo] = React.useState();
-    const timeValue = React.useMemo(() => {
-        if (week && startTime && endTime) {
-            return `${week  } ${  startTime  }~${  endTime}`;
-        } 
-            return " ";
-        
-    }, [week, startTime, endTime]);
-
-    const canNext = React.useMemo(() => {
-        if ((category, address, merchantNatureId, logo)) {
-            return true;
-        } 
-            return false;
-        
-    }, [logo]);
-
-
-    return (
-      <>
-        <GuideHeaderBar />
-        <ScrollPage>
-          <Layout style={styles.container}>
-            <Card appearance='headFilled'>
-              <Text category='s1'>{guideHome_title1}</Text>
-              <Text category='s1'>{guideHome_title2}</Text>
+  const theme = useTheme();
+  const { changeBackground } = useModel("barModel");
+  const { httpGet } = useModel("httpModel", true);
+  const { mid, registerSecend, registerInfo, getNowUser } = useModel(
+    "userModel"
+  );
+  const {
+    guideHome_title1,
+    guideHome_title2,
+    guideHome_form_1,
+    guideHome_form_2,
+    guideHome_form_4,
+    guideHome_form_5,
+    guideHome_form_6,
+    guideHome_form_7,
+    guideHome_pla_2,
+    guideHome_pla_3,
+    next,
+  } = useModel("wordsModel");
+  const [categoryList, changeCategoryList] = React.useState([]);
+  const [merchantNatureList, changeMerchantNatureList] = React.useState([]);
+  const [qualification, changeQualification] = React.useState("");
+  useFocusEffect(
+    React.useCallback(() => {
+      changeBackground(theme["color-primary-500"]);
+      httpGet("/category/tree", { id: 1 }).then(res => {
+        changeCategoryList(res);
+      });
+
+      httpGet("/merchantNature/all").then(res => {
+        changeMerchantNatureList(res.content);
+      });
+    }, [])
+  );
+
+  React.useEffect(() => {
+    if (registerInfo && registerInfo.qualification) {
+      changeQualification(registerInfo.qualification);
+    }
+  }, [registerInfo]);
+
+  const [category, changeCategory] = React.useState("");
+  const [address, changeAddress] = React.useState("");
+  const [week, changeWeek] = React.useState("");
+  const [startTime, changeStartTime] = React.useState("08:00:00");
+  const [endTime, changeEndTime] = React.useState("22:00:00");
+  const [merchantNatureId, changeMerchantNatureId] = React.useState("");
+  const [logo, changeLogo] = React.useState();
+
+  React.useEffect(() => {
+    if (mid) {
+      let userInfo = getNowUser();
+      changeCategory(userInfo.category);
+      changeAddress(userInfo.address);
+      changeWeek(userInfo.week);
+      changeLogo(userInfo.logo);
+      changeMerchantNatureId(userInfo.merchantNatureId);
+      changeStartTime(userInfo.startTime);
+      changeEndTime(userInfo.endTime);
+      changeQualification(userInfo.qualification);
+    }
+  }, [mid]);
+
+  const timeValue = React.useMemo(() => {
+    if (week && startTime && endTime) {
+      return `${week} ${startTime}~${endTime}`;
+    }
+    return " ";
+  }, [week, startTime, endTime]);
+
+  const canNext = React.useMemo(() => {
+    if ((category, address, merchantNatureId, logo)) {
+      return true;
+    }
+    return false;
+  }, [logo]);
+
+  return (
+    <>
+      <GuideHeaderBar />
+      <ScrollPage>
+        <Layout style={styles.container}>
+          {mid === 0 && (
+            <Card appearance="headFilled">
+              <Text category="s1">{guideHome_title1}</Text>
+              <Text category="s1">{guideHome_title2}</Text>
             </Card>
             </Card>
-            <Card appearance='formFilled'>
-              {/* 输入商家名称 */}
-              <FormInput
-                label={guideHome_form_1}
-                selectTitle={guideHome_form_1}
-                type='select'
-                value={category}
-                onChange={changeCategory}
-                textAlign='right'
-                selectList={categoryList}
-                style={{ paddingVertical: 5 }}
-              />
-
-              <FormInput
-                label={guideHome_form_2}
-                value={address}
-                onChange={changeAddress}
-                textAlign='right'
-              />
-
-              <FormInput
-                label={guideHome_form_4}
-                selectTitle={guideHome_form_4}
-                type='openTime'
-                value={timeValue}
-                onChange={(week, startTime, endTime) => {
-                                changeWeek(week);
-                                changeStartTime(startTime);
-                                changeEndTime(endTime);
-                            }}
-                textAlign='right'
-                style={{ paddingVertical: 5 }}
-              />
-
-              <FormInput
-                label={guideHome_form_5}
-                sub={guideHome_pla_2}
-                type='url'
-                value={qualification ? "已上传" : " "}
-                textAlign='right'
-                style={{ paddingVertical: 5 }}
-                changePath={() => {
-                                RootNavigation.navigate("EditBanner", {
-                                    type: "qualification",
-                                });
-                            }}
-              />
-
-              <FormInput
-                label={guideHome_form_6}
-                sub={guideHome_pla_3}
-                selectTitle={guideHome_form_6}
-                type='select'
-                value={merchantNatureId}
-                textAlign='right'
-                style={{ paddingVertical: 5 }}
-                onChange={changeMerchantNatureId}
-                selectList={merchantNatureList}
-              />
-
-              <FormInput
-                label={guideHome_form_7}
-                type='img'
-                value={logo}
-                textAlign='right'
-                onChange={changeLogo}
-              />
-              <Layout style={styles.layoutLeft} level='1'>
-                <Button
-                  status='primary'
-                  disabled={!canNext}
-                  onPress={() =>
-                                    registerSecend({
-                                        category,
-                                        address,
-                                        week,
-                                        startTime,
-                                        endTime,
-                                        qualification,
-                                        merchantNatureId,
-                                        logo,
-                                    })}
-                >
-                  {next}
-                </Button>
-              </Layout>
-            </Card>
-            <ConnectButton />
-          </Layout>
-        </ScrollPage>
-      </>
-    );
+          )}
+
+          <Card appearance="formFilled">
+            {/* 输入商家名称 */}
+            <FormInput
+              label={guideHome_form_1}
+              selectTitle={guideHome_form_1}
+              type="select"
+              value={category}
+              onChange={changeCategory}
+              textAlign="right"
+              selectList={categoryList}
+              style={{ paddingVertical: 5 }}
+            />
+
+            <FormInput
+              label={guideHome_form_2}
+              value={address}
+              onChange={changeAddress}
+              textAlign="right"
+            />
+
+            <FormInput
+              label={guideHome_form_4}
+              selectTitle={guideHome_form_4}
+              type="openTime"
+              value={timeValue}
+              week={week}
+              startTime={startTime}
+              endTime={startTime}
+              onChange={(week, startTime, endTime) => {
+                changeWeek(week);
+                changeStartTime(startTime);
+                changeEndTime(endTime);
+              }}
+              textAlign="right"
+              style={{ paddingVertical: 5 }}
+            />
+
+            <FormInput
+              label={guideHome_form_5}
+              sub={guideHome_pla_2}
+              type="url"
+              value={qualification ? "已上传" : " "}
+              textAlign="right"
+              style={{ paddingVertical: 5 }}
+              changePath={() => {
+                RootNavigation.navigate("EditBanner", {
+                  type: "qualification",
+                });
+              }}
+            />
+
+            <FormInput
+              label={guideHome_form_6}
+              sub={guideHome_pla_3}
+              selectTitle={guideHome_form_6}
+              type="select"
+              value={merchantNatureId}
+              textAlign="right"
+              style={{ paddingVertical: 5 }}
+              onChange={changeMerchantNatureId}
+              selectList={merchantNatureList}
+            />
+
+            <FormInput
+              label={guideHome_form_7}
+              type="img"
+              value={logo}
+              textAlign="right"
+              onChange={changeLogo}
+            />
+            <Layout style={styles.layoutLeft} level="1">
+              <Button
+                status="primary"
+                disabled={!canNext}
+                onPress={() =>
+                  registerSecend({
+                    category,
+                    address,
+                    week,
+                    startTime,
+                    endTime,
+                    qualification,
+                    merchantNatureId,
+                    logo,
+                  })
+                }
+              >
+                {next}
+              </Button>
+            </Layout>
+          </Card>
+          <ConnectButton />
+        </Layout>
+      </ScrollPage>
+    </>
+  );
 }
 }
-
-

+ 96 - 109
screens/StoreAudit.js

@@ -1,128 +1,115 @@
 import * as WebBrowser from "expo-web-browser";
 import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
 import * as React from "react";
 import { useFocusEffect } from "@react-navigation/native";
 import { useFocusEffect } from "@react-navigation/native";
-import {
-    Image,
-    StyleSheet,
-} from "react-native";
+import { Image, StyleSheet } from "react-native";
 import { useModel } from "flooks";
 import { useModel } from "flooks";
-import {
-    Layout,
-    Text,
-    useTheme,
-    Button,
-} from "@ui-kitten/components";
+import { Layout, Text, useTheme, Button } from "@ui-kitten/components";
 import NavHeaderBar from "../components/NavHeaderBar";
 import NavHeaderBar from "../components/NavHeaderBar";
 import ConnectButton from "../components/ConnectButton";
 import ConnectButton from "../components/ConnectButton";
-import ScrollPage from '../components/ScrollPage'
+import ScrollPage from "../components/ScrollPage";
 
 
 const img = require("../assets/images/shehe1.png");
 const img = require("../assets/images/shehe1.png");
 const img1 = require("../assets/images/shenhe.png");
 const img1 = require("../assets/images/shenhe.png");
+const img2 = require("../assets/images/shehe2.png");
 
 
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
-    container: {
-        flex: 1,
-        paddingBottom: 33,
-        paddingVertical: 40,
-        alignItems: "center",
-    },
-    icon: {
-        width: 90,
-        height: 80,
-        marginBottom: 26,
-    },
-    text: {
-        fontWeight: "500",
-        marginBottom: 7,
-    },
-    button: {
-        marginTop: 19,
-    },
+  container: {
+    flex: 1,
+    paddingBottom: 33,
+    paddingVertical: 40,
+    alignItems: "center",
+  },
+  icon: {
+    width: 90,
+    height: 80,
+    marginBottom: 26,
+  },
+  text: {
+    fontWeight: "500",
+    marginBottom: 7,
+  },
+  button: {
+    marginTop: 19,
+  },
 });
 });
 
 
-
 export default function StoreAudit() {
 export default function StoreAudit() {
-    const theme = useTheme();
-    const { changeBackground } = useModel("barModel");
-    const { status, changeGuideStep, getUserInfo } = useModel("userModel");
+  const theme = useTheme();
+  const { changeBackground } = useModel("barModel");
+  const { status, changeGuideStep, getUserInfo } = useModel("userModel");
 
 
-    const {
-        storeAudio,
-        storeAudioText1,
-        storeAudioText2,
-        storeAudioText3,
-        storeAudioText4,
-        complete,
-    } = useModel("wordsModel");
-    useFocusEffect(
-        React.useCallback(() => {
-            changeBackground(theme["color-primary-500"]);
-        }, [])
-    );
+  const {
+    storeAudio,
+    storeAudioText1,
+    storeAudioText2,
+    storeAudioText3,
+    storeAudioText4,
+    complete,
+  } = useModel("wordsModel");
+  useFocusEffect(
+    React.useCallback(() => {
+      changeBackground(theme["color-primary-500"]);
+    }, [])
+  );
 
 
-    function refreshEvent() {
-        return getUserInfo();
-    }
+  function refreshEvent() {
+    return getUserInfo();
+  }
 
 
-    return (
-      <>
-        <NavHeaderBar title={storeAudio} back={false} />
-        <ScrollPage enabledFresh refreshEvent={refreshEvent}>
-          <Layout style={styles.container}>
-            {status === "PENDING" ? (
-              <>
-                <Image
-                  source={img1}
-                  style={styles.icon}
-                />
-                <Text
-                  category='h6'
-                  status='info'
-                  style={styles.text}
-                >
-                  {storeAudioText1}
-                </Text>
-                <Text
-                  category='h6'
-                  status='info'
-                  style={styles.text}
-                >
-                  {storeAudioText2}
-                </Text>
-              </>
-                    ) : (
-                      <>
-                        <Image
-                          source={img}
-                          style={styles.icon}
-                        />
-                        <Text
-                          category='h6'
-                          status='primary'
-                          style={styles.text}
-                        >
-                          {storeAudioText3}
-                        </Text>
-                        <Text
-                          category='h6'
-                          status='primary'
-                          style={styles.text}
-                        >
-                          {storeAudioText4}
-                        </Text>
-                        <Button
-                          style={styles.button}
-                          onPress={() => changeGuideStep("finish")}
-                        >
-                          {complete}
-                        </Button>
-                      </>
-                    )}
+  const PENDINGInfo = () => (
+    <>
+      <Image source={img1} style={styles.icon} />
+      <Text category="h6" status="info" style={styles.text}>
+        {storeAudioText1}
+      </Text>
+      <Text category="h6" status="info" style={styles.text}>
+        {storeAudioText2}
+      </Text>
+    </>
+  );
 
 
-            <ConnectButton />
-          </Layout>
-        </ScrollPage>
-      </>
-    );
-}
+  const PASSInfo = () => (
+    <>
+      <Image source={img} style={styles.icon} />
+      <Text category="h6" status="primary" style={styles.text}>
+        {storeAudioText3}
+      </Text>
+      <Text category="h6" status="primary" style={styles.text}>
+        {storeAudioText4}
+      </Text>
+      <Button style={styles.button} onPress={() => changeGuideStep("finish")}>
+        {complete}
+      </Button>
+    </>
+  );
+
+  const DENYInfo = () => (
+    <>
+      <Image source={img2} style={styles.icon} />
+      <Text category="h6" status="danger" style={styles.text}>
+        很抱歉!!!您的店铺审核暂未通过
+      </Text>
+      <Text category="h6" status="danger" style={styles.text}>
+        请仔细检查店铺信息重新申请
+      </Text>
+      <Button style={styles.button} onPress={() => changeGuideStep("ComeBack")}>
+        重新申请
+      </Button>
+    </>
+  );
 
 
+  return (
+    <>
+      <NavHeaderBar title={storeAudio} back={false} />
+      <ScrollPage enabledFresh refreshEvent={refreshEvent}>
+        <Layout style={styles.container}>
+          {status === "PENDING" && <PENDINGInfo />}
+          {status === "PASS" && <PASSInfo />}
+          {status === "DENY" && <DENYInfo />}
+
+          <ConnectButton />
+        </Layout>
+      </ScrollPage>
+    </>
+  );
+}