张延森 4 lat temu
rodzic
commit
c14fffd52f
1 zmienionych plików z 23 dodań i 8 usunięć
  1. 23
    8
      src/pages/batchimport/index.jsx

+ 23
- 8
src/pages/batchimport/index.jsx Wyświetl plik

1
-import React, { useState } from "react";
1
+import React, { useState, useRef } from "react";
2
 import Taro, { useDidShow } from "@tarojs/taro";
2
 import Taro, { useDidShow } from "@tarojs/taro";
3
 import "./index.scss";
3
 import "./index.scss";
4
 import { View, Text, Input, Image } from "@tarojs/components";
4
 import { View, Text, Input, Image } from "@tarojs/components";
5
 import Tab from "../../compents/tab/index";
5
 import Tab from "../../compents/tab/index";
6
 import Tags from "../../compents/tags/index";
6
 import Tags from "../../compents/tags/index";
7
-import { AtImagePicker } from "taro-ui";
8
 import request, { uploadFiles } from "../../util/request";
7
 import request, { uploadFiles } from "../../util/request";
9
 import uploadicon from "../../assets/uploadicon.png";
8
 import uploadicon from "../../assets/uploadicon.png";
10
 import IsLogin from "../../layout/IsLogin";
9
 import IsLogin from "../../layout/IsLogin";
80
       success: res => {
79
       success: res => {
81
         const tempFilePaths = res.tempFilePaths;
80
         const tempFilePaths = res.tempFilePaths;
82
 
81
 
82
+        Taro.showLoading({title: '请稍候...'})
83
+
83
         uploadFiles(tempFilePaths, "/api/mp/taMetaImage").then(res1 => {
84
         uploadFiles(tempFilePaths, "/api/mp/taMetaImage").then(res1 => {
84
-          setImgUrl(res1);
85
-        });
85
+          setImgUrl(imgUrl.concat(res1));
86
+          Taro.hideLoading()
87
+        }).catch(err => Taro.hideLoading());
86
       }
88
       }
87
     });
89
     });
88
   };
90
   };
89
 
91
 
92
+  const handleImageDelete = row => {
93
+    Taro.showModal({
94
+      content: '确认删除当前图片?',
95
+      success: res => {
96
+        if (res.confirm) {
97
+          setImgUrl(imgUrl.filter(x => x.imageId !== row.imageId))
98
+        }
99
+      }
100
+    })
101
+  }
102
+
90
   return (
103
   return (
91
     <IsLogin>
104
     <IsLogin>
92
       <View className="batchimport">
105
       <View className="batchimport">
97
               className="at-row  at-row--wrap at-row__justify--center"
110
               className="at-row  at-row--wrap at-row__justify--center"
98
               style={{ marginTop: "0.15rem" }}
111
               style={{ marginTop: "0.15rem" }}
99
             >
112
             >
100
-              {labelList.map((item, index) => {
113
+              {labelList.map(item => {
101
                 return (
114
                 return (
102
-                  <View className="at-col at-col-4" key={index}>
115
+                  <View className="at-col at-col-4" key={item.name}>
103
                     <View className="tags-btn">{item.name}</View>
116
                     <View className="tags-btn">{item.name}</View>
104
                   </View>
117
                   </View>
105
                 );
118
                 );
127
                     <View
140
                     <View
128
                       className="at-col at-col-3"
141
                       className="at-col at-col-3"
129
                       style={{ padding: "3px", height: "94px" }}
142
                       style={{ padding: "3px", height: "94px" }}
143
+                      key={x.imageId}
130
                     >
144
                     >
131
                       <Image
145
                       <Image
132
                         className="guide-view-img"
146
                         className="guide-view-img"
135
                           height: "100%"
149
                           height: "100%"
136
                         }}
150
                         }}
137
                         mode="aspectFit"
151
                         mode="aspectFit"
138
-                        onClick={() => onUpImage()}
152
+                        onClick={() => handleImageDelete(x)}
139
                         src={x.image}
153
                         src={x.image}
140
                       ></Image>
154
                       ></Image>
141
                     </View>
155
                     </View>
177
           <View style={{ padding: "0 20px" }}>
191
           <View style={{ padding: "0 20px" }}>
178
             {tagList.map((item, index) => {
192
             {tagList.map((item, index) => {
179
               return (
193
               return (
180
-                <View className="material-card">
194
+                <View className="material-card" key={item.name}>
181
                   <Text>{item.name}</Text>
195
                   <Text>{item.name}</Text>
182
                   <Tags
196
                   <Tags
183
                     list={item.taMateTagList}
197
                     list={item.taMateTagList}
200
               },
214
               },
201
               e => {
215
               e => {
202
                 if (labelList.length > 0) setPageState("2");
216
                 if (labelList.length > 0) setPageState("2");
217
+                setImgUrl([])
203
               }
218
               }
204
             ]}
219
             ]}
205
           ></Tab>
220
           ></Tab>