123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import React, { useState, useEffect } from 'react';
- import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload } from 'antd';
- import { FormattedMessage } from 'umi-plugin-react/locale';
- import moment from 'moment';
- import router from 'umi/router';
- import BuildSelect from '../../../../../components/SelectButton/BuildSelect'
- import XForm, { FieldTypes } from '../../../../../components/XForm';
- import Wangedit from '../../../../../components/Wangedit/Wangedit'
- import request from '../../../../../utils/request'
- import yinhao from '../../../../../assets/yinhao.png'
- import ImageUploader from '../../../../../components/XForm/ImageUpload';
- import logo from '../../../../../assets/logo.png';
- import touxiang from '../../../../../assets/touxiang.jpg';
- import poster1 from '../../../../../assets/poster1.png';
- import poster2 from '../../../../../assets/poster2.png';
- import apis from '../../../../../services/apis';
-
- const Share = props => {
- const [inputValue, changeInput] = useState('')
- const [imgValue, changeImg] = useState('')
- const [shareContentId, setShareContentId] = useState('')
-
- const { buildingId } = props.building
- if (buildingId) {
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useEffect(() => {
- request({
- ...apis.activity.shareContent,
- params: { targetId: buildingId, targetType: 'building' },
- }).then(data => {
- if (data.length > 0) {
- setShareContentId(data[0].shareContentId)
- changeImg(data[0].shareContentImg)
- changeInput(data[0].shareContentTitle)
- }
- }).catch(err => {
- message.info(err.msg || err.message)
- })
- }, [])
- }
-
- const submitShare = () => {
- if (buildingId) {
- if (shareContentId) {
- request({
- ...apis.activity.updateShareContent,
- urlData: { id: shareContentId },
- data: { targetId: buildingId, shareContentType: 'building', shareContentImg: imgValue,shareContentTitle: inputValue },
- }).then(data => {
- message.info('保存成功')
- }).catch(err => {
- message.info(err.msg || err.message)
- })
- } else {
- request({
- ...apis.activity.addShareContent,
- data: { targetId: buildingId, shareContentType: 'building', shareContentImg: imgValue,shareContentTitle: inputValue },
- }).then(data => {
- setShareContentId(data.shareContentId)
- message.info('保存成功')
- }).catch(err => {
- message.info(err.msg || err.message)
- })
- }
- } else {
- message.warn('请先保存基本信息数据')
- }
- }
-
- return <div style={{ padding: '20px' }}>
- <div style={{ display: 'flex', margin: '10px 0 40px 0', width: '100%' }}>
- <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享模板</p>
- <div>
- {/* <p style={{ display: 'flex', alignItems: 'center', fontSize: '14px', color: '#999', margin: '0', lineHeight: '0' }}>
- <img src={logo} style={{ width: '22px', marginRight: '10px' }} />
- 南京云致
- </p> */}
- <p style={{ fontSize: '16px', color: '#222', fontWeight: '600', margin: '0' }}>{inputValue ? inputValue : ''}</p>
- <img style={{ width: '200px', height: '160px' }} src={imgValue ? imgValue : poster2} alt="" />
- </div>
- </div>
- <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
- <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>分享标题</p>
- <Input placeholder="请输入分享标题" value={inputValue} onChange={e => changeInput(e.target.value)} />
- </div>
- <div style={{ display: 'flex', width: '100%', marginTop: '40px' }}>
- <p style={{ minWidth: '200px', color: '#222', textAlign: 'right', margin: '0 30px 0 0' }}>楼盘分享图</p>
- <ImageUploader value={imgValue} onChange={e => changeImg(e)} />
- </div>
- <p style={{ fontSize: '0.5vw', color: '#A9A9A9', marginLeft: '230px', marginTop: '20px' }}>建议图片尺寸:750*600px,比例5:4,格式:jpg,用于楼盘分享好友</p>
- <Button type="primary" htmlType="submit" onClick={submitShare} style={{ margin: '40px 40px 40px 220px' }}> 确定</Button>
- <Button onClick={() => router.go(-1)}>取消</Button>
- </div>
- }
-
- export default Share
|