Kaynağa Gözat

项目海报图片,分享设置

魏熙美 5 yıl önce
ebeveyn
işleme
4a79fa06b5

+ 134
- 0
src/pages/building/list/add/components/poster.jsx Dosyayı Görüntüle

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

+ 97
- 0
src/pages/building/list/add/components/share.jsx Dosyayı Görüntüle

@@ -0,0 +1,97 @@
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 Share = props => {
19
+  const [inputValue, changeInput] = useState('')
20
+  const [imgValue, changeImg] = useState('')
21
+  const [shareContentId, setShareContentId] = useState('')
22
+
23
+  const { buildingId } = props.building
24
+  if (buildingId) {
25
+    // eslint-disable-next-line react-hooks/rules-of-hooks
26
+    useEffect(() => {
27
+      request({
28
+        url: '/api/admin/shareContent',
29
+        method: 'GET',
30
+        params: { targetId: buildingId, targetType: 'building' },
31
+      }).then(data => {
32
+        if (data.length > 0) {
33
+          setShareContentId(data[0].shareContentId)
34
+          changeImg(data[0].shareContentImg)
35
+          changeInput(data[0].shareContentTitle)
36
+        }
37
+      }).catch(err => {
38
+        message.info(err.msg || err.message)
39
+      })
40
+    }, [])
41
+  }
42
+
43
+  const submitShare = () => {
44
+    if (buildingId) {
45
+      if (shareContentId) {
46
+        request({
47
+          url: `/api/admin/shareContent/${shareContentId}`,
48
+          method: 'PUT',
49
+          data: { targetId: buildingId, shareContentType: 'building',shareContentImg: imgValue,shareContentTitle: inputValue },
50
+        }).then(data => {
51
+          message.info('保存成功')
52
+        }).catch(err => {
53
+          message.info(err.msg || err.message)
54
+        })
55
+       } else {
56
+        request({
57
+          url: '/api/admin/shareContent',
58
+          method: 'POST',
59
+          data: { targetId: buildingId, shareContentType: 'building',shareContentImg: imgValue,shareContentTitle: inputValue },
60
+        }).then(data => {
61
+          setShareContentId(data.shareContentId)
62
+          message.info('保存成功')
63
+        }).catch(err => {
64
+          message.info(err.msg || err.message)
65
+        })
66
+       }
67
+     } else {
68
+      message.warn('请先保存基本信息数据')
69
+     }
70
+  }
71
+
72
+  return <div style={{ padding: '20px' }}>
73
+    <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
74
+      <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享模板</p>
75
+      <div>
76
+        <p style={{ display: 'flex', alignItems: 'center', fontSize: '14px', color: '#999', margin: '0', lineHeight: '0' }}>
77
+          <img src={logo} style={{ width: '22px', marginRight: '10px' }} />
78
+          知与行互动
79
+        </p>
80
+        <p style={{ fontSize: '16px', color: '#222', fontWeight: '600', margin: '0' }}>{inputValue ? inputValue : '置业V客厅 精准获客平台'}</p>
81
+        <img style={{ width: '200px', height: '140px' }} src={imgValue ? imgValue : poster2} alt="" />
82
+      </div>
83
+    </div>
84
+    <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
85
+      <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>海报标题</p>
86
+      <Input placeholder="请输入海报标题" value={inputValue} onChange={e => changeInput(e.target.value)} />
87
+    </div>
88
+    <div style={{ display: 'flex', width: '100%', marginTop: '40px' }}>
89
+      <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享图片</p>
90
+      <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
91
+    </div>
92
+    <Button type="primary" htmlType="submit" onClick={submitShare} style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
93
+    <Button onClick={() => router.go(-1)}>取消</Button>
94
+  </div>
95
+}
96
+
97
+export default Share

+ 12
- 1
src/pages/building/list/add/index.jsx Dosyayı Görüntüle

@@ -12,6 +12,8 @@ import Wangedit from '../../../../components/Wangedit/Wangedit'
12 12
 import TagGroup from './components/tags'
13 13
 import Base from './components/base'
14 14
 import ImageSet from './components/imageSet'
15
+import Poster from './components/poster'
16
+import Share from './components/share'
15 17
 
16 18
 
17 19
 const { Option } = Select
@@ -44,12 +46,21 @@ function AddBuilding(props) {
44 46
       <Radio.Group value={ tab } buttonStyle="solid" onChange={e => tabsCallback(e)}>
45 47
         <Radio.Button value="base">基本信息</Radio.Button>
46 48
         {
47
-          props.location.query.id && <Radio.Button value="image">图片</Radio.Button>
49
+          props.location.query.id &&
50
+          (
51
+            <>
52
+              <Radio.Button value="image">图片</Radio.Button>
53
+              <Radio.Button value="poster">海报图片</Radio.Button>
54
+              <Radio.Button value="share">分享设置</Radio.Button>
55
+            </>
56
+          )
48 57
         }
49 58
       </Radio.Group>
50 59
       <div style={{ marginTop: '20px' }}>
51 60
         { tab === 'base' && <Base building={{ buildingId: props.location.query && props.location.query.id }} /> }
52 61
         { props.location.query.id && (tab === 'image' && <ImageSet building={{ buildingId: props.location.query && props.location.query.id }} />)}
62
+        { props.location.query.id && (tab === 'poster' && <Poster building={{ buildingId: props.location.query && props.location.query.id }} />)}
63
+        { props.location.query.id && (tab === 'share' && <Share building={{ buildingId: props.location.query && props.location.query.id }} />)}
53 64
       </div>
54 65
     </>
55 66
     // <Tabs defaultActiveKey="1" onChange={tabsCallback}>