panhui vor 5 Jahren
Ursprung
Commit
db1aec46c6
6 geänderte Dateien mit 338 neuen und 363 gelöschten Zeilen
  1. 2 1
      App.js
  2. 10 8
      models/userModel.js
  3. 8 5
      screens/Guide1Screen.js
  4. 197 212
      screens/Guide2Screen.js
  5. 118 134
      screens/Guide3Screen.js
  6. 3 3
      screens/RegisterSeScreen.js

+ 2 - 1
App.js

@@ -100,6 +100,7 @@ export default function App(props) {
   }, [mid]);
 
   useUpdateEffect(() => {
+    console.log(guideStep);
     switch (guideStep) {
       case "finish":
         setInit("Root");
@@ -148,7 +149,7 @@ export default function App(props) {
     }
   }, [initRouteName]);
 
-  if (!isLoadingComplete && !props.skipLoadingScreen && !!initRouteName) {
+  if (!isLoadingComplete && !props.skipLoadingScreen && !initRouteName) {
     return null;
   }
 

+ 10 - 8
models/userModel.js

@@ -10,7 +10,7 @@ export default {
     showName: "未登录",
     phone: "",
     isLogin: false,
-    guideStep: 0,
+    guideStep: "0",
     registerInfo: {},
     initApp: true,
     refreashReason: "login",
@@ -121,6 +121,12 @@ export default {
         .then(res => {
           return addAsyncStorage("token", res);
         })
+        .then(() => {
+          setState({
+            guideStep: "1",
+          });
+          return addAsyncStorage("guideStep", "1");
+        })
         .then(() => {
           return getUserInfo();
         })
@@ -129,10 +135,6 @@ export default {
         })
         .then(() => {
           success("注册成功");
-          return addAsyncStorage("guideStep", "1");
-        })
-        .then(() => {
-          setState({ initApp: true });
         });
       // setTimeout(() => {
       //     success("注册成功");
@@ -151,7 +153,7 @@ export default {
     },
     changeGuideStep(step) {
       const { addAsyncStorage } = model("httpModel");
-      setState({ guideStep: step });
+      setState({ guideStep: step.toString() });
       return addAsyncStorage("guideStep", step.toString());
     },
     saveMerchant({ ...data }) {
@@ -165,7 +167,7 @@ export default {
         },
         { body: "json" }
       ).then(() => {
-        changeGuideStep("5");
+        changeGuideStep("4");
       });
     },
     checkInfo({ aliAccountEvent, aliNameEvent }) {
@@ -225,7 +227,7 @@ export default {
           showName: "未登录",
           phone: "",
           isLogin: false,
-          guideStep: 0,
+          guideStep: "0",
           registerInfo: null,
           initApp: true,
           refreashReason: "loginOut",

+ 8 - 5
screens/Guide1Screen.js

@@ -105,7 +105,8 @@ export default function Guide1Screen({ navigation }) {
   } = useModel("wordsModel");
   const { showDialog } = useModel("dialogModel");
   const route = useRoute();
-  const routeName = route.name;
+  const [routeName, setRouteName] = React.useState("");
+
   const [id, changeId] = React.useState("");
 
   const [name, changeName] = React.useState("");
@@ -152,8 +153,10 @@ export default function Guide1Screen({ navigation }) {
   }
   useFocusEffect(
     React.useCallback(() => {
+      console.log(route);
       changeBackground(theme["color-primary-500"]);
-      const { params } = route;
+      const { params, name } = route;
+      setRouteName(name);
       if (params) {
         if (params.id) {
           changeId(params.id);
@@ -266,7 +269,7 @@ export default function Guide1Screen({ navigation }) {
               onChange={changeDiscountAmount}
               textAlign="right"
             />
-            {id !== 0 && (
+            {!!id && (
               <>
                 {/* 商品规格 */}
                 <FormInput
@@ -356,7 +359,7 @@ export default function Guide1Screen({ navigation }) {
                     }
                     success(`${id ? "修改" : "添加"}成功`);
                     if (routeName !== "AddGoods") {
-                      changeGuideStep(2);
+                      changeGuideStep("2");
                     } else {
                       navigation.goBack();
                     }
@@ -365,7 +368,7 @@ export default function Guide1Screen({ navigation }) {
               >
                 {routeName !== "AddGoods" ? next : confirm}
               </Button>
-              {routeName === "AddGoods" && id !== 0 && (
+              {routeName === "AddGoods" && !!id && (
                 <Button
                   appearance="ghost"
                   status="info"

+ 197 - 212
screens/Guide2Screen.js

@@ -3,16 +3,8 @@
 /* eslint-disable no-unused-vars */
 import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
-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 { useModel } from "flooks";
 import { useFocusEffect, useRoute } from "@react-navigation/native";
 import ScrollPage from "../components/ScrollPage";
@@ -22,232 +14,225 @@ import ConnectButton from "../components/ConnectButton";
 import GuideHeaderBar from "../components/GuideHeaderBar";
 import * as RootNavigation from "../navigation/RootNavigation";
 
-
 const styles = StyleSheet.create({
-    container: {
-        flex: 1,
-        paddingBottom: 33,
-    },
-    tabContent: {
-        backgroundColor: "#fff",
-        marginTop: 20,
-    },
-    img: {
-        width: 100,
-        height: 100,
-        alignSelf: "center",
-    },
-    img2: {
-        width: 97,
-        height: 21,
-        alignSelf: "center",
-        marginTop: 2,
-    },
-    text: {
-        marginTop: 16,
-    },
-    layoutLeft: {
-        // flexDirection: "row",
-        paddingVertical: 10,
-        justifyContent: "center",
-        alignItems: "center",
-    },
-    form: {
-        paddingHorizontal: 26,
-        paddingVertical: 20,
-    },
-    textareaContainer: {
-        backgroundColor: "#F0F0F0",
-        height: 100,
-        borderRadius: 4,
-    },
-    textarea: {
-        textAlignVertical: "top", // hack android
-        fontSize: 13,
-        color: "#333",
-        paddingHorizontal: 14,
-        paddingVertical: 10,
-        height: 100,
-    },
+  container: {
+    flex: 1,
+    paddingBottom: 33,
+  },
+  tabContent: {
+    backgroundColor: "#fff",
+    marginTop: 20,
+  },
+  img: {
+    width: 100,
+    height: 100,
+    alignSelf: "center",
+  },
+  img2: {
+    width: 97,
+    height: 21,
+    alignSelf: "center",
+    marginTop: 2,
+  },
+  text: {
+    marginTop: 16,
+  },
+  layoutLeft: {
+    // flexDirection: "row",
+    paddingVertical: 10,
+    justifyContent: "center",
+    alignItems: "center",
+  },
+  form: {
+    paddingHorizontal: 26,
+    paddingVertical: 20,
+  },
+  textareaContainer: {
+    backgroundColor: "#F0F0F0",
+    height: 100,
+    borderRadius: 4,
+  },
+  textarea: {
+    textAlignVertical: "top", // hack android
+    fontSize: 13,
+    color: "#333",
+    paddingHorizontal: 14,
+    paddingVertical: 10,
+    height: 100,
+  },
 });
 
-
-
-
 export default function Guide1Screen() {
-    const route = useRoute();
-    const theme = useTheme();
-    const { changeBackground } = useModel("barModel");
-    const {  httpPost } = useModel("httpModel", true);
-    const { changeGuideStep, mid } = useModel(
-        "userModel",
-        true
-    );
-    const { success } = useModel("loadingModel", true);
+  const route = useRoute();
+  const theme = useTheme();
+  const { changeBackground } = useModel("barModel");
+  const { httpPost } = useModel("httpModel", true);
+  const { changeGuideStep, mid } = useModel("userModel", true);
+  const { success } = useModel("loadingModel", true);
 
-    const {
-        guide2_title1,
-        guide2_title2,
-        guide2_form_1,
-        guide2_pla_1,
-        guide2_pla_2,
-        guide1_pla_2,
-        guide2_form_2,
-        guide2_form_3,
-        guide1_form_4,
-        guide1_pla_4,
-        guide1_form_5,
-        guide1_pla_5,
-        next,
-        pass,
-        passTips,
-    } = useModel("wordsModel");
-    const { showDialog } = useModel("dialogModel");
-    const [pageName, changePageName] = React.useState("");
-    const [name, changeName] = React.useState("");
-    const [sort, changeSort] = React.useState("");
-    const [goodsIds, changeGoodsIds] = React.useState("");
-    const { selectInfos, changeSelect } = useModel("goodsModel");
+  const {
+    guide2_title1,
+    guide2_title2,
+    guide2_form_1,
+    guide2_pla_1,
+    guide2_pla_2,
+    guide1_pla_2,
+    guide2_form_2,
+    guide2_form_3,
+    guide1_form_4,
+    guide1_pla_4,
+    guide1_form_5,
+    guide1_pla_5,
+    next,
+    pass,
+    passTips,
+  } = useModel("wordsModel");
+  const { showDialog } = useModel("dialogModel");
+  const [pageName, changePageName] = React.useState("");
+  const [name, changeName] = React.useState("");
+  const [sort, changeSort] = React.useState("");
+  const [goodsIds, changeGoodsIds] = React.useState("");
+  const { selectInfos, changeSelect } = useModel("goodsModel");
 
-    useFocusEffect(
-        React.useCallback(() => {
-            changeBackground(theme["color-primary-500"]);
-            if (route.name) {
-                changePageName(route.name);
-            }
-        }, [])
-    );
-    React.useEffect(() => {
-        if (selectInfos.length > 0) {
-            const _ids = selectInfos.map(item => {
-                return item.id;
-            });
-            changeGoodsIds(_ids.join(","));
-        }
-    }, [selectInfos]);
+  useFocusEffect(
+    React.useCallback(() => {
+      changeBackground(theme["color-primary-500"]);
+      console.log(route);
+      if (route.name) {
+        changePageName(route.name);
+      }
+    }, [])
+  );
+  React.useEffect(() => {
+    if (selectInfos.length > 0) {
+      const _ids = selectInfos.map(item => {
+        return item.id;
+      });
+      changeGoodsIds(_ids.join(","));
+    }
+  }, [selectInfos]);
 
-    const canNext = React.useMemo(() => {
-        if (name && sort) {
-            return true;
-        } 
-            return false;
-        
-    }, [name, sort, goodsIds]);
+  const canNext = React.useMemo(() => {
+    if (name && sort) {
+      return true;
+    }
+    return false;
+  }, [name, sort, goodsIds]);
 
-    const addClass = () => {
-        return httpPost(
-            "/classification/save",
-            {
-                name,
-                sort,
-                goodsIds,
-                merchantId: mid,
-            },
-            { body: "json" }
-        ).then(res => {});
-    };
+  const addClass = () => {
+    return httpPost(
+      "/classification/save",
+      {
+        name,
+        sort,
+        goodsIds,
+        merchantId: mid,
+      },
+      { body: "json" }
+    ).then(res => {});
+  };
 
-    return (
-      <>
-        {pageName !== "AddNewClass" && <GuideHeaderBar />}
-        {pageName === "AddNewClass" && <NavHeaderBar title='添加分类' />}
-        <ScrollPage>
-          <Layout style={styles.container}>
-            {pageName !== "AddNewClass" && (
-            <Card appearance='headFilled'>
-              <Text category='s1'>{guide2_title1}</Text>
-              <Text category='s1'>{guide2_title2}</Text>
+  return (
+    <>
+      {pageName !== "AddNewClass" && <GuideHeaderBar />}
+      {pageName === "AddNewClass" && <NavHeaderBar title="添加分类" />}
+      <ScrollPage>
+        <Layout style={styles.container}>
+          {pageName !== "AddNewClass" && (
+            <Card appearance="headFilled">
+              <Text category="s1">{guide2_title1}</Text>
+              <Text category="s1">{guide2_title2}</Text>
             </Card>
-                    )}
-            <Card appearance='formFilled'>
-              {/* 类别名称 */}
-              <FormInput
-                label={guide2_form_1}
-                placeholder={guide2_pla_1}
-                value={name}
-                onChange={changeName}
-                style={{ paddingVertical: 3 }}
-              />
-              {/* 显示排序 */}
-              <FormInput
-                label={guide2_form_2}
-                value={sort}
-                type='actionSheet'
-                list={[1, 2, 3, 4, 5, 6, 7, 8, 9]}
-                onChange={changeSort}
-                textAlign='right'
-              />
+          )}
+          <Card appearance="formFilled">
+            {/* 类别名称 */}
+            <FormInput
+              label={guide2_form_1}
+              placeholder={guide2_pla_1}
+              value={name}
+              onChange={changeName}
+              style={{ paddingVertical: 3 }}
+            />
+            {/* 显示排序 */}
+            <FormInput
+              label={guide2_form_2}
+              value={sort}
+              type="actionSheet"
+              list={[1, 2, 3, 4, 5, 6, 7, 8, 9]}
+              onChange={changeSort}
+              textAlign="right"
+            />
 
-              {/* 商品 */}
-              <FormInput
-                label={guide2_form_3}
-                value={goodsIds}
-                type='url'
-                changePath={() => {
-                                RootNavigation.navigate("AddClassification", {
-                                    type: "classification",
-                                    classificationId: "new",
-                                    preKey: route.name,
-                                });
-                            }}
-                textAlign='right'
-              />
-              {pageName === "AddNewClass" && (
-                <Layout style={styles.layoutLeft} level='1'>
-                  <Button
-                    status='primary'
-                    disabled={!canNext}
-                    onPress={() => {
-                                        addClass().then(_ => {
-                                            success("添加成功");
-                                            RootNavigation.goBack();
-                                            changeSelect([]);
-                                        });
-                                    }}
-                  >
-                    确定
-                  </Button>
-                </Layout>
-                        )}
-            </Card>
-            {pageName !== "AddNewClass" && (
+            {/* 商品 */}
+            <FormInput
+              label={guide2_form_3}
+              value={goodsIds}
+              type="url"
+              changePath={() => {
+                RootNavigation.navigate("AddClassification", {
+                  type: "classification",
+                  classificationId: "new",
+                  preKey: route.name,
+                });
+              }}
+              textAlign="right"
+            />
+            {pageName === "AddNewClass" && (
+              <Layout style={styles.layoutLeft} level="1">
+                <Button
+                  status="primary"
+                  disabled={!canNext}
+                  onPress={() => {
+                    addClass().then(_ => {
+                      success("添加成功");
+                      RootNavigation.goBack();
+                      changeSelect([]);
+                    });
+                  }}
+                >
+                  确定
+                </Button>
+              </Layout>
+            )}
+          </Card>
+          {pageName !== "AddNewClass" && (
             <ConnectButton>
-              <Layout style={styles.layoutLeft} level='1'>
+              <Layout style={styles.layoutLeft} level="1">
                 <Button
-                  status='primary'
+                  status="primary"
                   disabled={!canNext}
                   onPress={() => {
-                                        addClass()
-                                            .then(_ => {
-                                                success("添加成功");
-                                                changeGuideStep(3);
-                                            })
-                                            .then(e => {});
-                                    }}
+                    addClass()
+                      .then(_ => {
+                        success("添加成功");
+                        changeGuideStep("3");
+                      })
+                      .then(e => {});
+                  }}
                 >
                   {next}
                 </Button>
                 <Button
                   style={{ marginTop: 10 }}
-                  appearance='ghost'
-                  status='primary'
+                  appearance="ghost"
+                  status="primary"
                   onPress={() => {
-                                        showDialog({
-                                            bodyText: passTips,
-                                            cancelable: true,
-                                            confirmCallback: () => {
-                                                changeGuideStep(3);
-                                            },
-                                        });
-                                    }}
+                    showDialog({
+                      bodyText: passTips,
+                      cancelable: true,
+                      confirmCallback: () => {
+                        changeGuideStep("3");
+                      },
+                    });
+                  }}
                 >
                   {pass}
                 </Button>
               </Layout>
             </ConnectButton>
-                    )}
-          </Layout>
-        </ScrollPage>
-      </>
-    );
+          )}
+        </Layout>
+      </ScrollPage>
+    </>
+  );
 }

+ 118 - 134
screens/Guide3Screen.js

@@ -1,153 +1,137 @@
 /* eslint-disable camelcase */
 import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
-import {
-    StyleSheet,
-} from "react-native";
+import { StyleSheet } from "react-native";
 import { useModel } from "flooks";
-import {
-    Layout,
-    Text,
-    useTheme,
-    Button,
-    Card,
-} from "@ui-kitten/components";
+import { Layout, Text, useTheme, Button, Card } from "@ui-kitten/components";
 import { useFocusEffect } from "@react-navigation/native";
 import ScrollPage from "../components/ScrollPage";
 import FormInput from "../components/FormInput";
 import ConnectButton from "../components/ConnectButton";
 import GuideHeaderBar from "../components/GuideHeaderBar";
 
-
 const styles = StyleSheet.create({
-    container: {
-        flex: 1,
-        paddingBottom: 33,
-    },
-    tabContent: {
-        backgroundColor: "#fff",
-        marginTop: 20,
-    },
-    img: {
-        width: 100,
-        height: 100,
-        alignSelf: "center",
-    },
-    img2: {
-        width: 97,
-        height: 21,
-        alignSelf: "center",
-        marginTop: 2,
-    },
-    text: {
-        marginTop: 16,
-    },
-    layoutLeft: {
-        // flexDirection: "row",
-        paddingVertical: 10,
-        justifyContent: "center",
-        alignItems: "center",
-        marginTop: 50,
-    },
-    form: {
-        paddingHorizontal: 26,
-        paddingVertical: 20,
-    },
-    textareaContainer: {
-        backgroundColor: "#F0F0F0",
-        height: 100,
-        borderRadius: 4,
-    },
-    textarea: {
-        textAlignVertical: "top", // hack android
-        fontSize: 13,
-        color: "#333",
-        paddingHorizontal: 14,
-        paddingVertical: 10,
-        height: 100,
-    },
+  container: {
+    flex: 1,
+    paddingBottom: 33,
+  },
+  tabContent: {
+    backgroundColor: "#fff",
+    marginTop: 20,
+  },
+  img: {
+    width: 100,
+    height: 100,
+    alignSelf: "center",
+  },
+  img2: {
+    width: 97,
+    height: 21,
+    alignSelf: "center",
+    marginTop: 2,
+  },
+  text: {
+    marginTop: 16,
+  },
+  layoutLeft: {
+    // flexDirection: "row",
+    paddingVertical: 10,
+    justifyContent: "center",
+    alignItems: "center",
+    marginTop: 50,
+  },
+  form: {
+    paddingHorizontal: 26,
+    paddingVertical: 20,
+  },
+  textareaContainer: {
+    backgroundColor: "#F0F0F0",
+    height: 100,
+    borderRadius: 4,
+  },
+  textarea: {
+    textAlignVertical: "top", // hack android
+    fontSize: 13,
+    color: "#333",
+    paddingHorizontal: 14,
+    paddingVertical: 10,
+    height: 100,
+  },
 });
 
-
-
 export default function Guide1Screen() {
-    const theme = useTheme();
-    const { changeBackground } = useModel("barModel");
-    const { saveMerchant, checkInfo } = useModel(
-        "userModel",
-        true
-    );
+  const theme = useTheme();
+  const { changeBackground } = useModel("barModel");
+  const { saveMerchant, checkInfo } = useModel("userModel", true);
 
-    const {
-        guide3_title1,
-        guide3_title2,
-        guide3_form_1,
-        guide3_pla_1,
-        guide3_form_2,
-        guide3_pla_2,
-        complete,
-    } = useModel("wordsModel");
-    const [aliName, changeAliName] = React.useState("");
-    const [aliAccount, changeAliAccount] = React.useState("");
-    useFocusEffect(
-        React.useCallback(() => {
-            changeBackground(theme["color-primary-500"]);
-            checkInfo({
-                aliAccountEvent: changeAliAccount,
-                aliNameEvent: changeAliName,
-            });
-        }, [])
-    );
+  const {
+    guide3_title1,
+    guide3_title2,
+    guide3_form_1,
+    guide3_pla_1,
+    guide3_form_2,
+    guide3_pla_2,
+    complete,
+  } = useModel("wordsModel");
+  const [aliName, changeAliName] = React.useState("");
+  const [aliAccount, changeAliAccount] = React.useState("");
+  useFocusEffect(
+    React.useCallback(() => {
+      changeBackground(theme["color-primary-500"]);
+      checkInfo({
+        aliAccountEvent: changeAliAccount,
+        aliNameEvent: changeAliName,
+      });
+    }, [])
+  );
 
-    const canNext = React.useMemo(() => {
-        if (aliAccount && aliName) {
-            return true;
-        } 
-            return false;
-        
-    }, [aliName, aliAccount]);
+  const canNext = React.useMemo(() => {
+    if (aliAccount && aliName) {
+      return true;
+    }
+    return false;
+  }, [aliName, aliAccount]);
 
-    return (
-      <>
-        <GuideHeaderBar />
-        <ScrollPage>
-          <Layout style={styles.container}>
-            <Card appearance='headFilled'>
-              <Text category='s1'>{guide3_title1}</Text>
-              <Text category='s1'>{guide3_title2}</Text>
-            </Card>
-            <Card appearance='formFilled'>
-              {/* 支付宝账号 */}
-              <FormInput
-                label={guide3_form_1}
-                placeholder={guide3_pla_1}
-                value={aliName}
-                onChange={changeAliName}
-                style={{ paddingVertical: 3 }}
-              />
-              {/* 支付宝账户名 */}
-              <FormInput
-                label={guide3_form_2}
-                placeholder={guide3_pla_2}
-                value={aliAccount}
-                onChange={changeAliAccount}
-                style={{ paddingVertical: 3 }}
-              />
+  return (
+    <>
+      <GuideHeaderBar />
+      <ScrollPage>
+        <Layout style={styles.container}>
+          <Card appearance="headFilled">
+            <Text category="s1">{guide3_title1}</Text>
+            <Text category="s1">{guide3_title2}</Text>
+          </Card>
+          <Card appearance="formFilled">
+            {/* 支付宝账号 */}
+            <FormInput
+              label={guide3_form_1}
+              placeholder={guide3_pla_1}
+              value={aliName}
+              onChange={changeAliName}
+              style={{ paddingVertical: 3 }}
+            />
+            {/* 支付宝账户名 */}
+            <FormInput
+              label={guide3_form_2}
+              placeholder={guide3_pla_2}
+              value={aliAccount}
+              onChange={changeAliAccount}
+              style={{ paddingVertical: 3 }}
+            />
 
-              <Layout style={styles.layoutLeft} level='1'>
-                <Button
-                  status='primary'
-                  disabled={!canNext}
-                  onPress={() =>
-                                    saveMerchant({ aliName, aliAccount })}
-                >
-                  {complete}
-                </Button>
-              </Layout>
-            </Card>
-            <ConnectButton />
-          </Layout>
-        </ScrollPage>
-      </>
-    );
+            <Layout style={styles.layoutLeft} level="1">
+              <Button
+                status="primary"
+                disabled={!canNext}
+                onPress={() => saveMerchant({ aliName, aliAccount })}
+              >
+                {complete}
+              </Button>
+            </Layout>
+          </Card>
+          <ConnectButton />
+        </Layout>
+      </ScrollPage>
+    </>
+  );
 }

+ 3 - 3
screens/RegisterSeScreen.js

@@ -6,8 +6,8 @@ import { useModel } from "flooks";
 import { StyleSheet } from "react-native";
 import { Layout, Text, useTheme, Button, Card } from "@ui-kitten/components";
 
-import { useFocusEffect } from "@react-navigation/native";
-import { useToggle, useMount } from "@umijs/hooks";
+// import { useFocusEffect } from "@react-navigation/native";
+import {  useMount } from "@umijs/hooks";
 
 import ScrollPage from "../components/ScrollPage";
 import FormInput from "../components/FormInput";
@@ -275,7 +275,7 @@ export default function RegisterScreen() {
               label="法人信息"
               type="url"
               value={
-                realName && idNo && idNoImg && handheldIdNo ? "已上传" : " "
+               ( realName && idNo && idNoImg && handheldIdNo) ? "已上传" : " "
               }
               textAlign="right"
               style={{ paddingVertical: 5 }}