Ver código fonte

首单满减

panhui 5 anos atrás
pai
commit
77416dfcba

+ 2 - 2
Utils/TimeUtil.js

@@ -8,8 +8,8 @@ export function getNowDate() {
     return new Date().getDate();
 }
 
-export function getDateStr() {
-    return moment().format("YYYY-MM-DD");
+export function getDateStr(date) {
+    return moment(date).format("YYYY-MM-DD");
 }
 
 export function getAddDateStr(num) {

+ 1 - 1
components/Badge.js

@@ -14,7 +14,7 @@ export default function Badge(props) {
         
     }, [status]);
 
-    if (appearance === "fill") {
+    if (appearance === "filled") {
         return (
           <Button
             appearance='badge'

+ 45 - 49
components/Datepicker.js

@@ -1,60 +1,56 @@
 import React from "react";
-import {
-    View,
-} from "react-native";
-import {
-    Icon,
-    SelectItem,
-} from "@ui-kitten/components";
+import { View } from "react-native";
+import { Icon, SelectItem } from "@ui-kitten/components";
 import { Datepicker, BottomModal } from "beeshell";
 import * as TimeUtil from "../Utils/TimeUtil";
 
-const ForwardIcon = props => <Icon {...props} name='arrow-ios-forward' />;
+const ForwardIcon = props => <Icon {...props} name="arrow-ios-forward" />;
 
 export default function MyDatepicker(props) {
-    const { value, chooseDate } = props || {};
+  const { value, chooseDate } = props || {};
 
-    const [dateValue, chooseValue] = React.useState();
+  const [dateValue, chooseValue] = React.useState();
 
-    const [bottomModal, setBottomModal] = React.useState();
+  const [bottomModal, setBottomModal] = React.useState();
 
-    return (
-      <>
-        <SelectItem
-          appearance='form'
-          style={{ flex: 1, height: 32 }}
-          accessoryRight={ForwardIcon}
-          title={value || " "}
-          onPress={() => {
-                    bottomModal.open();
-                }}
-        />
-        <BottomModal
-          title=''
-          cancelable
-          ref={c => setBottomModal(c)}
-          rightCallback={() => {
-                    chooseDate(dateValue);
-                }}
+  return (
+    <>
+      <SelectItem
+        appearance="form"
+        style={{ flex: 1, height: 32 }}
+        accessoryRight={ForwardIcon}
+        title={value || " "}
+        onPress={() => {
+          chooseValue(value);
+          bottomModal.open();
+        }}
+      />
+      <BottomModal
+        title=""
+        cancelable
+        ref={c => setBottomModal(c)}
+        rightCallback={() => {
+          chooseDate(dateValue);
+        }}
+      >
+        <View
+          style={{
+            height: 200,
+            marginBottom: 50,
+            minHeight: 200,
+          }}
         >
-          <View
-            style={{
-                        height: 200,
-                        marginBottom: 50,
-                        minHeight: 200,
-                    }}
-          >
-            <Datepicker
-              proportion={[1, 1, 1]}
-              startYear={TimeUtil.getNowYear()}
-              numberOfYears={10}
-              date={TimeUtil.getDateStr()}
-              onChange={date => {
-                            chooseValue(date);
-                        }}
-            />
-          </View>
-        </BottomModal>
-      </>
-    );
+          <Datepicker
+            proportion={[1, 1, 1]}
+            startYear={TimeUtil.getNowYear()}
+            numberOfYears={10}
+            date={dateValue}
+            onChange={date => {
+              chooseValue(date);
+            }}
+          />
+        </View>
+      </BottomModal>
+    </>
+  );
 }

+ 5 - 3
screens/FullReduction.js

@@ -102,6 +102,8 @@ export default function FullReduction() {
     changeFllReduction(_fullReductions);
   };
   const delInfo = (info, index) => {
+    console.log(info);
+    console.log(index);
     showDialog({
       bodyText: removeTips,
       status: "danger",
@@ -213,7 +215,7 @@ export default function FullReduction() {
           size="small"
           defaultValue={info.fullAmount.toString()}
           style={styles.input}
-          key={`${index  }_0`}
+          key={`${index}_0`}
           keyboardType="numeric"
           onChangeText={value => changeText(value, index, "full")}
         />
@@ -222,7 +224,7 @@ export default function FullReduction() {
           size="small"
           defaultValue={info.minusAmount.toString()}
           style={styles.input}
-          key={`${index  }_1`}
+          key={`${index}_1`}
           keyboardType="numeric"
           onChangeText={value => changeText(value, index, "minus")}
         />
@@ -252,7 +254,7 @@ export default function FullReduction() {
     if (!item.id || item.edit) {
       return editItem(item, index);
     }
-    return saveItem(item);
+    return saveItem(item, index);
   };
 
   return (

+ 1 - 1
screens/HomeScreen.js

@@ -260,7 +260,7 @@ export default function HomeScreen({ navigation, route }) {
             userLogout();
           }}
         />
-        <MenuItem title="06.08.01版本" />
+        <MenuItem title="06.08.02版本" />
       </OverflowMenu>
     </>
   );

+ 7 - 7
screens/HomeScreenPage2.js

@@ -54,25 +54,25 @@ export default function HomePage2() {
   return (
     <Layout style={styles.tabContainer}>
       <Layout style={styles.bageList}>
-        <Badge appearance="fill" status="warning" right={5} bottom={4}>
+        <Badge appearance="filled" status="warning" right={5} bottom={4}>
           全部7345
         </Badge>
-        <Badge appearance="fill" right={5} bottom={4}>
+        <Badge appearance="filled" right={5} bottom={4}>
           最新
         </Badge>
-        <Badge appearance="fill" right={5} bottom={4}>
+        <Badge appearance="filled" right={5} bottom={4}>
           好评1213
         </Badge>
-        <Badge appearance="fill" status="info" right={5} bottom={4}>
+        <Badge appearance="filled" status="info" right={5} bottom={4}>
           差评12
         </Badge>
-        <Badge appearance="fill" right={5} bottom={4}>
+        <Badge appearance="filled" right={5} bottom={4}>
           最新
         </Badge>
-        <Badge appearance="fill" right={5} bottom={4}>
+        <Badge appearance="filled" right={5} bottom={4}>
           好评1213
         </Badge>
-        <Badge appearance="fill" status="info" right={5} bottom={4}>
+        <Badge appearance="filled" status="info" right={5} bottom={4}>
           差评12
         </Badge>
       </Layout>

+ 129 - 128
screens/Set/ClassificationManageScreen.js

@@ -1,149 +1,150 @@
 import * as WebBrowser from "expo-web-browser";
 import * as React from "react";
-import ListComponent from "../../components/ListComponent";
-import TipNavHeader from "../../components/TipNavHeader";
 import { useModel } from "flooks";
 import {
-    Layout,
-    Input,
-    Button,
-    Text,
-    ListItem,
-    Icon,
+  Layout,
+  Input,
+  Button,
+  Text,
+  ListItem,
+  Icon,
 } from "@ui-kitten/components";
 import { StyleSheet, View } from "react-native";
 import ListUtil from "../../Utils/ListUtil";
 import { ClassificationUtil } from "../../Utils/SystemRuleUtil";
+import ListComponent from "../../components/ListComponent";
+import TipNavHeader from "../../components/TipNavHeader";
+
 const ForwardIcon = props => (
-    <Icon
-        {...props}
-        name='arrow-ios-forward'
-        fill='#B4B4B4'
-        style={{ width: 15, height: 15, fontWeight: 500 }}
-    />
+  <Icon
+    {...props}
+    name="arrow-ios-forward"
+    fill="#B4B4B4"
+    style={{ width: 15, height: 15, fontWeight: 500 }}
+  />
 );
-//分类设置
+// 分类设置
 export default function ClassificationManageScreen({ navigation, route }) {
-    const {
-        ClassificationManage,
-        ClassificationManageText1,
-        ClassificationManageText2,
-        ClassificationManageText3,
-        ClassificationManageText4,
-        ClassificationManageText5,
-    } = useModel("wordsModel");
+  const {
+    ClassificationManage,
+    ClassificationManageText1,
+    ClassificationManageText2,
+    ClassificationManageText3,
+    ClassificationManageText4,
+    ClassificationManageText5,
+  } = useModel("wordsModel");
+
+  const {
+    getUserInfo,
+    startingAmount,
+    preparationTime,
+    updateMerchant,
+  } = useModel("userModel");
+  const { success } = useModel("loadingModel");
 
-    const {
-        getUserInfo,
-        startingAmount,
-        preparationTime,
-        updateMerchant,
-    } = useModel("userModel");
-    const { success } = useModel("loadingModel");
+  const { httpGet } = useModel("httpModel");
 
-    const { httpGet } = useModel("httpModel");
+  function getList() {
+    return httpGet("/classification/my").then(res => {
+      return Promise.resolve({
+        content: res,
+        last: true,
+      });
+    });
+  }
 
-    function getList() {
-        return httpGet("/classification/my").then(res => {
-            return Promise.resolve({
-                content: res,
-                last: true,
-            });
-        });
-    }
+  const renderItem = ({ item, index }) => (
+    <ListItem
+      title={item.name}
+      key={index}
+      onPress={() => {
+        if (new ClassificationUtil(item).checkSystem()) {
+          navigation.navigate("SystemClassificationEdit", {
+            classifyId: item.id,
+            classifyTitle: item.name,
+          });
+        } else {
+          navigation.navigate("ClassificationEdit", {
+            classifyId: item.id,
+            classifyTitle: item.name,
+          });
+        }
+      }}
+      accessoryRight={props => (
+        <View style={styles.right}>
+          {new ClassificationUtil(item).checkSystem() ? (
+            <Text category="c1" status="info">
+              {item.isOpen ? "已启动" : "未启动"}
+            </Text>
+          ) : (
+            <Text category="c1" status="info">
+              {new ListUtil(item.goodsIds).getLength()}件商品
+            </Text>
+          )}
+          <ForwardIcon {...props} />
+        </View>
+      )}
+    />
+  );
 
-    const renderItem = ({ item, index }) => (
-        <ListItem
-            title={item.name}
-            key={index}
+  return (
+    <>
+      <TipNavHeader title={ClassificationManage}>
+        <Text>{ClassificationManageText1}</Text>
+        <Text style={styles.text1}>{ClassificationManageText2}</Text>
+        <Text style={styles.text1}>{ClassificationManageText3}</Text>
+        <Text style={styles.text1}>{ClassificationManageText4}</Text>
+      </TipNavHeader>
+      <Layout style={styles.top}>
+        <Text category="h6">{ClassificationManageText5}</Text>
+      </Layout>
+      <ListComponent
+        getInfo={getList}
+        renderItem={renderItem}
+        separatorStyle={styles.separatorStyle}
+        showEmpty={true}
+        style={styles.list}
+        ListFooterComponent={() => (
+          <Button
+            style={styles.addGoods}
+            appearance="classification"
+            status="danger"
+            accessoryLeft={StarIcon}
             onPress={() => {
-                if (new ClassificationUtil(item).checkSystem()) {
-                    navigation.navigate("SystemClassificationEdit", {
-                        classifyId: item.id,
-                        classifyTitle: item.name,
-                    });
-                } else {
-                    navigation.navigate("ClassificationEdit", {
-                        classifyId: item.id,
-                        classifyTitle: item.name,
-                    });
-                }
+              navigation.navigate("AddNewClass");
             }}
-            accessoryRight={props => (
-                <View style={styles.right}>
-                    {new ClassificationUtil(item).checkSystem() ? (
-                        <Text category='c1' status='info'>
-                            {item.isOpen ? "已启动" : "未启动"}
-                        </Text>
-                    ) : (
-                        <Text category='c1' status='info'>
-                            {new ListUtil(item.goodsIds).getLength()}件商品
-                        </Text>
-                    )}
-                    <ForwardIcon {...props} />
-                </View>
-            )}
-        />
-    );
-
-    return (
-        <>
-            <TipNavHeader title={ClassificationManage}>
-                <Text>{ClassificationManageText1}</Text>
-                <Text style={styles.text1}>{ClassificationManageText2}</Text>
-                <Text style={styles.text1}>{ClassificationManageText3}</Text>
-                <Text style={styles.text1}>{ClassificationManageText4}</Text>
-            </TipNavHeader>
-            <Layout style={styles.top}>
-                <Text category='h6'>{ClassificationManageText5}</Text>
-            </Layout>
-            <ListComponent
-                getInfo={getList}
-                renderItem={renderItem}
-                separatorStyle={styles.separatorStyle}
-                showEmpty={true}
-                style={styles.list}
-                ListFooterComponent={() => (
-                    <Button
-                        style={styles.addGoods}
-                        appearance='classification'
-                        status='danger'
-                        accessoryLeft={StarIcon}
-                        onPress={() => {
-                            navigation.navigate("AddNewClass");
-                        }}
-                    />
-                )}
-            />
-        </>
-    );
+          />
+        )}
+      />
+    </>
+  );
 }
 
-const StarIcon = props => <Icon {...props} name='plus' />;
+const StarIcon = props => <Icon {...props} name="plus" />;
 const styles = StyleSheet.create({
-    text1: {
-        marginTop: 10,
-        marginLeft: 57,
-        maxWidth: 200,
-    },
-    list: {
-        backgroundColor: "#fff",
-    },
-    separatorStyle: {
-        height: 0,
-    },
-    right: {
-        flexDirection: "row",
-        alignItems: "center",
-    },
-    addGoods: {
-        width: 33,
-        margin: 15,
-    },
-    top: {
-        marginTop: 7,
-        paddingTop: 20,
-        paddingBottom: 10,
-        paddingHorizontal: 13,
-    },
+  text1: {
+    marginTop: 10,
+    marginLeft: 57,
+    maxWidth: 200,
+  },
+  list: {
+    backgroundColor: "#fff",
+  },
+  separatorStyle: {
+    height: 0,
+  },
+  right: {
+    flexDirection: "row",
+    alignItems: "center",
+  },
+  addGoods: {
+    width: 33,
+    margin: 15,
+  },
+  top: {
+    marginTop: 7,
+    paddingTop: 20,
+    paddingBottom: 10,
+    paddingHorizontal: 13,
+  },
 });

+ 82 - 96
screens/Set/FirstOrderScreen.js

@@ -1,83 +1,69 @@
-import * as WebBrowser from 'expo-web-browser';
-import * as React from 'react';
-import {
-  StyleSheet,
-} from 'react-native';
-import { useModel } from 'flooks';
-import {
-  Layout,
-  Text,
-  useTheme,
-  Button,
-  Input,
-} from '@ui-kitten/components';
-import { useFocusEffect } from '@react-navigation/native';
-import ScrollPage from '../../components/ScrollPage';
-import NavHeaderBar from '../../components/NavHeaderBar';
+import * as WebBrowser from "expo-web-browser";
+import * as React from "react";
+import { StyleSheet } from "react-native";
+import { useModel } from "flooks";
+import { Layout, Text, useTheme, Button, Input } from "@ui-kitten/components";
+import { useFocusEffect } from "@react-navigation/native";
+import ScrollPage from "../../components/ScrollPage";
+import NavHeaderBar from "../../components/NavHeaderBar";
 
-
-  const styles = StyleSheet.create({
-	lay: {
-	  backgroundColor: '#fff',
-	},
-	padBot: {
-	  paddingBottom: 100,
-	},
-	list: {
-	  paddingVertical: 10,
-	  paddingHorizontal: 15,
-	  backgroundColor: 'transparent',
-	  flex: 0,
-	},
-	item: {
-	  flexDirection: 'row',
-	  alignItems: 'center',
-	  paddingVertical: 10,
-	  paddingHorizontal: 15,
-	},
-	input: {
-	  marginHorizontal: 5,
-	  minWidth: 49,
-	},
-	text: {
-	  flex: 1,
-	},
-	flexRow: {
-	  flexDirection: 'row',
-	  alignItems: 'center',
-	},
-	buttonlast: {
-	  marginLeft: 10,
-	},
-	button: {
-	  alignSelf: 'flex-start',
-	},
-  });
-  
+const styles = StyleSheet.create({
+  lay: {
+    backgroundColor: "#fff",
+  },
+  padBot: {
+    paddingBottom: 100,
+  },
+  list: {
+    paddingVertical: 10,
+    paddingHorizontal: 15,
+    backgroundColor: "transparent",
+    flex: 0,
+  },
+  item: {
+    flexDirection: "row",
+    alignItems: "center",
+    paddingVertical: 10,
+    paddingHorizontal: 15,
+  },
+  input: {
+    marginHorizontal: 5,
+    minWidth: 49,
+  },
+  text: {
+    flex: 1,
+  },
+  flexRow: {
+    flexDirection: "row",
+    alignItems: "center",
+  },
+  buttonlast: {
+    marginLeft: 10,
+  },
+  button: {
+    alignSelf: "flex-start",
+  },
+});
 
 export default function FirstOrderScreen() {
   const theme = useTheme();
-  const { changeBackground } = useModel('barModel', true);
+  const { changeBackground } = useModel("barModel", true);
 
-  const {
-    delText,
-    editText,
-    cancel,
-  } = useModel('wordsModel');
-  const [money, changeMoney] = React.useState('');
+  const { delText, editText, cancel } = useModel("wordsModel");
+  const [money, changeMoney] = React.useState("");
   const [edit, changeEdit] = React.useState(false);
   useFocusEffect(
     React.useCallback(() => {
-      changeBackground(theme['color-primary-500']);
-    }, []),
+      changeBackground(theme["color-primary-500"]);
+    }, [])
   );
 
-  const {  firstOrder, updateMerchant } = useModel('userModel');
+  const { firstOrder, updateMerchant } = useModel("userModel");
   React.useEffect(() => {
     if (!firstOrder) {
       changeEdit(true);
     } else {
-      changeMoney(firstOrder.toString() || '');
+      changeMoney(firstOrder.toString() || "0");
     }
   }, [firstOrder]);
 
@@ -118,50 +104,51 @@ export default function FirstOrderScreen() {
                 >
                   {editText}
                 </Button>
-                <Button
-                  size="small"
-                  appearance="outline"
-                  style={styles.buttonlast}
-                  onPress={() => {
-                    changeEdit(false);
-                  }}
-                >
-                  {cancel}
-                </Button>
+                {firstOrder != null && (
+                  <Button
+                    size="small"
+                    status="danger"
+                    style={styles.buttonlast}
+                    onPress={() => {
+                      changeMoney("0");
+                      changeEdit(true);
+                      updateMerchant({
+                        firstOrder: 0,
+                      }).then(() => {
+                        // success("删除成功");
+                      });
+                    }}
+                  >
+                    {delText}
+                  </Button>
+                )}
               </>
             ) : (
               <>
                 <Button
                   size="small"
                   onPress={() => {
-                        changeEdit(false);
-                        updateMerchant({
-                          firstOrder: money,
-                        }).then(() => {
-                          // success("保存成功");
-                        });
-                      }}
+                    changeEdit(false);
+                    updateMerchant({
+                      firstOrder: money,
+                    }).then(() => {
+                      // success("保存成功");
+                    });
+                  }}
                 >
                   保存
                 </Button>
-                {money !== '' && (
                 <Button
                   size="small"
-                  status="danger"
+                  appearance="outline"
                   style={styles.buttonlast}
                   onPress={() => {
-                            changeMoney('');
-                            changeEdit(true);
-                            updateMerchant({
-                              firstOrder: 0,
-                            }).then(() => {
-                              // success("删除成功");
-                            });
-                          }}
+                    changeEdit(false);
+                    changeMoney(firstOrder.toString() || '0');
+                  }}
                 >
-                  {delText}
+                  {cancel}
                 </Button>
-                )}
               </>
             )}
           </Layout>
@@ -170,4 +157,3 @@ export default function FirstOrderScreen() {
     </>
   );
 }
-