傅行帆 5 年之前
父節點
當前提交
3f8fc36711
共有 3 個文件被更改,包括 76 次插入42 次删除
  1. 60
    0
      src/components/Cards/PosterCard.jsx
  2. 9
    42
      src/pages/activity/editActivity.jsx
  3. 7
    0
      src/services/apis.js

+ 60
- 0
src/components/Cards/PosterCard.jsx 查看文件

@@ -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
+

+ 9
- 42
src/pages/activity/editActivity.jsx 查看文件

@@ -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;
@@ -269,51 +270,17 @@ const Edit = props => {
269 270
       }
270 271
     }
271 272
 
273
+    const [ checkList, setCheckList ] = useState([2])
274
+
275
+    const cardChange = (e) => {
276
+      console.log(e,"123")
277
+      setCheckList(e)
278
+    }
279
+
272 280
     return <div>
273 281
       <div style={{ display: 'flex' }}>
274 282
         <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>
283
+           <PosterCard postType="dynamic"  checkedList={checkList} onChange={cardChange} />
317 284
         </div>
318 285
 
319 286
         <div >

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

@@ -869,4 +869,11 @@ export default {
869 869
     action: 'admin.thirdPartyMiniapp.id.get',
870 870
   },
871 871
  },
872
+ poster: {
873
+  posterTemplate: {
874
+    url: `${prefix}/posterTemplate`,
875
+    method: 'GET',
876
+    action: 'admin.posterTemplate.get',
877
+  },
878
+ }
872 879
 }