Browse Source

Merge branch 'master' of http://git.ycjcjy.com/shigongli/client-s

张延森 4 years ago
parent
commit
7a4ffe5760
3 changed files with 72 additions and 36 deletions
  1. 1
    1
      config/dev.js
  2. 70
    34
      src/pages/imglist/index.jsx
  3. 1
    1
      src/util/request.js

+ 1
- 1
config/dev.js View File

@@ -24,7 +24,7 @@ module.exports = {
24 24
       proxy: {
25 25
         '/api': {
26 26
           // target: 'https://sgl.ycjcjy.com',
27
-          target: 'http://localhost:7080',
27
+          target: 'http://192.168.211.105:7080',
28 28
           changeOrigin: true
29 29
         }
30 30
       }

+ 70
- 34
src/pages/imglist/index.jsx View File

@@ -12,7 +12,6 @@ import groupby from "lodash.groupby";
12 12
 import NoData from "@/compents/NoData";
13 13
 import IsLogin from "../../layout/IsLogin";
14 14
 
15
-
16 15
 const index = props => {
17 16
   const { query } = getQueryValue();
18 17
 
@@ -20,7 +19,7 @@ const index = props => {
20 19
   const [labelState, setLabelState] = useState(false);
21 20
   const [list, setList] = useState({});
22 21
   const [labelList, setLabelList] = useState([]);
23
-  const [data, setData] = useState({});
22
+  const [data, setData] = useState([]);
24 23
   const [tagList, setTagList] = useState([]);
25 24
 
26 25
   let [arrList, setArrList] = useState({});
@@ -32,7 +31,7 @@ const index = props => {
32 31
   const getMateTagGroupList = () => {
33 32
     request({
34 33
       url: "/taMateTagGroup",
35
-      params: { pageSize: 1, pageSize: 9999 }
34
+      params: { pageSize: 9999 }
36 35
     }).then(res => {
37 36
       const { records, ...page } = res.data.data;
38 37
       setTagList(records);
@@ -40,14 +39,15 @@ const index = props => {
40 39
   };
41 40
 
42 41
   const getImageList = () => {
43
-    request({ url: "/taMetaImageTag", params: { tagIds: query } }).then(res => {
42
+    request({
43
+      url: "/taMetaImageTag",
44
+      params: { tagIds: query, pageSize: 9999 }
45
+    }).then(res => {
44 46
       const { records, ...page } = res.data.data;
45 47
       setList(groupby(records, item => item.imageId));
46 48
     });
47 49
   };
48 50
   const updateImage = () => {
49
-
50
-
51 51
     Taro.chooseImage({
52 52
       sourceType: ["album"],
53 53
       success: res => {
@@ -58,7 +58,7 @@ const index = props => {
58 58
             newImage: res[0].imageId,
59 59
             newTags: data.map(x => x.tagId)
60 60
           };
61
-          updatainfo(newInfo);
61
+          updatainfo(newInfo,'image');
62 62
         });
63 63
       }
64 64
     });
@@ -71,10 +71,10 @@ const index = props => {
71 71
       newImage: data[0].imageId,
72 72
       newTags: labelList.map(x => x.tagId)
73 73
     };
74
-    updatainfo(newInfo);
74
+    updatainfo(newInfo,'tag');
75 75
   };
76 76
 
77
-  const updatainfo = newInfo => {
77
+  const updatainfo = (newInfo,type) => {
78 78
     const oldinfo = {
79 79
       originImage: data[0].imageId,
80 80
       originTags: data.map(x => x.tagId)
@@ -84,8 +84,20 @@ const index = props => {
84 84
       data: { ...oldinfo, ...newInfo },
85 85
       method: "put"
86 86
     }).then(() => {
87
-      getImageList();
88
-      setLabelState(false);
87
+      Taro.showModal({
88
+        title: "修改成功",
89
+        content:type==='tag'? "修改标签请重新查询":'',
90
+        showCancel: false,
91
+        success: function(res) {
92
+          if (res.confirm) {
93
+            console.log("用户点击确定");
94
+            getImageList();
95
+            setLabelState(false);
96
+          } else if (res.cancel) {
97
+            console.log("用户点击取消");
98
+          }
99
+        }
100
+      });
89 101
     });
90 102
   };
91 103
 
@@ -94,7 +106,7 @@ const index = props => {
94 106
     setLabelState(true);
95 107
   };
96 108
   const handleClose = e => {
97
-    console.log(e, "111");
109
+    // console.log(e, "111");
98 110
 
99 111
     setIsOpened(false);
100 112
   };
@@ -109,6 +121,27 @@ const index = props => {
109 121
           console.log("用户点击确定");
110 122
 
111 123
           setIsOpened(false);
124
+          request({
125
+            url: `/taMetaImageTag`,
126
+            params: { ids: data.map(x => x.serialNo).join(",") },
127
+            method: "delete"
128
+          }).then(res => {
129
+            // const { records, ...page } = res.data.data;
130
+            // setList(groupby(records, item => item.imageId));
131
+            Taro.showModal({
132
+              title: "删除成功",
133
+              showCancel: false,
134
+              success: function(res) {
135
+                if (res.confirm) {
136
+                  console.log("用户点击确定");
137
+                  getImageList();
138
+                } else if (res.cancel) {
139
+                  console.log("用户点击取消");
140
+                }
141
+              }
142
+            });
143
+          });
144
+
112 145
           // Taro.showModal({
113 146
           //   title: `改标签组有${row.user.number}个标签仍在使用。请先清空标签,再删除标签组`,
114 147
           //   showCancel: false,
@@ -175,38 +208,41 @@ const index = props => {
175 208
           )}
176 209
 
177 210
           {labelState && (
178
-            <View style={{ textAlign: "center" }}>
179
-              <View style={{ padding: "0 20px" }}>
180
-                {tagList.map((item, index) => {
181
-                  return (
182
-                    <View className="imglist-tagcard" key={item.name}>
183
-                      <Text>{item.name}</Text>
184
-                      <Tags
185
-                        list={item.taMateTagList}
186
-                        onChange={e => onLabelChange(e, index)}
187
-                        style={{ marginTop: "90rpx" }}
188
-                      />
189
-                    </View>
190
-                  );
191
-                })}
211
+            <View>
212
+              <View style={{ textAlign: "center" }}>
213
+                <View style={{}}>
214
+                  {tagList.map((item, index) => {
215
+                    return (
216
+                      <View className="imglist-tagcard" key={item.name}>
217
+                        <Text>{item.name}</Text>
218
+                        <Tags
219
+                          list={item.taMateTagList}
220
+                          onChange={e => onLabelChange(e, index)}
221
+                          style={{ marginTop: "90rpx" }}
222
+                        />
223
+                      </View>
224
+                    );
225
+                  })}
226
+                </View>
192 227
               </View>
193
-              <Tab
194
-                pageState="3"
195
-                value={["取消", "选择"]}
196
-                onClick={[e => setLabelState(false), e => ontagsClick()]}
197
-              ></Tab>
198 228
             </View>
199 229
           )}
200 230
         </NoData>
201
-
231
+        {labelState && (
232
+          <Tab
233
+            pageState="3"
234
+            value={["取消", "选择"]}
235
+            onClick={[e => setLabelState(false), e => ontagsClick()]}
236
+          ></Tab>
237
+        )}
202 238
         <AtFloatLayout
203 239
           isOpened={isOpened}
204 240
           onClose={() => handleClose()}
205 241
           style={{ zIndex: "1000" }}
206 242
         >
207 243
           <View className="floatmodel">
208
-            <View onClick={() => updateLabel()}>更改标签</View>
209
-            <View onClick={() => updateImage()}>更换图片</View>
244
+            <View onClick={() => updateLabel('tag')}>更改标签</View>
245
+            <View onClick={() => updateImage('image')}>更换图片</View>
210 246
             <View onClick={() => deleteImage()}>删除</View>
211 247
             <View
212 248
               style={{ color: "#d2d2d2" }}

+ 1
- 1
src/util/request.js View File

@@ -31,7 +31,7 @@ export function optionBuilder(options) {
31 31
   // console.log(user,'user')
32 32
   let api = `/api/mp${url}`
33 33
 
34
-  if (method == 'get'&&JSON.stringify(params) != "{}") {
34
+  if (JSON.stringify(params) != "{}") {
35 35
     api = `${api}?${paramsToString(params)}`
36 36
   } 
37 37
   const token = Taro.getStorageSync('token')||''