|
@@ -0,0 +1,350 @@
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload } from 'antd';
|
|
3
|
+import { FormattedMessage } from 'umi-plugin-react/locale';
|
|
4
|
+import styles from '../../style/GoodsList.less';
|
|
5
|
+import apis from '../../../services/apis';
|
|
6
|
+import moment from 'moment';
|
|
7
|
+import router from 'umi/router';
|
|
8
|
+import BuildSelect from '../../../components/SelectButton/BuildSelect'
|
|
9
|
+import XForm, { FieldTypes } from '../../../components/XForm';
|
|
10
|
+import Wangedit from '../../../components/Wangedit/Wangedit'
|
|
11
|
+import request from '../../../utils/request'
|
|
12
|
+import yinhao from '../../../assets/yinhao.png'
|
|
13
|
+import ImageUploader from '../../../components/XForm/ImageUpload';
|
|
14
|
+import logo from '../../../assets/logo.png';
|
|
15
|
+import touxiang from '../../../assets/touxiang.jpg';
|
|
16
|
+import poster1 from '../../../assets/poster1.png';
|
|
17
|
+import poster2 from '../../../assets/poster2.png';
|
|
18
|
+import xiaochengxu from '../../../assets/xiaochengxu.png'
|
|
19
|
+
|
|
20
|
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
|
21
|
+const { TextArea } = Input;
|
|
22
|
+
|
|
23
|
+/**
|
|
24
|
+ *
|
|
25
|
+ *
|
|
26
|
+ * @param {*} props
|
|
27
|
+ * @returns
|
|
28
|
+ */
|
|
29
|
+const Edit = props => {
|
|
30
|
+ const [tab, changeTab] = useState('basic')
|
|
31
|
+ // 判断是否展示助力次数的输入框
|
|
32
|
+ // const [help, helpTab] = useState('1')
|
|
33
|
+ const { groupActivityId } = props.location.query
|
|
34
|
+ const [dynamicData, setDynamicData] = useState({ isEnlist: 1 })
|
|
35
|
+ if (groupActivityId) {
|
|
36
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
37
|
+ useEffect(() => {
|
|
38
|
+ // eslint-disable-next-line no-use-before-define
|
|
39
|
+ getDynamicData(groupActivityId);
|
|
40
|
+ }, [])
|
|
41
|
+
|
|
42
|
+ // 详情
|
|
43
|
+ const getDynamicData = (groupActivityId) => {
|
|
44
|
+ request({ ...apis.groupActivity.details, urlData: { id: groupActivityId } }).then((data) => {
|
|
45
|
+ console.log(data)
|
|
46
|
+ setDynamicData(data)
|
|
47
|
+ })
|
|
48
|
+ }
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ const cancelPage = () => {
|
|
52
|
+ router.push({
|
|
53
|
+ pathname: '/activity/groupActivity/list',
|
|
54
|
+ });
|
|
55
|
+ }
|
|
56
|
+ const radioOnChange = e => {
|
|
57
|
+ console.log(e.target.value)
|
|
58
|
+ setDynamicData({ ...dynamicData, isEnlist: e.target.value })
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ const Basic = props => {
|
|
62
|
+ const fields = [
|
|
63
|
+ {
|
|
64
|
+ label: '选择项目',
|
|
65
|
+ name: 'buildingId',
|
|
66
|
+ render: <BuildSelect />,
|
|
67
|
+ value: dynamicData.buildingId,
|
|
68
|
+ rules: [
|
|
69
|
+ { required: true, message: '请选择项目' },
|
|
70
|
+ ],
|
|
71
|
+ },
|
|
72
|
+ {
|
|
73
|
+ label: '活动标题',
|
|
74
|
+ name: 'activityName',
|
|
75
|
+ type: FieldTypes.Text,
|
|
76
|
+ value: dynamicData.activityName,
|
|
77
|
+ rules: [
|
|
78
|
+ { required: true, message: '请输入活动标题' },
|
|
79
|
+ ]
|
|
80
|
+ },
|
|
81
|
+ {
|
|
82
|
+ label: '活动主图',
|
|
83
|
+ name: 'mainImg',
|
|
84
|
+ type: FieldTypes.ImageUploader,
|
|
85
|
+ value: dynamicData.mainImg,
|
|
86
|
+ help: '建议图片尺寸:750px*560px',
|
|
87
|
+ },
|
|
88
|
+ {
|
|
89
|
+ label: '活动时间',
|
|
90
|
+ name: 'activityTime',
|
|
91
|
+ type: FieldTypes.RangePicker,
|
|
92
|
+ value: dynamicData.startTime != null ? [moment(dynamicData.startTime, 'YYYY-MM-DD HH:mm'), moment(dynamicData.endTime, 'YYYY-MM-DD HH:mm')] : null,
|
|
93
|
+ props: { showTime: { format: 'HH:mm' } },
|
|
94
|
+ rules: [
|
|
95
|
+ { required: true, message: '请选择活动时间' },
|
|
96
|
+ ],
|
|
97
|
+ },
|
|
98
|
+ {
|
|
99
|
+ label: '成团人数',
|
|
100
|
+ name: 'groupBuyPeople',
|
|
101
|
+ type: FieldTypes.Text,
|
|
102
|
+ value: dynamicData.groupBuyPeople,
|
|
103
|
+ rules: [
|
|
104
|
+ { required: true, message: '请输入成团人数' },
|
|
105
|
+ ]
|
|
106
|
+ },
|
|
107
|
+ {
|
|
108
|
+ label: '所需积分',
|
|
109
|
+ name: 'integral',
|
|
110
|
+ type: FieldTypes.Text,
|
|
111
|
+ value: dynamicData.integral,
|
|
112
|
+ rules: [
|
|
113
|
+ { required: true, message: '请输入所需积分' },
|
|
114
|
+ ]
|
|
115
|
+ },
|
|
116
|
+ {
|
|
117
|
+ label: '活动说明',
|
|
118
|
+ name: 'descImg',
|
|
119
|
+ type: FieldTypes.ImageUploader,
|
|
120
|
+ value: dynamicData.descImg,
|
|
121
|
+ help: '建议图片尺寸:750px*560px',
|
|
122
|
+ },
|
|
123
|
+ ]
|
|
124
|
+
|
|
125
|
+ const handleSubmit = val => {
|
|
126
|
+ const { activityTime, signupTime, ...submitValue } = val
|
|
127
|
+ console.log('val', val)
|
|
128
|
+ const [startTime, endTime] = activityTime
|
|
129
|
+ submitValue.startTime = moment(startTime).format('YYYY-MM-DD HH:mm');
|
|
130
|
+ submitValue.endTime = moment(endTime).format('YYYY-MM-DD HH:mm');
|
|
131
|
+ console.log('submit data --->', submitValue)
|
|
132
|
+ if (groupActivityId) {
|
|
133
|
+ submitValue.groupActicityId = groupActivityId
|
|
134
|
+ request({ ...apis.groupActivity.update, data: submitValue }).then((data) => {
|
|
135
|
+ message.info("保存成功")
|
|
136
|
+ cancelPage()
|
|
137
|
+ }).catch((err) => {
|
|
138
|
+ message.info(err.msg || err.message)
|
|
139
|
+ })
|
|
140
|
+ } else {
|
|
141
|
+ request({ ...apis.groupActivity.add, data: submitValue }).then((data) => {
|
|
142
|
+ message.info("保存成功")
|
|
143
|
+ cancelPage()
|
|
144
|
+ }).catch((err) => {
|
|
145
|
+ message.info(err.msg || err.message)
|
|
146
|
+ })
|
|
147
|
+ }
|
|
148
|
+ }
|
|
149
|
+
|
|
150
|
+ return <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
|
|
151
|
+ }
|
|
152
|
+
|
|
153
|
+ const Poster = (props) => {
|
|
154
|
+ const [inputValue, changeInput] = useState('')
|
|
155
|
+ const [textAreaValue, changeTextArea] = useState('')
|
|
156
|
+ const [imgValue, changeImg] = useState('')
|
|
157
|
+ const [posterId, setPosterId] = useState('')
|
|
158
|
+
|
|
159
|
+ if (groupActivityId) {
|
|
160
|
+ console.log(groupActivityId, 'groupActivityId')
|
|
161
|
+ useEffect(() => {
|
|
162
|
+ request({ ...apis.activity.poster, params: { targetId: groupActivityId, targetType: 'activity' } }).then((data) => {
|
|
163
|
+ console.log(data, "2222")
|
|
164
|
+ if (data.length > 0) {
|
|
165
|
+ setPosterId(data[0].posterId)
|
|
166
|
+ changeImg(data[0].posterImg)
|
|
167
|
+ changeTextArea(data[0].posterDescription)
|
|
168
|
+ changeInput(data[0].posterTitle)
|
|
169
|
+ }
|
|
170
|
+ }).catch((err) => {
|
|
171
|
+ message.info(err.msg || err.message)
|
|
172
|
+ })
|
|
173
|
+ getMiniappName()
|
|
174
|
+ }, [])
|
|
175
|
+ }else{
|
|
176
|
+ getMiniappName()
|
|
177
|
+ }
|
|
178
|
+ // 获取小程序名称
|
|
179
|
+ const [miniappName, setMiniappName] = useState('')
|
|
180
|
+ function getMiniappName() {
|
|
181
|
+ request({ ...apis.building.getMiniappName }).then(res => {
|
|
182
|
+ console.log(res, "0000000000000")
|
|
183
|
+ setMiniappName(res)
|
|
184
|
+ })
|
|
185
|
+ }
|
|
186
|
+
|
|
187
|
+ const submitPoster = () => {
|
|
188
|
+ if (groupActivityId) {
|
|
189
|
+ if (posterId) {
|
|
190
|
+ request({ ...apis.activity.updatePoster, urlData: { id: posterId }, data: { targetId: groupActivityId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
|
|
191
|
+ message.info("保存成功")
|
|
192
|
+ }).catch((err) => {
|
|
193
|
+ message.info(err.msg || err.message)
|
|
194
|
+ })
|
|
195
|
+ } else {
|
|
196
|
+ request({ ...apis.activity.addPoster, data: { targetId: groupActivityId, targetType: 'activity', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue }, }).then((data) => {
|
|
197
|
+ setPosterId(data.posterId)
|
|
198
|
+ message.info("保存成功")
|
|
199
|
+ }).catch((err) => {
|
|
200
|
+ message.info(err.msg || err.message)
|
|
201
|
+ })
|
|
202
|
+ }
|
|
203
|
+ } else {
|
|
204
|
+ message.warn("请先保存基本信息数据")
|
|
205
|
+ }
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ return <div>
|
|
209
|
+ <div style={{ display: 'flex' }}>
|
|
210
|
+ <div style={{ width: '420px', height: '900px', display: 'inline-block', marginTop: '30px' }}>
|
|
211
|
+ <div style={{ width: '375px', height: '700px', backgroundColor: '#fff', boxShadow: '0px 0px 16px 6px rgba(0,0,0,0.15)', position: 'relative', margin: '0 auto' }}>
|
|
212
|
+ <img style={{ width: '100%', height: '300px' }} src={imgValue ? imgValue : poster1} alt="" />
|
|
213
|
+ <div style={{ display: 'flex', alignItems: 'center', marginTop: '-24px' }}>
|
|
214
|
+ <img style={{ width: '70px', height: '70px', border: '4px solid #fff', borderRadius: '35px', marginLeft: '16px' }} src={touxiang} alt="" />
|
|
215
|
+ <span style={{ color: '#222', fontWeight: '600', margin: '24px 10px 0 14px', fontSize: '17px' }}>喵喵</span>
|
|
216
|
+ <span style={{ color: '#999', marginTop: '25px', fontSize: '17px' }}>邀您阅读</span>
|
|
217
|
+ <span style={{ color: '#999', margin: '25px 0 0 60px', fontSize: '17px' }}>2019.09.21</span>
|
|
218
|
+ </div>
|
|
219
|
+ <p style={{
|
|
220
|
+ margin: '10px 20px', fontSize: '20px', color: '#222', fontWeight: '600',
|
|
221
|
+ display: '-webkit-box', lineClamp: '3', height: '60px',
|
|
222
|
+ WebkitLineClamp: '2',
|
|
223
|
+ WebkitBoxOrient: 'vertical',
|
|
224
|
+ overflow: 'hidden',
|
|
225
|
+ textOverflow: 'ellipsis'
|
|
226
|
+ }}>{inputValue ? inputValue : '海报标题'}</p>
|
|
227
|
+
|
|
228
|
+ <img src={yinhao} style={{ width: '30px', marginLeft: '20px' }} alt="" />
|
|
229
|
+ <p style={{
|
|
230
|
+ margin: '16px 20px 28px 20px', fontSize: '17px', color: '#999',
|
|
231
|
+ display: '-webkit-box', lineClamp: '3', height: '72px',
|
|
232
|
+ WebkitLineClamp: '3',
|
|
233
|
+ WebkitBoxOrient: 'vertical',
|
|
234
|
+ overflow: 'hidden',
|
|
235
|
+ textOverflow: 'ellipsis'
|
|
236
|
+ }}>{textAreaValue ? textAreaValue : '海报描述'}</p>
|
|
237
|
+ <div style={{ backgroundColor: '#f1f1f1', padding: '22px 30px', boxShadow: '0px 6px 12px -4px #dcdcdc', position: 'relative' }}>
|
|
238
|
+ <p style={{ margin: '0', fontSize: '18px', color: '#888' }}>长按识别小程序码</p>
|
|
239
|
+ <p style={{ margin: '0', fontSize: '18px', color: '#888' }}>进入<span style={{ margin: '0 5px', fontSize: '18px', color: '#333', fontWeight: '600' }}>{miniappName || '置业V顾问'}</span>报名活动</p>
|
|
240
|
+ <img style={{ width: '80px', position: 'absolute', right: '30px', top: '10px' }} src={xiaochengxu} alt="" />
|
|
241
|
+ </div>
|
|
242
|
+ </div>
|
|
243
|
+ <p style={{ textAlign: 'center', fontSize: '19px', color: '#666', marginTop: '30px' }}>海报模板</p>
|
|
244
|
+ </div>
|
|
245
|
+
|
|
246
|
+ <div >
|
|
247
|
+ <div style={{ display: 'flex', width: '100%', margin: '60px 0' }}>
|
|
248
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报图片1</p>
|
|
249
|
+ <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
|
|
250
|
+ </div>
|
|
251
|
+ <div style={{ display: 'flex', alignItems: 'center', width: '100%', marginBottom: '60px' }}>
|
|
252
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题1</p>
|
|
253
|
+ <Input style={{ width: '20vw' }} value={inputValue} placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
|
|
254
|
+ </div>
|
|
255
|
+ <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
|
|
256
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报描述1</p>
|
|
257
|
+ <TextArea rows={5} value={textAreaValue} onChange={e => changeTextArea(e.target.value)} />
|
|
258
|
+ </div>
|
|
259
|
+
|
|
260
|
+ </div>
|
|
261
|
+ </div>
|
|
262
|
+ <Button type="primary" onClick={submitPoster} style={{ margin: '40px 40px 40px 30vw' }}> 确定</Button>
|
|
263
|
+ <Button onClick={() => router.go(-1)}>取消</Button>
|
|
264
|
+ </div>
|
|
265
|
+
|
|
266
|
+ }
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+ const Share = (props) => {
|
|
271
|
+ const [inputValue, changeInput] = useState('')
|
|
272
|
+ const [imgValue, changeImg] = useState('')
|
|
273
|
+ const [shareContentId, setShareContentId] = useState('')
|
|
274
|
+
|
|
275
|
+ if (groupActivityId) {
|
|
276
|
+ useEffect(() => {
|
|
277
|
+ request({ ...apis.activity.shareContent, params: { targetId: groupActivityId, targetType: 'activity' }, }).then((data) => {
|
|
278
|
+ console.log(data, "2222")
|
|
279
|
+ if (data.length > 0) {
|
|
280
|
+ setShareContentId(data[0].shareContentId)
|
|
281
|
+ changeImg(data[0].shareContentImg)
|
|
282
|
+ changeInput(data[0].shareContentTitle)
|
|
283
|
+ }
|
|
284
|
+ }).catch((err) => {
|
|
285
|
+ message.info(err.msg || err.message)
|
|
286
|
+ })
|
|
287
|
+ }, [])
|
|
288
|
+ }
|
|
289
|
+
|
|
290
|
+ const submitShare = () => {
|
|
291
|
+ if (groupActivityId) {
|
|
292
|
+ if (shareContentId) {
|
|
293
|
+ request({ ...apis.activity.updateShareContent, urlData: { id: shareContentId }, data: { targetId: groupActivityId, shareContentType: 'activity', shareContentImg: imgValue, shareContentTitle: inputValue }, }).then((data) => {
|
|
294
|
+ message.info("保存成功")
|
|
295
|
+ }).catch((err) => {
|
|
296
|
+ message.info(err.msg || err.message)
|
|
297
|
+ })
|
|
298
|
+ } else {
|
|
299
|
+ request({ ...apis.activity.addShareContent, data: { targetId: groupActivityId, shareContentType: 'activity', shareContentImg: imgValue, shareContentTitle: inputValue }, }).then((data) => {
|
|
300
|
+ setShareContentId(data.shareContentId)
|
|
301
|
+ message.info("保存成功")
|
|
302
|
+ }).catch((err) => {
|
|
303
|
+ message.info(err.msg || err.message)
|
|
304
|
+ })
|
|
305
|
+ }
|
|
306
|
+ } else {
|
|
307
|
+ message.warn("请先保存基本信息数据")
|
|
308
|
+ }
|
|
309
|
+ }
|
|
310
|
+
|
|
311
|
+ return <div style={{ padding: '20px' }}>
|
|
312
|
+ <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
|
|
313
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享模板1</p>
|
|
314
|
+ <div>
|
|
315
|
+ <p style={{ display: 'flex', alignItems: 'center', fontSize: '14px', color: '#999', margin: '0', lineHeight: '0' }}><img src={logo} style={{ width: '22px', marginRight: '10px' }} />知与行互动</p>
|
|
316
|
+ <p style={{ fontSize: '16px', color: '#222', fontWeight: '600', margin: '0' }}>{inputValue ? inputValue : '置业V客厅 精准获客平台'}</p>
|
|
317
|
+ <img style={{ width: '200px', height: '140px' }} src={imgValue ? imgValue : poster2} alt="" />
|
|
318
|
+ </div>
|
|
319
|
+ </div>
|
|
320
|
+ <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
|
|
321
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享标题1</p>
|
|
322
|
+ <Input placeholder="请输入分享标题" value={inputValue} onChange={e => changeInput(e.target.value)} />
|
|
323
|
+ </div>
|
|
324
|
+ <div style={{ display: 'flex', width: '100%', marginTop: '40px' }}>
|
|
325
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享图片1</p>
|
|
326
|
+ <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
|
|
327
|
+ </div>
|
|
328
|
+ <Button type="primary" htmlType="submit" onClick={submitShare} style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
|
|
329
|
+ <Button onClick={() => router.go(-1)}>取消</Button>
|
|
330
|
+ </div>
|
|
331
|
+ }
|
|
332
|
+
|
|
333
|
+ return (
|
|
334
|
+ <div>
|
|
335
|
+ <div>
|
|
336
|
+ <Radio.Group value={tab} buttonStyle="solid" onChange={e => changeTab(e.target.value)}>
|
|
337
|
+ <Radio.Button value="basic">基本信息1</Radio.Button>
|
|
338
|
+ <Radio.Button value="poster">海报图片1</Radio.Button>
|
|
339
|
+ <Radio.Button value="share">分享设置1</Radio.Button>
|
|
340
|
+ </Radio.Group>
|
|
341
|
+ </div>
|
|
342
|
+ <div>
|
|
343
|
+ {tab === 'basic' && <Basic />}
|
|
344
|
+ {tab === 'poster' && <Poster />}
|
|
345
|
+ {tab === 'share' && <Share />}
|
|
346
|
+ </div>
|
|
347
|
+ </div>
|
|
348
|
+ );
|
|
349
|
+}
|
|
350
|
+export default Edit
|