傅行帆 5 年之前
父節點
當前提交
a077512559
共有 2 個檔案被更改,包括 21 行新增15 行删除
  1. 16
    15
      src/pages/activity/editActivity.jsx
  2. 5
    0
      src/services/apis.js

+ 16
- 15
src/pages/activity/editActivity.jsx 查看文件

@@ -224,13 +224,13 @@ const Edit = props => {
224 224
     if (dynamicId) {
225 225
       console.log(dynamicId, 'dynamicId')
226 226
       useEffect(() => {
227
-        request({ ...apis.activity.poster, params: { targetId: dynamicId, targetType: 'activity' } }).then((data) => {
227
+        request({ ...apis.activity.usedPoster, params: { targetId: dynamicId, targetType: 'activity' } }).then((data) => {
228 228
           console.log(data, "2222")
229
-          if (data.length > 0) {
230
-            setPosterId(data[0].posterId)
231
-            changeImg(data[0].posterImg)
232
-            changeTextArea(data[0].posterDescription)
233
-            changeInput(data[0].posterTitle)
229
+          if (data) {
230
+            setPosterId(data.posterId)
231
+            changeImg(data.posterImg)
232
+            changeTextArea(data.posterDescription)
233
+            changeInput(data.posterTitle)
234 234
           }
235 235
         }).catch((err) => {
236 236
           message.info(err.msg || err.message)
@@ -249,16 +249,24 @@ const Edit = props => {
249 249
       })
250 250
     }
251 251
 
252
+    //获取选中的模板
253
+    const [ checkList, setCheckList ] = useState([])
254
+
255
+    const cardChange = (e) => {
256
+      console.log(e,"123")
257
+      setCheckList(e)
258
+    }
259
+
252 260
     const submitPoster = () => {
253 261
       if (dynamicId) {
254 262
         if (posterId) {
255
-          request({ ...apis.activity.updatePoster, urlData: { id: posterId }, data: { targetId: dynamicId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
263
+          request({ ...apis.activity.updatePoster, urlData: { id: posterId }, data: { targetId: dynamicId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue, templateIds: checkList }, }).then((data) => {
256 264
             message.info("保存成功")
257 265
           }).catch((err) => {
258 266
             message.info(err.msg || err.message)
259 267
           })
260 268
         } else {
261
-          request({ ...apis.activity.addPoster, data: { targetId: dynamicId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
269
+          request({ ...apis.activity.addPoster, data: { targetId: dynamicId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue, templateIds: checkList }, }).then((data) => {
262 270
             setPosterId(data.posterId)
263 271
             message.info("保存成功")
264 272
           }).catch((err) => {
@@ -270,13 +278,6 @@ const Edit = props => {
270 278
       }
271 279
     }
272 280
 
273
-    const [ checkList, setCheckList ] = useState([2])
274
-
275
-    const cardChange = (e) => {
276
-      console.log(e,"123")
277
-      setCheckList(e)
278
-    }
279
-
280 281
     return <div>
281 282
       <div style={{ display: 'flex' }}>
282 283
         <div style={{ width: '420px', height: '900px', display: 'inline-block', marginTop: '30px' }}>

+ 5
- 0
src/services/apis.js 查看文件

@@ -406,6 +406,11 @@ export default {
406 406
         method: 'GET',
407 407
         action: 'admin.poster.get',
408 408
       },
409
+      usedPoster: {
410
+        url: `${prefix}/used/poster`,
411
+        method: 'GET',
412
+        action: 'admin.used.poster.get',
413
+      },
409 414
       updatePoster: {
410 415
         url: `${prefix}/poster/:id`,
411 416
         method: 'PUT',