|
@@ -0,0 +1,134 @@
|
|
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 moment from 'moment';
|
|
5
|
+import router from 'umi/router';
|
|
6
|
+import BuildSelect from '../../../../../components/SelectButton/BuildSelect'
|
|
7
|
+import XForm, { FieldTypes } from '../../../../../components/XForm';
|
|
8
|
+import Wangedit from '../../../../../components/Wangedit/Wangedit'
|
|
9
|
+import request from '../../../../../utils/request'
|
|
10
|
+import PosterBottom from '../../../../../assets/bottom.png'
|
|
11
|
+import yinhao from '../../../../../assets/yinhao.png'
|
|
12
|
+import ImageUploader from '../../../../../components/XForm/ImageUpload';
|
|
13
|
+import logo from '../../../../../assets/logo.png';
|
|
14
|
+import touxiang from '../../../../../assets/touxiang.jpg';
|
|
15
|
+import poster1 from '../../../../../assets/poster1.png';
|
|
16
|
+import poster2 from '../../../../../assets/poster2.png';
|
|
17
|
+
|
|
18
|
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
|
19
|
+const { TextArea } = Input;
|
|
20
|
+
|
|
21
|
+const Poster = props => {
|
|
22
|
+ const [inputValue, changeInput] = useState('')
|
|
23
|
+ const [textAreaValue, changeTextArea] = useState('')
|
|
24
|
+ const [imgValue, changeImg] = useState('')
|
|
25
|
+ const [posterId, setPosterId] = useState('')
|
|
26
|
+
|
|
27
|
+ const { buildingId } = props.building
|
|
28
|
+
|
|
29
|
+ if (buildingId) {
|
|
30
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
31
|
+ useEffect(() => {
|
|
32
|
+ request({
|
|
33
|
+ url: '/api/admin/poster',
|
|
34
|
+ method: 'GET',
|
|
35
|
+ params: { targetId: buildingId, targetType: 'building' },
|
|
36
|
+ }).then(data => {
|
|
37
|
+ console.log(data, '2222')
|
|
38
|
+ if (data.length > 0) {
|
|
39
|
+ setPosterId(data[0].posterId)
|
|
40
|
+ changeImg(data[0].posterImg)
|
|
41
|
+ changeTextArea(data[0].posterDescription)
|
|
42
|
+ changeInput(data[0].posterTitle)
|
|
43
|
+ }
|
|
44
|
+ }).catch(err => {
|
|
45
|
+ message.info(err.msg || err.message)
|
|
46
|
+ })
|
|
47
|
+ }, [])
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ const submitPoster = () => {
|
|
51
|
+ if (buildingId) {
|
|
52
|
+ if (posterId) {
|
|
53
|
+ request({
|
|
54
|
+ url: `/api/admin/poster/${posterId}`,
|
|
55
|
+ method: 'PUT',
|
|
56
|
+ data: { targetId: buildingId, targetType: 'building', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue },
|
|
57
|
+ }).then(() => {
|
|
58
|
+ message.info('保存成功')
|
|
59
|
+ }).catch(err => {
|
|
60
|
+ message.info(err.msg || err.message)
|
|
61
|
+ })
|
|
62
|
+ } else {
|
|
63
|
+ request({
|
|
64
|
+ url: '/api/admin/poster',
|
|
65
|
+ method: 'POST',
|
|
66
|
+ data: { targetId: buildingId, targetType: 'building', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue },
|
|
67
|
+ }).then(data => {
|
|
68
|
+ setPosterId(data.posterId)
|
|
69
|
+ message.info('保存成功')
|
|
70
|
+ }).catch(err => {
|
|
71
|
+ message.info(err.msg || err.message)
|
|
72
|
+ })
|
|
73
|
+ }
|
|
74
|
+ } else {
|
|
75
|
+ message.warn('请先保存基本信息数据')
|
|
76
|
+ }
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+ return <div>
|
|
80
|
+ <div style={{ display: 'flex' }}>
|
|
81
|
+ <div style={{ width: '420px', height: '900px', display: 'inline-block', marginTop: '30px' }}>
|
|
82
|
+ <div style={{ width: '375px', height: '785px', backgroundColor: '#fff', boxShadow: '0px 0px 16px 6px rgba(0,0,0,0.15)', position: 'relative', margin: '0 auto' }}>
|
|
83
|
+ <img style={{ width: '100%', height: '300px' }} src={imgValue || poster1} alt="" />
|
|
84
|
+ <div style={{ display: 'flex', alignItems: 'center', marginTop: '-24px' }}>
|
|
85
|
+ <img style={{ width: '70px', height: '70px', border: '4px solid #fff', borderRadius: '35px', marginLeft: '16px' }} src={touxiang} alt="" />
|
|
86
|
+ <span style={{ color: '#222', fontWeight: '600', margin: '24px 10px 0 14px', fontSize: '17px' }}>喵喵</span>
|
|
87
|
+ <span style={{ color: '#999', marginTop: '25px', fontSize: '17px' }}>邀您阅读</span>
|
|
88
|
+ <span style={{ color: '#999', margin: '25px 0 0 60px', fontSize: '17px' }}>2019.09.21</span>
|
|
89
|
+ </div>
|
|
90
|
+ <p style={{
|
|
91
|
+ margin: '10px 20px', fontSize: '20px', color: '#222', fontWeight: '600',
|
|
92
|
+ display: '-webkit-box', lineClamp: '3', height: '60px',
|
|
93
|
+ WebkitLineClamp: '2',
|
|
94
|
+ WebkitBoxOrient: 'vertical',
|
|
95
|
+ overflow: 'hidden',
|
|
96
|
+ textOverflow: 'ellipsis',
|
|
97
|
+ }}>{inputValue || '海报标题'}</p>
|
|
98
|
+
|
|
99
|
+ <img src={yinhao} style={{ width: '30px', marginLeft: '10px' }} alt="" />
|
|
100
|
+ <p style={{
|
|
101
|
+ margin: '16px 20px 28px 20px', fontSize: '17px', color: '#999',
|
|
102
|
+ display: '-webkit-box', lineClamp: '3', height: '76px',
|
|
103
|
+ WebkitLineClamp: '3',
|
|
104
|
+ WebkitBoxOrient: 'vertical',
|
|
105
|
+ overflow: 'hidden',
|
|
106
|
+ textOverflow: 'ellipsis',
|
|
107
|
+ }}>{textAreaValue || '海报描述'}</p>
|
|
108
|
+ <img src={PosterBottom} style={{ width: '100%' }} alt="" />
|
|
109
|
+ </div>
|
|
110
|
+ <p style={{ textAlign: 'center', fontSize: '19px', color: '#666', marginTop: '30px' }}>海报模板</p>
|
|
111
|
+ </div>
|
|
112
|
+
|
|
113
|
+ <div >
|
|
114
|
+ <div style={{ display: 'flex', width: '100%', margin: '60px 0' }}>
|
|
115
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报图片</p>
|
|
116
|
+ <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
|
|
117
|
+ </div>
|
|
118
|
+ <div style={{ display: 'flex', alignItems: 'center', width: '100%', marginBottom: '60px' }}>
|
|
119
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
|
|
120
|
+ <Input style={{ width: '20vw' }} value={inputValue} placeholder="请输入海报标题" onChange={e => changeInput(e.target.value)} />
|
|
121
|
+ </div>
|
|
122
|
+ <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
|
|
123
|
+ <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报描述</p>
|
|
124
|
+ <TextArea rows={5} value={textAreaValue} onChange={e => changeTextArea(e.target.value)} />
|
|
125
|
+ </div>
|
|
126
|
+
|
|
127
|
+ </div>
|
|
128
|
+ </div>
|
|
129
|
+ <Button type="primary" onClick={submitPoster} style={{ margin: '40px 40px 40px 30vw' }}> 确定</Button>
|
|
130
|
+ <Button onClick={() => router.go(-1)}>取消</Button>
|
|
131
|
+ </div>
|
|
132
|
+}
|
|
133
|
+
|
|
134
|
+export default Poster
|