Просмотр исходного кода

系统分类商品分类修改

panhui 5 лет назад
Родитель
Сommit
daa321b06c

+ 24 - 7
Utils/SystemRuleUtil.js

@@ -2,27 +2,44 @@
 
 //商品分类
 
-const systemMenus = ["好评热销", "点单必读", "折扣"];
+const systemMenus = [1, 2, 3]; //好评,折扣,点单必读
 const menuTips = {
-    好评热销: ["systemClassification1", "systemClassification2"],
-    点单必读: ["systemClassification3", "systemClassification4"],
-    折扣: ["systemClassification5", "systemClassification6"],
+    1: ["systemClassification1", "systemClassification2"],
+    2: ["systemClassification3", "systemClassification4"],
+    3: ["systemClassification5", "systemClassification6"],
 };
+
+//好评,折扣,点单必读
+export function getClassificationByName(name) {
+    if (name == "好评") {
+        return 1;
+    } else if (name == "折扣") {
+        return 2;
+    } else if (name == "点单必读") {
+        return 3;
+    }
+}
+
 export class ClassificationUtil {
     constructor(classification) {
-        let { name, id, goodsIds, isOpen } = classification || {};
+        let { name, id, goodsIds, isOpen, type } = classification || {};
         this.name = name || "";
         this.id = id || "";
         this.goodsIds = goodsIds || "";
         this.isOpen = isOpen || false;
         this.allInfo = classification || {};
+        this.type = type || "";
     }
 
     checkSystem() {
-        return systemMenus.indexOf(this.name) != -1;
+        return systemMenus.indexOf(this.type) != -1;
     }
 
     getMenuTipsList() {
-        return menuTips[this.name] || [];
+        return menuTips[this.type] || [];
+    }
+
+    getType() {
+        return this.type;
     }
 }

+ 4 - 0
components/GoodsCard.js

@@ -27,6 +27,10 @@ export default function GoodsCard(props) {
 
     const { takeOffInfo, ChangeTakeOff } = useModel("goodsModel", true);
 
+    
+
+
+
     return (
         <Card
             style={[!props.appearance && styles.card, props.style]}

+ 13 - 0
models/goodsModel.js

@@ -146,5 +146,18 @@ export default {
                 },
             });
         },
+
+        // 商品分类添加商品
+        addClassification(selectId, goodsId) {
+            let { httpGet } = model("httpModel");
+            return httpGet(
+                "/classification/saveGoods",
+                {
+                    classificationId: selectId,
+                    string: goodsId,
+                },
+                { body: "json" }
+            );
+        },
     }),
 };

+ 19 - 15
screens/AddGoodsClassification.js

@@ -87,19 +87,23 @@ export default function AddGoodsClassification({ navigation, route }) {
     function getSelectGoods() {
         httpGet("/classification/allGoods", {
             classificationId: selectId,
-        }).then((res) => {
-            setGoodsClass(res);
+        }).then(res => {
+            let list = res || [];
+            list = list.filter(item => {
+                return item != null;
+            });
+            setGoodsClass(list);
         });
     }
     function getAllGoods() {
-        httpGet("/goods/my").then((res) => {
+        httpGet("/goods/my").then(res => {
             changeGoods(res);
         });
     }
 
     const topGoods = React.useMemo(() => {
         if (pageType == "signboard") {
-            return goods.filter((item) => {
+            return goods.filter(item => {
                 return item.signboard;
             });
         } else {
@@ -109,14 +113,14 @@ export default function AddGoodsClassification({ navigation, route }) {
 
     const elseGoods = React.useMemo(() => {
         if (pageType === "signboard") {
-            return goods.filter((item) => {
+            return goods.filter(item => {
                 return !item.signboard;
             });
         } else {
-            let _topIds = topGoods.map((item) => {
+            let _topIds = topGoods.map(item => {
                 return item.id;
             });
-            return goods.filter((item) => {
+            return goods.filter(item => {
                 return _topIds.indexOf(item.id) === -1;
             });
         }
@@ -173,9 +177,9 @@ export default function AddGoodsClassification({ navigation, route }) {
                     signboard,
                 },
                 { body: "json" }
-            ).then((res) => {
+            ).then(res => {
                 success(tips + successText);
-                let _goods = goods.map((item) => {
+                let _goods = goods.map(item => {
                     if (item.id != id) {
                         return item;
                     } else {
@@ -190,7 +194,7 @@ export default function AddGoodsClassification({ navigation, route }) {
                 _goodsClass.push(info);
             } else {
                 _goodsClass.splice(
-                    _goodsClass.findIndex((item) => {
+                    _goodsClass.findIndex(item => {
                         return item.id == id;
                     }),
                     1
@@ -201,7 +205,7 @@ export default function AddGoodsClassification({ navigation, route }) {
             changeSelect(_goodsClass);
         } else {
             if (signboard) {
-                let ids = topGoods.map((item) => {
+                let ids = topGoods.map(item => {
                     return item.id;
                 });
                 ids.push(id);
@@ -212,7 +216,7 @@ export default function AddGoodsClassification({ navigation, route }) {
                         string: ids.join(","),
                     },
                     { body: "json" }
-                ).then((res) => {
+                ).then(res => {
                     success(tips + successText);
                     getSelectGoods();
                 });
@@ -224,7 +228,7 @@ export default function AddGoodsClassification({ navigation, route }) {
                         goodId: id,
                     },
                     { body: "json" }
-                ).then((res) => {
+                ).then(res => {
                     success(tips + successText);
                     getSelectGoods();
                 });
@@ -239,7 +243,7 @@ export default function AddGoodsClassification({ navigation, route }) {
                 <Layout style={styles.container}>
                     <Card
                         appearance='headerList'
-                        header={(props) => {
+                        header={props => {
                             return Header(props, goodsClassificationTitle2);
                         }}
                         disabled={true}
@@ -254,7 +258,7 @@ export default function AddGoodsClassification({ navigation, route }) {
 
                     <Card
                         appearance='headerList'
-                        header={(props) => {
+                        header={props => {
                             return Header(props, goodsClassificationTitle3);
                         }}
                         disabled={true}

+ 21 - 13
screens/Guide1Screen.js

@@ -35,6 +35,7 @@ export default function Guide1Screen({ navigation }) {
     const { httpGet, httpPost } = useModel("httpModel", true);
     const { success } = useModel("loadingModel", true);
     const { mid, changeGuideStep } = useModel("userModel", true);
+    const { addClassification } = useModel("goodsModel", true);
 
     const {
         guide1_title1,
@@ -165,7 +166,6 @@ export default function Guide1Screen({ navigation }) {
             week &&
             startTime &&
             endTime &&
-            introduction &&
             img
         ) {
             return true;
@@ -270,18 +270,16 @@ export default function Guide1Screen({ navigation }) {
                         />
 
                         <Layout>
-                            {loadingSuccess && (
-                                <Textarea
-                                    containerStyle={styles.textareaContainer}
-                                    style={styles.textarea}
-                                    onChangeText={changeIntroduction}
-                                    defaultValue={introduction}
-                                    maxLength={50}
-                                    placeholder={guide1_pla_5}
-                                    placeholderTextColor={"#B4B4B4"}
-                                    underlineColorAndroid={"transparent"}
-                                />
-                            )}
+                            <Textarea
+                                containerStyle={styles.textareaContainer}
+                                style={styles.textarea}
+                                onChangeText={changeIntroduction}
+                                defaultValue={introduction}
+                                maxLength={50}
+                                placeholder={guide1_pla_5}
+                                placeholderTextColor={"#B4B4B4"}
+                                underlineColorAndroid={"transparent"}
+                            />
                         </Layout>
 
                         <FormInput
@@ -314,6 +312,16 @@ export default function Guide1Screen({ navigation }) {
                                         { body: "json" },
                                         true
                                     ).then(res => {
+                                        if (!id) {
+                                            let { params } = route;
+                                            let { classifyId } = params || {};
+                                            if (classifyId) {
+                                                addClassification(
+                                                    classifyId,
+                                                    res.id
+                                                );
+                                            }
+                                        }
                                         success(
                                             (id ? "修改" : "添加") + "成功"
                                         );

+ 19 - 9
screens/HomeScreenPage1.js

@@ -25,7 +25,10 @@ import GoodsCardLarge from "../components/GoodsCard";
 import * as RootNavigation from "../navigation/RootNavigation.js";
 import ActionButton from "react-native-action-button";
 import EmptyComponent from "../components/EmptyComponent";
-import { ClassificationUtil } from "../Utils/SystemRuleUtil";
+import {
+    ClassificationUtil,
+    getClassificationByName,
+} from "../Utils/SystemRuleUtil";
 
 const width = Dimensions.get("window").width;
 const height = Dimensions.get("window").height;
@@ -73,7 +76,11 @@ export default function HomePage1(props) {
             httpGet("/classification/allGoods", {
                 classificationId: selectId,
             }).then(res => {
-                setGoodsClass(res);
+                setGoodsClass(
+                    res.filter(item => {
+                        return item != null;
+                    })
+                );
             });
         }
         if (selectId) {
@@ -249,8 +256,14 @@ export default function HomePage1(props) {
                                 status='danger'
                                 accessoryLeft={StarIcon}
                                 onPress={() => {
+                                    let _classificationUtil = new ClassificationUtil(
+                                        selectClassInfo
+                                    );
                                     if (
-                                        new ClassificationUtil(selectClassInfo).checkSystem()
+                                        _classificationUtil.getType() ==
+                                            getClassificationByName("好评") ||
+                                        _classificationUtil.getType() ==
+                                            getClassificationByName("折扣")
                                     ) {
                                         RootNavigation.navigate(
                                             "SystemClassificationEdit",
@@ -259,12 +272,9 @@ export default function HomePage1(props) {
                                             }
                                         );
                                     } else {
-                                        RootNavigation.navigate(
-                                            "ClassificationEdit",
-                                            {
-                                                classifyId: selectId,
-                                            }
-                                        );
+                                        RootNavigation.navigate("AddGoods", {
+                                            classifyId: selectId,
+                                        });
                                     }
                                 }}
                             />

+ 34 - 16
screens/Set/SystemClassificationEditScreen.js

@@ -14,7 +14,10 @@ import {
 } from "@ui-kitten/components";
 import { StyleSheet, View } from "react-native";
 import ListUtil from "../../Utils/ListUtil";
-import { ClassificationUtil } from "../../Utils/SystemRuleUtil";
+import {
+    ClassificationUtil,
+    getClassificationByName,
+} from "../../Utils/SystemRuleUtil";
 import { useRoute } from "@react-navigation/native";
 import GoodsCard from "../../components/GoodsCard";
 const ForwardIcon = props => (
@@ -86,8 +89,12 @@ export default function SystemClassificationEditScreen({ navigation }) {
                 });
             })
             .then(res => {
+                let list = res || [];
+                list = list.filter(item => {
+                    return item != null;
+                });
                 return Promise.resolve({
-                    content: res || [],
+                    content: list,
                     last: true,
                 });
             });
@@ -155,20 +162,31 @@ export default function SystemClassificationEditScreen({ navigation }) {
                 delId={delId}
                 style={styles.list}
                 extraData={{ id: id }}
-                ListFooterComponent={() => (
-                    <Button
-                        style={styles.addGoods}
-                        appearance='classification'
-                        status='danger'
-                        accessoryLeft={StarIcon}
-                        onPress={() => {
-                            navigation.navigate("AddClassification", {
-                                type: "classification",
-                                classificationId: id,
-                            });
-                        }}
-                    />
-                )}
+                ListFooterComponent={() => {
+                    if (
+                        classifyInfo.getType() !=
+                            getClassificationByName("好评") &&
+                        classifyInfo.getType() !=
+                            getClassificationByName("折扣")
+                    ) {
+                        return (
+                            <Button
+                                style={styles.addGoods}
+                                appearance='classification'
+                                status='danger'
+                                accessoryLeft={StarIcon}
+                                onPress={() => {
+                                    navigation.navigate("AddClassification", {
+                                        type: "classification",
+                                        classificationId: id,
+                                    });
+                                }}
+                            />
+                        );
+                    } else {
+                        return <></>;
+                    }
+                }}
             />
         </>
     );

+ 2 - 2
screens/UserScreen.js

@@ -103,13 +103,13 @@ export default function UserScreen({ navigation }) {
                                     navigation.navigate("FullReduction");
                                 }}
                             />
-                            <MenuItem
+                            {/* <MenuItem
                                 title={userTitle22}
                                 accessoryRight={ForwardIcon}
                                 onPress={() => {
                                     navigation.navigate("ClassificationManage");
                                 }}
-                            />
+                            /> */}
                             <MenuItem
                                 title={userTitle23}
                                 accessoryRight={ForwardIcon}