Explorar el Código

Merge branch 'dev'

weichaochao hace 5 años
padre
commit
6bba5ae7b8

+ 81
- 0
src/components/uploadImage/ImageUpload.jsx Ver fichero

@@ -0,0 +1,81 @@
1
+import React from 'react';
2
+import { Upload, Icon, message, Modal } from 'antd';
3
+import './style.less';
4
+import { uploaderProps } from '../../utils/upload';
5
+
6
+
7
+
8
+class ImageUpload extends React.Component {
9
+
10
+  state = {
11
+    loading: false,
12
+    previewVisible: false,
13
+    previewImage: '',
14
+    fileList: this.getPropsFileList(),
15
+  };
16
+
17
+  componentDidUpdate(prevProps) {
18
+    // 直接 setState 会死循环
19
+    if (prevProps.value !== this.props.value) {
20
+      this.setState({ fileList: this.getPropsFileList() })
21
+    }
22
+  }
23
+
24
+  getPropsFileList() {
25
+    return !this.props.value ? [] : [{
26
+      uid: '-1',
27
+      name: 'image.png',
28
+      status: 'done',
29
+      url: this.props.value,
30
+    }]
31
+  }
32
+
33
+
34
+  handleChange = ({ file, fileList }) => {
35
+    const { status, response } = file
36
+    this.setState({ fileList, loading: status === "uploading" })
37
+
38
+    if (typeof this.props.onChange === 'function' && status != "uploading") {
39
+      const image = status === 'done' ? response : undefined
40
+      this.props.onChange(image);
41
+    }
42
+  };
43
+
44
+  handleCancel = () => this.setState({ previewVisible: false });
45
+
46
+  handlePreview = async file => {
47
+    console.log(file)
48
+    this.setState({
49
+      previewImage: file.url,
50
+      previewVisible: true,
51
+    });
52
+  };
53
+
54
+  render() {
55
+    const uploadButton = (
56
+      <div>
57
+        <Icon style={{ fontSize: '2em', color: '#aaa' }} type={this.state.loading ? "loading" : "plus"} />
58
+      </div>
59
+    );
60
+
61
+    return (
62
+      <>
63
+      <Upload
64
+        {...uploaderProps}
65
+        listType="picture-card"
66
+        className="avatar-uploader"
67
+        onChange={this.handleChange}
68
+        fileList={this.state.fileList}
69
+        onPreview={this.handlePreview}
70
+      >
71
+        {this.state.fileList.length >= 1 ? null : uploadButton}  
72
+      </Upload>
73
+      <Modal visible={this.state.previewVisible} footer={null} onCancel={this.handleCancel}>
74
+      <img alt="example" style={{ width: '100%' }} src={this.state.previewImage} />
75
+      </Modal>
76
+      </>
77
+    );
78
+  }
79
+}
80
+
81
+export default ImageUpload;

+ 8
- 0
src/components/uploadImage/style.less Ver fichero

@@ -0,0 +1,8 @@
1
+:global {
2
+  .avatar-uploader {
3
+    & > .ant-upload {
4
+      width: 128px;
5
+      height: 128px;
6
+    }
7
+  }
8
+}

+ 11
- 7
src/pages/building/list/add/components/base.jsx Ver fichero

@@ -7,6 +7,7 @@ import request from '../../../../../utils/request';
7 7
 import apis from '../../../../../services/apis';
8 8
 import Styles from '../style.less';
9 9
 import ImageUpload from '../../../../../components/XForm/ImageUpload'
10
+import NewImageUpload from '../../../../../components/uploadImage/ImageUpload';
10 11
 import ImageListUpload from '../../../../../components/XForm/ImageListUpload'
11 12
 import Wangedit from '../../../../../components/Wangedit/Wangedit'
12 13
 import TagGroup from './tags'
@@ -202,11 +203,14 @@ function AddBuilding(props) {
202 203
       data.buildingRestaurant = tagFilter(data.buildingRestaurant, 'Restaurant')
203 204
     }
204 205
   
205
-    if(typeof(data.highlights) != "undefined" && (typeof(data.highlightsCover) == "undefined" || data.highlightsCover == null)){
206
-      openNotificationWithIcon('error', '请上传项目亮点封面')
207
-      return;
206
+    // if(typeof(data.highlights) != "undefined" && (typeof(data.highlightsCover) == "undefined" || data.highlightsCover == null)){
207
+    //   openNotificationWithIcon('error', '请上传项目亮点封面')
208
+    //   return;
209
+    // }
210
+    console.log(data,"datadataddata")
211
+    if(typeof(data.highlights) == "undefined"){
212
+      data.highlights = null;
208 213
     }
209
-
210 214
     
211 215
     const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
212 216
     request({ ...api, data: { ...data } }).then(res => {
@@ -587,11 +591,11 @@ function AddBuilding(props) {
587 591
           </Form.Item>*/}
588 592
           <Form.Item label="亮点封面" help="建议尺寸:比例3:1 690*230px,用于项目详情-项目亮点封面图">
589 593
             {getFieldDecorator('highlightsCover')(
590
-              <ImageUpload />,
594
+              <NewImageUpload onChange={e => console.log(e,"66")}/>,
591 595
             )}
592 596
           </Form.Item>
593
-          <Form.Item label="亮点类型">
594
-            {getFieldDecorator('highlightsType', {
597
+          <Form.Item label="亮点类型" help="说明:项目亮点必须上传封面图才会在小程序端展示">
598
+            {getFieldDecorator('highlightsType',{
595 599
               initialValue: "rich",
596 600
             })(
597 601
             <Radio.Group onChange={e => highlightsTypeChange(e)}>

+ 1
- 1
src/pages/building/list/add/components/poster.jsx Ver fichero

@@ -121,7 +121,7 @@ const Poster = props => {
121 121
             overflow: 'hidden',
122 122
             textOverflow: 'ellipsis',
123 123
           }}>{inputValue || (building.buildingName || '海报标题')}</p>
124
-          <p style={{ color: '#999', padding: ' 0 20px' }}><span style={{ color: '#fd0d0c', fontSize: '24px', marginLeft: '6px' }}>{building.price} </span><span style={{ color: '#fd0d0c', fontSize: '20px' }}>元/m²</span></p>
124
+          <p style={{ color: '#999', padding: ' 0 20px' }}><span style={{ color: '#fd0d0c', fontSize: '24px', marginLeft: '6px' }}>{building.price} </span><span style={{ color: '#fd0d0c', fontSize: '20px' }}></span></p>
125 125
           <img src={yinhao} style={{ width: '30px', marginLeft: '22px' }} alt="" />
126 126
           <p style={{
127 127
             margin: '16px 20px 28px 20px', fontSize: '17px', color: '#999',

+ 0
- 0
src/pages/roomManager/roomInfo/roomInfo.jsx Ver fichero


+ 0
- 0
src/pages/roomManager/saleBatch/shareRecord.jsx Ver fichero


+ 0
- 0
src/pages/roomManager/saleBatch/visitRecord.jsx Ver fichero