dingxin 5 anni fa
parent
commit
cdc15aadd6

+ 1
- 1
config/config.js Vedi File

@@ -455,7 +455,7 @@ export default {
455 455
 
456 456
   proxy: {
457 457
     '/api/': {
458
-      target: 'http://localhost:8080//',
458
+      target: 'http://localhost:8080/',
459 459
       changeOrigin: true,
460 460
       // pathRewrite: { '^/server': '' },
461 461
     },

BIN
src/assets/poster1.png Vedi File


BIN
src/assets/poster2.png Vedi File


BIN
src/assets/touxiang.jpg Vedi File


+ 3
- 3
src/components/GlobalHeader/AvatarDropdown.jsx Vedi File

@@ -29,7 +29,7 @@ class AvatarDropdown extends React.Component {
29 29
     const {
30 30
       currentUser = {
31 31
         avatar: '',
32
-        name: '',
32
+        userName: '',
33 33
       },
34 34
       menu,
35 35
     } = this.props;
@@ -55,11 +55,11 @@ class AvatarDropdown extends React.Component {
55 55
         </Menu.Item>
56 56
       </Menu>
57 57
     );
58
-    return currentUser && currentUser.name ? (
58
+    return currentUser && currentUser.userName ? (
59 59
       <HeaderDropdown overlay={menuHeaderDropdown}>
60 60
         <span className={`${styles.action} ${styles.account}`}>
61 61
           <Avatar size="small" className={styles.avatar} src={currentUser.avatar} alt="avatar" />
62
-          <span className={styles.name}>{currentUser.name}</span>
62
+          <span className={styles.name}>{currentUser.userName}</span>
63 63
         </span>
64 64
       </HeaderDropdown>
65 65
     ) : (

+ 74
- 0
src/components/XForm/ImageListUpload.jsx Vedi File

@@ -0,0 +1,74 @@
1
+import React from 'react';
2
+import { Upload, Icon, Modal } from 'antd';
3
+import './style.less';
4
+import { uploaderProps } from '../../utils/upload';
5
+
6
+function getBase64(file) {
7
+  return new Promise((resolve, reject) => {
8
+    const reader = new FileReader();
9
+    reader.readAsDataURL(file);
10
+    reader.onload = () => resolve(reader.result);
11
+    reader.onerror = error => reject(error);
12
+  });
13
+}
14
+
15
+class ImageListUpload extends React.Component {
16
+  state = {
17
+    previewVisible: false,
18
+    previewImage: '',
19
+    fileList: [],
20
+  };
21
+
22
+  handleCancel = () => this.setState({ previewVisible: false });
23
+
24
+  handlePreview = async file => {
25
+    if (!file.url && !file.preview) {
26
+      file.preview = await getBase64(file.originFileObj);
27
+    }
28
+
29
+    this.setState({
30
+      previewImage: file.url || file.preview,
31
+      previewVisible: true,
32
+    });
33
+  };
34
+
35
+  handleChange = ({ fileList }) => {
36
+    this.setState({ fileList })
37
+    if (typeof this.props.onChange === 'function') {
38
+      // return item.response.url
39
+      const images = fileList.filter(item => item.status === 'done')
40
+      this.props.onChange(images.map(item => item.response.url))
41
+    }
42
+  };
43
+
44
+  render() {
45
+    const { previewVisible, previewImage, fileList } = this.state;
46
+
47
+    const { value } = this.props
48
+
49
+    const uploadButton = (
50
+      <div>
51
+        <Icon type="plus" />
52
+        <div className="ant-upload-text">Upload</div>
53
+      </div>
54
+    );
55
+    return (
56
+      <div className="clearfix">
57
+        <Upload
58
+          listType="picture-card"
59
+          fileList={fileList || value}
60
+          onPreview={this.handlePreview}
61
+          onChange={this.handleChange}
62
+          { ...uploaderProps }
63
+        >
64
+          {fileList.length >= 8 ? null : uploadButton}
65
+        </Upload>
66
+        <Modal visible={previewVisible} footer={null} onCancel={this.handleCancel}>
67
+          <img alt="example" style={{ width: '100%' }} src={previewImage} />
68
+        </Modal>
69
+      </div>
70
+    );
71
+  }
72
+}
73
+
74
+export default ImageListUpload;

+ 13
- 0
src/components/XForm/style.css Vedi File

@@ -0,0 +1,13 @@
1
+:global .avatar-uploader > .ant-upload {
2
+  width: 128px;
3
+  height: 128px;
4
+}
5
+/* you can make up upload button and sample style by using stylesheets */
6
+.ant-upload-select-picture-card i {
7
+  font-size: 32px;
8
+  color: #999;
9
+}
10
+.ant-upload-select-picture-card .ant-upload-text {
11
+  margin-top: 8px;
12
+  color: #666;
13
+}

+ 12
- 0
src/components/XForm/style.less Vedi File

@@ -6,3 +6,15 @@
6 6
     }
7 7
   }
8 8
 }
9
+
10
+
11
+/* you can make up upload button and sample style by using stylesheets */
12
+.ant-upload-select-picture-card i {
13
+  font-size: 32px;
14
+  color: #999;
15
+}
16
+
17
+.ant-upload-select-picture-card .ant-upload-text {
18
+  margin-top: 8px;
19
+  color: #666;
20
+}

+ 13
- 0
src/components/XForm/style.wxss Vedi File

@@ -0,0 +1,13 @@
1
+:global .avatar-uploader > .ant-upload {
2
+  width: 128px;
3
+  height: 128px;
4
+}
5
+/* you can make up upload button and sample style by using stylesheets */
6
+.ant-upload-select-picture-card i {
7
+  font-size: 32px;
8
+  color: #999;
9
+}
10
+.ant-upload-select-picture-card .ant-upload-text {
11
+  margin-top: 8px;
12
+  color: #666;
13
+}

+ 0
- 2
src/layouts/SecurityLayout.jsx Vedi File

@@ -25,8 +25,6 @@ class SecurityLayout extends React.Component {
25 25
     const { isReady } = this.state;
26 26
     const { children, loading, currentUser } = this.props;
27 27
 
28
-    console.log('------------>', loading, currentUser)
29
-
30 28
     if ((!currentUser.userId && loading) || !isReady) {
31 29
       return <PageLoading />;
32 30
     }

+ 3
- 2
src/models/user.js Vedi File

@@ -5,6 +5,7 @@ const UserModel = {
5 5
   namespace: 'user',
6 6
   state: {
7 7
     currentUser: {},
8
+    menuList: [],
8 9
   },
9 10
   effects: {
10 11
     // *fetch(_, { call, put }) {
@@ -25,8 +26,8 @@ const UserModel = {
25 26
     },
26 27
   },
27 28
   reducers: {
28
-    saveCurrentUser(state, action) {
29
-      return { ...state, currentUser: action.payload || {} };
29
+    saveCurrentUser(state, { payload = {} }) {
30
+      return { ...state, currentUser: payload.taUser || {}, menuList: payload.menuList || [] };
30 31
     },
31 32
     changeNotifyCount(
32 33
       state = {

+ 6
- 5
src/pages/activity/editActivity.jsx Vedi File

@@ -12,6 +12,9 @@ import PosterBottom from '../../assets/bottom.png'
12 12
 import yinhao from '../../assets/yinhao.png'
13 13
 import ImageUploader from '../../components/XForm/ImageUpload';
14 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';
15 18
 
16 19
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
17 20
 const { TextArea } = Input;
@@ -174,11 +177,9 @@ const Edit = (props) => {
174 177
       <div style={{ display: 'flex' }}>
175 178
         <div style={{ width: '420px', height: '900px', display: 'inline-block', marginTop: '30px' }}>
176 179
           <div style={{ width: '375px', height: '785px', backgroundColor: '#fff', boxShadow: '0px 0px 16px 6px rgba(0,0,0,0.15)', position: 'relative', margin: '0 auto' }}>
177
-
178
-            <img style={{ width: '100%', height: '300px' }} src={imgValue ? imgValue : 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg'} alt="" />
179
-
180
+            <img style={{ width: '100%', height: '300px' }} src={imgValue ? imgValue : poster1} alt="" />
180 181
             <div style={{ display: 'flex', alignItems: 'center', marginTop: '-24px' }}>
181
-              <img style={{ width: '70px', height: '70px', border: '4px solid #fff', borderRadius: '35px', marginLeft: '16px' }} src="http://img0.imgtn.bdimg.com/it/u=3463541938,2540701974&fm=26&gp=0.jpg" alt="" />
182
+              <img style={{ width: '70px', height: '70px', border: '4px solid #fff', borderRadius: '35px', marginLeft: '16px' }} src={touxiang} alt="" />
182 183
               <span style={{ color: '#222', fontWeight: '600', margin: '24px 10px 0 14px', fontSize: '17px' }}>喵喵</span>
183 184
               <span style={{ color: '#999', marginTop: '25px', fontSize: '17px' }}>邀您阅读</span>
184 185
               <span style={{ color: '#999', margin: '25px 0 0 60px', fontSize: '17px' }}>2019.09.21</span>
@@ -247,7 +248,7 @@ const Edit = (props) => {
247 248
         <div>
248 249
           <p style={{ display: 'flex', alignItems: 'center', fontSize: '14px', color: '#999', margin: '0', lineHeight: '0' }}><img src={logo} style={{ width: '22px', marginRight: '10px' }} />知与行互动</p>
249 250
           <p style={{ fontSize: '16px', color: '#222', fontWeight: '600', margin: '0' }}>{inputValue ? inputValue : '置业V客厅 精准获客平台'}</p>
250
-          <img style={{ width: '200px', height: '140px' }} src={imgValue ? imgValue : 'http://house.china.com.cn/nanjing/UserFiles/20171124/11070256.jpg'} alt="" />
251
+          <img style={{ width: '200px', height: '140px' }} src={imgValue ? imgValue : poster2} alt="" />
251 252
         </div>
252 253
       </div>
253 254
       <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>

+ 60
- 13
src/pages/building/list/add/components/base.jsx Vedi File

@@ -1,11 +1,12 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, InputNumber } from 'antd';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, InputNumber, notification } from 'antd';
3 3
 import moment from 'moment';
4 4
 import request from '../../../../../utils/request';
5 5
 import apis from '../../../../../services/apis';
6 6
 import Styles from '../style.less';
7 7
 import { router } from 'umi';
8 8
 import ImageUpload from '../../../../../components/XForm/ImageUpload'
9
+import ImageListUpload from '../../../../../components/XForm/ImageListUpload'
9 10
 import Wangedit from '../../../../../components/Wangedit/Wangedit'
10 11
 import TagGroup from './tags'
11 12
 
@@ -23,21 +24,67 @@ const formItemLayout = {
23 24
   },
24 25
 };
25 26
 
27
+
28
+function openNotificationWithIcon(type, message) {
29
+  notification[type]({
30
+    message,
31
+    description:
32
+      '',
33
+  });
34
+}
35
+
36
+
26 37
 function AddBuilding(props) {
27 38
   const { getFieldDecorator } = props.form;
28 39
 
40
+  if (props.building.buildingId !== undefined) {
41
+    const { buildingId } = props.building
42
+    if (buildingId !== '') {
43
+      // eslint-disable-next-line react-hooks/rules-of-hooks
44
+      useEffect(() => {
45
+        getById(buildingId)
46
+      }, [])
47
+    }
48
+  }
49
+
50
+   // 获取详情信息
51
+   function getById(currentId) {
52
+    const { url, method } = apis.building.buildingGetById
53
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(currentId)
54
+
55
+    request({ url: tempUrl, method }).then(res => {
56
+      res.openingDate = moment(res.openingDate)
57
+      res.receivedDate = moment(res.receivedDate)
58
+      props.form.setFieldsValue(res)
59
+    })
60
+  }
61
+
29 62
   function handleSubmit(e) {
30 63
     e.preventDefault();
31 64
     props.form.validateFieldsAndScroll((err, values) => {
32 65
       if (!err) {
33
-        console.log('Received values of form: ', values);
66
+        addBuilding(values)
34 67
       }
35 68
     });
36 69
   }
37 70
 
71
+  function addBuilding(data) {
72
+    data.openingDate = moment(data.openingDate, 'yyyy-MM-dd HH:mm:ss')
73
+    data.receivedDate = moment(data.receivedDate, 'yyyy-MM-dd HH:mm:ss')
74
+    data.buildingProjectType = []
75
+    // 项目主图
76
+    data.img = data.avatarImage && data.avatarImage.map((item, index) => ({ imgType: 'banner', url: item, orderNo: index + 1 }))
77
+
78
+    request({ ...apis.building.addBuilding, data: { ...data } }).then(() => {
79
+      openNotificationWithIcon('success', '操作成功')
80
+    }).catch(err => {
81
+      openNotificationWithIcon('error', err.message)
82
+    })
83
+  }
84
+
38 85
   return (
39 86
         <Form {...formItemLayout} onSubmit={handleSubmit}>
40
-          <Form.Item label="楼盘编号">
87
+          <Form.Item label="楼盘编号" hasFeedback>
41 88
             {getFieldDecorator('code')(<Input />)}
42 89
           </Form.Item>
43 90
           <Form.Item label="楼盘名称" hasFeedback>
@@ -47,13 +94,13 @@ function AddBuilding(props) {
47 94
             {getFieldDecorator('name')(<Input />)}
48 95
           </Form.Item>
49 96
           <Form.Item label="项目类型" hasFeedback>
50
-            {getFieldDecorator('name')(<Input />)}
97
+            {getFieldDecorator('buildingProjectType')(<Input />)}
51 98
           </Form.Item>
52 99
           <Form.Item label="均价" hasFeedback>
53 100
             {getFieldDecorator('price')(<Input />)}
54 101
           </Form.Item>
55 102
           <Form.Item label="开盘时间" hasFeedback>
56
-            {getFieldDecorator('openingDate')(<DatePicker />)}
103
+            {getFieldDecorator('openingDate')(<DatePicker format="YYYY/MM/DD" />)}
57 104
           </Form.Item>
58 105
           <Form.Item label="电话" hasFeedback>
59 106
             {getFieldDecorator('tel')(<Input />)}
@@ -79,17 +126,17 @@ function AddBuilding(props) {
79 126
             )}
80 127
           </Form.Item>
81 128
           <Form.Item label="项目主图" hasFeedback>
82
-            {getFieldDecorator('tags')(
83
-              <ImageUpload />,
129
+            {getFieldDecorator('avatarImage')(
130
+              <ImageListUpload />,
84 131
             )}
85 132
           </Form.Item>
86 133
           <Form.Item label="地址图片" hasFeedback>
87
-            {getFieldDecorator('tags')(
134
+            {getFieldDecorator('mapImg')(
88 135
               <ImageUpload />,
89 136
             )}
90 137
           </Form.Item>
91 138
           <Form.Item label="海报底图" hasFeedback>
92
-            {getFieldDecorator('tags')(
139
+            {getFieldDecorator('poster')(
93 140
               <ImageUpload />,
94 141
             )}
95 142
           </Form.Item>
@@ -123,11 +170,11 @@ function AddBuilding(props) {
123 170
           <Form.Item label="项目坐标" hasFeedback>
124 171
             {getFieldDecorator('coordinate')(<Input disabled />)}
125 172
           </Form.Item>
126
-          <Form.Item label="项目地址" hasFeedback>
127
-            {getFieldDecorator('coordinate')(<Input />)}
173
+          <Form.Item label="地图位置" hasFeedback>
174
+            {(<Input />)}
128 175
           </Form.Item>
129 176
           <Form.Item label="周边交通" hasFeedback>
130
-            {getFieldDecorator('buildingArea')(
177
+            {getFieldDecorator('buildingTransport')(
131 178
               <TagGroup />,
132 179
             )}
133 180
           </Form.Item>
@@ -184,7 +231,7 @@ function AddBuilding(props) {
184 231
             {getFieldDecorator('rightsYear')(<InputNumber />)}
185 232
           </Form.Item>
186 233
           <Form.Item label="预售许可证" hasFeedback>
187
-            {getFieldDecorator('decoration')(
234
+            {getFieldDecorator('preSalePermit')(
188 235
               <ImageUpload />,
189 236
             )}
190 237
           </Form.Item>

+ 1
- 1
src/pages/building/list/add/components/imageSet.jsx Vedi File

@@ -138,7 +138,7 @@ function imageSet(props) {
138 138
 
139 139
       {/* 编辑页 */}
140 140
       {/*  onSuccess是子组件传递事件信息  */}
141
-      <ModalImage visibleData={visibleData} key={visibleData.apartmentId} onSuccess={getList}/>
141
+      <ModalImage visibleData={visibleData} key={1} onSuccess={getList}/>
142 142
     </>
143 143
   )
144 144
 }

+ 1
- 1
src/pages/building/list/add/components/modalImage.jsx Vedi File

@@ -89,7 +89,7 @@ class ModalImage extends React.Component {
89 89
     const { url, method } = apis.building.buildingApartmentGetById
90 90
     const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(apartmentId)
91 91
 
92
-    request({ url: tempUrl, method , params: { ...params } }).then(res => {
92
+    request({ url: tempUrl, method, params: { ...params } }).then(res => {
93 93
       // res.img = res.buildingImgList.map((item, _) => item.url)
94 94
       res.img = res.buildingImgList[0].url
95 95
       this.props.form.setFieldsValue(res)

+ 15
- 1
src/pages/building/list/add/components/tags.jsx Vedi File

@@ -34,15 +34,29 @@ class EditableTagGroup extends React.Component {
34 34
       inputVisible: false,
35 35
       inputValue: '',
36 36
     });
37
+
38
+    if (typeof this.props.onChange === 'function') {
39
+      const tempTags = tags.join(',')
40
+      this.props.onChange(tempTags);
41
+    }
37 42
   };
38 43
 
39 44
   saveInputRef = input => (this.input = input);
40 45
 
41 46
   render() {
42 47
     const { tags, inputVisible, inputValue } = this.state;
48
+
49
+    const { value } = this.props
50
+    let data = []
51
+    if (value !== undefined && value !== null) {
52
+      data = value.split(',')
53
+    } else {
54
+      data = tags
55
+    }
56
+
43 57
     return (
44 58
       <div>
45
-        {tags.map((tag, index) => {
59
+        {data.map((tag, index) => {
46 60
           const isLongTag = tag.length > 20;
47 61
           const tagElem = (
48 62
             <Tag key={tag} closable onClose={() => this.handleClose(tag)}>

+ 10
- 21
src/pages/building/list/add/index.jsx Vedi File

@@ -29,35 +29,24 @@ const formItemLayout = {
29 29
 };
30 30
 
31 31
 function AddBuilding(props) {
32
-  // eslint-disable-next-line react-hooks/rules-of-hooks
33
-  const [dataSource, setDataSource] = useState({ records: [] })
34
-
35
-  const [buildingAreaTags, setBuildingAreaTags] = useState({ tags: ['Unremovable', 'Tag 2', 'Tag 3'], inputVisible: false, inputValue: '' })
36
-
37
-
38
-  const { getFieldDecorator } = props.form;
39
-
40
-  function handleSubmit(e) {
41
-    e.preventDefault();
42
-    props.form.validateFieldsAndScroll((err, values) => {
43
-      if (!err) {
44
-        console.log('Received values of form: ', values);
45
-      }
46
-    });
47
-  }
48
-
49 32
   function tabsCallback(key) {
50 33
     console.log(key);
51 34
   }
52 35
 
36
+  console.log(props.location)
37
+
53 38
   return (
54 39
     <Tabs defaultActiveKey="1" onChange={tabsCallback}>
55 40
       <TabPane tab="基本信息" key="1">
56
-        <Base />
57
-      </TabPane>
58
-      <TabPane tab="图片" key="2">
59
-        <ImageSet building={{ buildingId: '159fd19bb973b6972c10fbebf07ddeb1' }} />
41
+        <Base building={{ buildingId: props.location.query && props.location.query.id }} />
60 42
       </TabPane>
43
+      {
44
+        props.location.query.id &&
45
+        <TabPane tab="图片" key="2">
46
+          {/* '159fd19bb973b6972c10fbebf07ddeb1' */}
47
+          <ImageSet building={{ buildingId: props.location.query && props.location.query.id }} />
48
+        </TabPane>
49
+      }
61 50
     </Tabs>
62 51
   )
63 52
 }

+ 87
- 8
src/pages/building/list/index.jsx Vedi File

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert } from 'antd';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, notification, Modal } from 'antd';
3 3
 import moment from 'moment';
4 4
 import request from '../../../utils/request';
5 5
 import apis from '../../../services/apis';
@@ -13,6 +13,14 @@ const { Meta } = Card;
13 13
 
14 14
 const tempDate = [{ code: 's101' }]
15 15
 
16
+function openNotificationWithIcon(type, message) {
17
+  notification[type]({
18
+    message,
19
+    description:
20
+      '',
21
+  });
22
+}
23
+
16 24
 /**
17 25
  *卡片
18 26
  *
@@ -21,6 +29,76 @@ const tempDate = [{ code: 's101' }]
21 29
 function CartBody(props) {
22 30
   const { data } = props
23 31
 
32
+
33
+  function toEdi(record) {
34
+    router.push({
35
+      pathname: '/building/list/add',
36
+      query: {
37
+        id: record.buildingId,
38
+      },
39
+    })
40
+  }
41
+
42
+  /**
43
+   *发布 取消 发布
44
+   *
45
+   * @param {*} record
46
+   */
47
+  function pulicAndUnPulic(record) {
48
+    const modal = Modal.confirm();
49
+    const buidingStatus = record.status === 1 ? 2 : 1
50
+    const title = record.status === 1 ? '确认取消发布此数据?' : '确认发布此数据?'
51
+
52
+    modal.update({
53
+      content: title,
54
+      okText: '确认',
55
+      cancelText: '关闭',
56
+      onOk: () => {
57
+        request({ ...apis.building.updateStatus, data: { id: record.buildingId, status: buidingStatus } }).then(() => {
58
+          openNotificationWithIcon('success', '操作成功')
59
+          props.onSuccess()
60
+        }).catch(err => {
61
+          openNotificationWithIcon('error', err.message)
62
+        })
63
+
64
+        modal.destroy();
65
+      },
66
+      onCancel: () => {
67
+        modal.destroy();
68
+      },
69
+    });
70
+  }
71
+
72
+  /**
73
+   *删除楼盘
74
+   *
75
+   * @param {*} record
76
+   */
77
+  function deleteBuilding(record) {
78
+    const { url, method } = apis.building.deleteBuilding
79
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(record.buildingId)
80
+
81
+    const modal = Modal.confirm();
82
+    modal.update({
83
+      content: '确定删除此楼盘?',
84
+      okText: '确认',
85
+      cancelText: '关闭',
86
+      onOk: () => {
87
+        request({ url: tempUrl, method }).then(() => {
88
+          openNotificationWithIcon('success', '操作成功')
89
+          props.onSuccess()
90
+        }).catch(err => {
91
+          openNotificationWithIcon('error', err.message)
92
+        })
93
+
94
+        modal.destroy();
95
+      },
96
+      onCancel: () => {
97
+        modal.destroy();
98
+      },
99
+    });
100
+  }
101
+
24 102
   return (
25 103
           <Card
26 104
             hoverable
@@ -31,7 +109,7 @@ function CartBody(props) {
31 109
             <p className={Styles.cardText}>
32 110
               <span className={Styles.title}>楼盘编号</span>
33 111
               <span >:{ data.code }</span>
34
-              <span className={Styles.ediText}>
112
+              <span className={Styles.ediText} onClick={() => toEdi(data)}>
35 113
                 编辑
36 114
                 <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
37 115
               </span>
@@ -52,20 +130,21 @@ function CartBody(props) {
52 130
             </p>
53 131
             <p className={Styles.cardItem}>
54 132
               <span className={Styles.title}>发布状态</span>
55
-              <span >:{ data.status === '1' ? '已发布' : '未发布' }</span>
133
+              <span >:{ data.status === 1 ? '已发布' : '未发布' }</span>
56 134
             </p>
57 135
             <p className={Styles.cardItem}>
58 136
               <span className={Styles.title}>录入时间</span>
59 137
               <span >:{ data.createDate }</span>
60 138
             </p>
61 139
             <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
62
-              <span style={{ color: '#1990FF' }}>
63
-                取消发布
140
+              <span style={{ color: '#1990FF' }} onClick={() => pulicAndUnPulic(data)}>
141
+                {/* 已发布的时候,需要显示取消发布的字样 */}
142
+                { data.status === 1 ? '取消发布' : '发布' }
64 143
                 <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
65 144
               </span>
66 145
               <span style={{
67 146
                 color: '#FF4A4A', position: 'absolute', right: '0',
68
-              }} >
147
+              }} onClick={() => deleteBuilding(data)}>
69 148
                 删除
70 149
                 <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
71 150
               </span>
@@ -213,9 +292,9 @@ function body(props) {
213 292
       {/* 卡片内容,显示楼盘项目  */}
214 293
       <Row style={{ padding: ' 0 10px' }}>
215 294
         {
216
-          dataSource.records.map((item, index) => (
295
+          dataSource.records.map((item, _) => (
217 296
               <Col span={8}>
218
-                <CartBody data={item} key={item.buildingId}/>
297
+                <CartBody data={item} key={item.buildingId} onSuccess={getList}/>
219 298
               </Col>
220 299
             ))
221 300
         }

+ 16
- 0
src/services/apis.js Vedi File

@@ -22,6 +22,22 @@ export default {
22 22
       method: 'GET',
23 23
       url: `${prefix}/buildinglist`,
24 24
     },
25
+    updateStatus: {
26
+      method: 'PUT',
27
+      url: `${prefix}/building/update/status`,
28
+    },
29
+    addBuilding: {
30
+      method: 'POST',
31
+      url: `${prefix}/building/add`,
32
+    },
33
+    buildingGetById: {
34
+      method: 'GET',
35
+      url: `${prefix}/buildingSelectId/id`,
36
+    },
37
+    deleteBuilding: {
38
+      method: 'DELETE',
39
+      url: `${prefix}/building/delete/id`,
40
+    },
25 41
     buildingApartment: {
26 42
       method: 'GET',
27 43
       url: `${prefix}/buildingApartment/buildingId/id`,

+ 31
- 0
src/utils/mixStr.js Vedi File

@@ -0,0 +1,31 @@
1
+
2
+const fill2Len = (str, len) => {
3
+  if (!str) {
4
+    return '*'.repeat(len)
5
+  }
6
+
7
+  const orginLen = str.length
8
+  if (len <= orginLen) {
9
+    return str.substr(0, len)
10
+  }
11
+
12
+  return str.repeat(Math.floor(len / orginLen)) + str.substr(0, len % orginLen)
13
+}
14
+
15
+const mixChars = window.navigator.userAgent + (new Date).toUTCString().replace(/\d{2}:\d{2}:\d{2}/, '')
16
+
17
+const strXOR = (str, mix) => {
18
+  if (!str) return str
19
+
20
+  const strLen = str.length
21
+  const mixStr = fill2Len(mix, strLen)
22
+
23
+  const result = []
24
+  for (let i = 0; i < strLen; i ++) {
25
+    result.push(String.fromCharCode(str.charCodeAt(i) ^ mixStr.charCodeAt(i)))
26
+  }
27
+
28
+  return result.join('')
29
+}
30
+
31
+export default str => strXOR(str, mixChars)

+ 4
- 3
src/utils/request.js Vedi File

@@ -5,6 +5,7 @@
5 5
 import request from 'umi-request';
6 6
 import { notification } from 'antd';
7 7
 import apis from '../services/apis';
8
+import mixStr from './mixStr';
8 9
 
9 10
 const codeMessage = {
10 11
   200: '服务器成功返回请求的数据。',
@@ -34,11 +35,11 @@ const replaceURLParams = (url, params = {}) => {
34 35
 request.interceptors.request.use((url, options) => {
35 36
   const { urlData, headers = {}, logout = false, data, ...opts } = options
36 37
   const apiURL = urlData ? replaceURLParams(url, urlData) : url
37
-  const token = window.localStorage.getItem('x-token')
38
+  const token = mixStr(window.localStorage.getItem('test-foobar'))
38 39
   const authHeader = token ? { Authorization: `Bearer ${token}` } : {}
39 40
 
40 41
   if (logout) {
41
-    window.localStorage.removeItem('x-token')
42
+    window.localStorage.removeItem('test-foobar')
42 43
   }
43 44
 
44 45
   return (
@@ -81,7 +82,7 @@ request.interceptors.response.use(async (response, options) => {
81 82
       }
82 83
 
83 84
       if (data && data.token) {
84
-        window.localStorage.setItem('x-token', data.token)
85
+        window.localStorage.setItem('test-foobar', mixStr(data.token))
85 86
       }
86 87
 
87 88
       return data;