zlisen 4 년 전
부모
커밋
6c8087c074
2개의 변경된 파일66개의 추가작업 그리고 19개의 파일을 삭제
  1. 65
    18
      src/pages/batchimport/index.jsx
  2. 1
    1
      src/pages/batchimport/index.scss

+ 65
- 18
src/pages/batchimport/index.jsx 파일 보기

@@ -8,11 +8,12 @@ import { AtImagePicker } from "taro-ui";
8 8
 import request, { uploadFiles } from "../../util/request";
9 9
 import uploadicon from "../../assets/uploadicon.png";
10 10
 import IsLogin from "../../layout/IsLogin";
11
+import "taro-ui/dist/style/components/flex.scss";
11 12
 
12 13
 const batchimport = props => {
13 14
   const [pageState, setPageState] = useState("1");
14 15
   const [labelList, setLabelList] = useState([]);
15
-  const [imgUrl, setImgUrl] = useState({});
16
+  const [imgUrl, setImgUrl] = useState([]);
16 17
   const [tagList, setTagList] = useState([]);
17 18
 
18 19
   let [arrList, setArrList] = useState({});
@@ -31,8 +32,12 @@ const batchimport = props => {
31 32
   };
32 33
 
33 34
   const onSave = e => {
34
-    const data = labelList.map(x => {
35
-      return { tagId: x.tagId, imageId: imgUrl.imageId };
35
+    let data = [];
36
+
37
+    imgUrl.map(item => {
38
+      labelList.map(x => {
39
+        data.push({ tagId: x.tagId, imageId: item.imageId });
40
+      });
36 41
     });
37 42
 
38 43
     request({ url: "/taMetaImageTag", data: data, method: "post" }).then(
@@ -71,11 +76,12 @@ const batchimport = props => {
71 76
   const onUpImage = () => {
72 77
     Taro.chooseImage({
73 78
       sourceType: ["album"],
79
+      count: 9,
74 80
       success: res => {
75 81
         const tempFilePaths = res.tempFilePaths;
76
-        uploadFiles(tempFilePaths, "/api/mp/taMetaImage").then(res => {
77
-          console.log(res, "uploadFiles");
78
-          setImgUrl(res[0]);
82
+
83
+        uploadFiles(tempFilePaths, "/api/mp/taMetaImage").then(res1 => {
84
+          setImgUrl(res1);
79 85
         });
80 86
       }
81 87
     });
@@ -105,13 +111,52 @@ const batchimport = props => {
105 111
           </View>
106 112
 
107 113
           <Text>照片</Text>
108
-          <View style={{ padding: "30px" }}>
109
-            <Image
110
-              className="guide-view-img"
111
-              style={{ width: imgUrl.image ? "100%" : "10%", height: "100%" }}
112
-              onClick={() => onUpImage()}
113
-              src={imgUrl.image || uploadicon}
114
-            ></Image>
114
+          <View>
115
+            {imgUrl.length === 0 && (
116
+              <Image
117
+                className="guide-view-img"
118
+                style={{ width: "10%", height: "100%" }}
119
+                onClick={() => onUpImage()}
120
+                src={uploadicon}
121
+              ></Image>
122
+            )}
123
+            {imgUrl.length > 0 && (
124
+              <View className="at-row at-row--wrap">
125
+                {imgUrl.map(x => {
126
+                  return (
127
+                    <View
128
+                      className="at-col at-col-3"
129
+                      style={{ padding: "3px", height: "94px" }}
130
+                    >
131
+                      <Image
132
+                        className="guide-view-img"
133
+                        style={{
134
+                          width: "100%",
135
+                          height: "100%"
136
+                        }}
137
+                        mode="aspectFit"
138
+                        onClick={() => onUpImage()}
139
+                        src={x.image}
140
+                      ></Image>
141
+                    </View>
142
+                  );
143
+                })}
144
+                <View
145
+                  className="at-col at-col-3"
146
+                  style={{ padding: "30px", height: "94px" }}
147
+                >
148
+                  <Image
149
+                    className="guide-view-img"
150
+                    style={{
151
+                      width: "100%",
152
+                      height: "100%"
153
+                    }}
154
+                    onClick={() => onUpImage()}
155
+                    src={uploadicon}
156
+                  ></Image>
157
+                </View>
158
+              </View>
159
+            )}
115 160
           </View>
116 161
 
117 162
           {/* <Tab value={['取消','']}  onClick={() => { Taro.navigateTo({ url: `/pages/label/edit/index` }) }} ></Tab> */}
@@ -138,9 +183,7 @@ const batchimport = props => {
138 183
                     list={item.taMateTagList}
139 184
                     onChange={e => onLabelChange(e, index)}
140 185
                     style={{ marginTop: "90rpx" }}
141
-                  >
142
-                    {" "}
143
-                  </Tags>
186
+                  ></Tags>
144 187
                 </View>
145 188
               );
146 189
             })}
@@ -151,9 +194,13 @@ const batchimport = props => {
151 194
             value={["取消", "选择"]}
152 195
             onClick={[
153 196
               e => {
154
-                setPageState("2");
197
+                Taro.navigateBack({
198
+                  delta: 1
199
+                });
155 200
               },
156
-              e => setPageState("2")
201
+              e => {
202
+                if (labelList.length > 0) setPageState("2");
203
+              }
157 204
             ]}
158 205
           ></Tab>
159 206
         </View>

+ 1
- 1
src/pages/batchimport/index.scss 파일 보기

@@ -1,6 +1,6 @@
1 1
 // @import "~taro-ui/dist/style/components/image-picker.scss";
2 2
 // @import "~taro-ui/dist/style/components/icon.scss";
3
-
3
+@import "~taro-ui/dist/style/components/flex.scss";
4 4
 .batchimport {
5 5
   padding-top: 30rpx;
6 6