Ver código fonte

Merge branch 'v3.5.1' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager into v3.5.1

张延森 5 anos atrás
pai
commit
e08f235006

+ 60
- 0
src/components/Cards/PosterCard.jsx Ver arquivo

@@ -0,0 +1,60 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Card, Checkbox } from 'antd';
3
+import apis from '../../services/apis';
4
+import request from '../../utils/request'
5
+
6
+const { Meta } = Card;
7
+
8
+/**
9
+ *
10
+ *
11
+ * @param {*} props
12
+ * @returns
13
+ */
14
+const PosterCard = (props) => {
15
+  const [ data, setData ] = useState([])
16
+//   const [ checkedData, setCheckedData ] = useState([])
17
+
18
+  useEffect(() => {
19
+    getCardsList(props.postType);    
20
+  },[])
21
+
22
+
23
+  const getCardsList = (postType) => {
24
+    request({ ...apis.poster.posterTemplate, params: { type: postType }}).then((data) => {
25
+        setData(data)
26
+      }).catch((err) => {
27
+        message.info(err.msg || err.message)
28
+      })
29
+  }
30
+
31
+  const onChange = (template) => (e) => {
32
+    // debugger
33
+
34
+    if (e.target.checked) {
35
+        if (props.checkedList.indexOf(template.templateId) > -1) {
36
+            props.onChange(props.checkedList)
37
+        } else {
38
+            props.onChange(props.checkedList.concat(template.templateId))
39
+        }
40
+    } else {
41
+        props.onChange(props.checkedList.filter(x => x !== template.templateId))
42
+    }
43
+  }
44
+
45
+  return (
46
+      data.map(template => (
47
+        <Card
48
+            hoverable
49
+            style={{ width: 240 }}
50
+            cover={<img src={template.img} />}
51
+        >
52
+
53
+        <Checkbox checked={props.checkedList.indexOf(template.templateId) !== -1} onChange={onChange(template)}>生成海分享给朋友</Checkbox>
54
+
55
+        </Card>
56
+      ))
57
+  )
58
+}
59
+export default PosterCard
60
+

+ 18
- 50
src/pages/activity/editActivity.jsx Ver arquivo

@@ -16,6 +16,7 @@ import touxiang from '../../assets/touxiang.jpg';
16 16
 import poster1 from '../../assets/poster1.png';
17 17
 import poster2 from '../../assets/poster2.png';
18 18
 import xiaochengxu from '../../assets/xiaochengxu.png'
19
+import PosterCard from '../../components/Cards/PosterCard'
19 20
 
20 21
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
21 22
 const { TextArea } = Input;
@@ -223,13 +224,13 @@ const Edit = props => {
223 224
     if (dynamicId) {
224 225
       console.log(dynamicId, 'dynamicId')
225 226
       useEffect(() => {
226
-        request({ ...apis.activity.poster, params: { targetId: dynamicId, targetType: 'activity' } }).then((data) => {
227
+        request({ ...apis.activity.usedPoster, params: { targetId: dynamicId, targetType: 'activity' } }).then((data) => {
227 228
           console.log(data, "2222")
228
-          if (data.length > 0) {
229
-            setPosterId(data[0].posterId)
230
-            changeImg(data[0].posterImg)
231
-            changeTextArea(data[0].posterDescription)
232
-            changeInput(data[0].posterTitle)
229
+          if (data) {
230
+            setPosterId(data.posterId)
231
+            changeImg(data.posterImg)
232
+            changeTextArea(data.posterDescription)
233
+            changeInput(data.posterTitle)
233 234
           }
234 235
         }).catch((err) => {
235 236
           message.info(err.msg || err.message)
@@ -248,16 +249,24 @@ const Edit = props => {
248 249
       })
249 250
     }
250 251
 
252
+    //获取选中的模板
253
+    const [ checkList, setCheckList ] = useState([])
254
+
255
+    const cardChange = (e) => {
256
+      console.log(e,"123")
257
+      setCheckList(e)
258
+    }
259
+
251 260
     const submitPoster = () => {
252 261
       if (dynamicId) {
253 262
         if (posterId) {
254
-          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) => {
255 264
             message.info("保存成功")
256 265
           }).catch((err) => {
257 266
             message.info(err.msg || err.message)
258 267
           })
259 268
         } else {
260
-          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) => {
261 270
             setPosterId(data.posterId)
262 271
             message.info("保存成功")
263 272
           }).catch((err) => {
@@ -272,48 +281,7 @@ const Edit = props => {
272 281
     return <div>
273 282
       <div style={{ display: 'flex' }}>
274 283
         <div style={{ width: '420px', height: '900px', display: 'inline-block', marginTop: '30px' }}>
275
-          <div style={{ width: '375px', height: '700px', backgroundColor: '#fff', boxShadow: '0px 0px 16px 6px rgba(0,0,0,0.15)', position: 'relative', margin: '0 auto' }}>
276
-            <img style={{ width: '100%', height: '300px' }} src={imgValue ? imgValue : poster1} alt="" />
277
-            <div style={{ display: 'flex', alignItems: 'center', marginTop: '-24px' }}>
278
-              <img style={{ width: '70px', height: '70px', border: '4px solid #fff', borderRadius: '35px', marginLeft: '16px' }} src={touxiang} alt="" />
279
-              <span style={{ color: '#222', fontWeight: '600', margin: '24px 10px 0 14px', fontSize: '17px' }}>喵喵</span>
280
-              <span style={{ color: '#999', marginTop: '25px', fontSize: '17px' }}>邀您参与</span>
281
-              <span style={{ color: '#999', margin: '25px 0 0 60px', fontSize: '17px' }}>2019.09.21</span>
282
-            </div>
283
-            <p style={{
284
-              margin: '10px 20px',
285
-              fontSize: '20px',
286
-              color: '#222',
287
-              fontWeight: '600',
288
-              display: '-webkit-box',
289
-              lineClamp: '3',
290
-              height: '60px',
291
-              WebkitLineClamp: '2',
292
-              WebkitBoxOrient: 'vertical',
293
-              overflow: 'hidden',
294
-              textOverflow: 'ellipsis'
295
-            }}>{inputValue ? inputValue : '海报标题'}</p>
296
-
297
-            <img src={yinhao} style={{ width: '30px', marginLeft: '20px' }} alt="" />
298
-            <p style={{
299
-              margin: '16px 20px 28px 20px',
300
-              fontSize: '17px',
301
-              color: '#999',
302
-              display: '-webkit-box',
303
-              lineClamp: '3',
304
-              height: '72px',
305
-              WebkitLineClamp: '3',
306
-              WebkitBoxOrient: 'vertical',
307
-              overflow: 'hidden',
308
-              textOverflow: 'ellipsis'
309
-            }}>{textAreaValue ? textAreaValue : '海报描述'}</p>
310
-            <div style={{ backgroundColor: '#f1f1f1', padding: '22px 30px', boxShadow: '0px 6px 12px -4px #dcdcdc', position: 'relative' }}>
311
-              <p style={{ margin: '0', fontSize: '18px', color: '#888' }}>长按识别小程序码</p>
312
-              <p style={{ margin: '0', fontSize: '18px', color: '#888' }}>进入<span style={{ margin: '0 5px', fontSize: '18px', color: '#333', fontWeight: '600' }}>{miniappName || '置业V顾问'}</span>报名活动</p>
313
-              <img style={{ width: '80px', position: 'absolute', right: '30px', top: '10px' }} src={xiaochengxu} alt="" />
314
-            </div>
315
-          </div>
316
-          <p style={{ textAlign: 'center', fontSize: '19px', color: '#666', marginTop: '30px' }}>海报模板</p>
284
+           <PosterCard postType="dynamic"  checkedList={checkList} onChange={cardChange} />
317 285
         </div>
318 286
 
319 287
         <div >

+ 12
- 0
src/services/apis.js Ver arquivo

@@ -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',
@@ -880,4 +885,11 @@ export default {
880 885
     action: 'admin.thirdPartyMiniapp.id.get',
881 886
   },
882 887
  },
888
+ poster: {
889
+  posterTemplate: {
890
+    url: `${prefix}/posterTemplate`,
891
+    method: 'GET',
892
+    action: 'admin.posterTemplate.get',
893
+  },
894
+ }
883 895
 }