1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import React, { Component } from "react";
- import { Modal, Icon, Upload } from "antd";
- import { timingSafeEqual } from "crypto";
- class PicturesWall extends Component {
- constructor(props) {
- super(props);
- this.state = {
- previewVisible: false,
- previewImage: "",
- fileList: this.props.pictureUrl
- };
- this.handleCancel = this.handleCancel.bind(this);
- this.handleChange = this.handleChange.bind(this);
- this.handlePreview = this.handlePreview.bind(this);
- }
- handleCancel() {
- this.setState({
- previewVisible: false
- });
- }
- handlePreview(file) {
- this.setState({
- previewImage: file.url || file.thumbUrl,
- previewVisible: true
- });
- }
- handleChange(info) {
- let fileList = info.fileList;
- this.setState({
- fileList
- });
- this.props.fileList(fileList);
- }
- componentWillReceiveProps(nextProps) {
- this.state.fileList = nextProps.pictureUrl;
- this.state.pojectApplicationUrl = undefined;
- }
- render() {
- const { previewVisible, previewImage, fileList } = this.state;
- const uploadButton = (
- <div>
- <Icon type="plus" />
- <div className="ant-upload-text">点击上传</div>
- </div>
- );
- return (
- <div style={{ display: "inline-block" }}>
- <Upload
- action={
- globalConfig.context + this.props.url
- }
- data={{ sign: this.props.sign }}
- listType="picture-card"
- fileList={fileList}
- onPreview={this.handlePreview}
- onChange={this.handleChange}
- >
- {fileList.length >= 18 ? null : uploadButton}
- </Upload>
- <Modal
- maskClosable={false}
- visible={previewVisible}
- footer={null}
- onCancel={this.handleCancel}
- >
- <img alt="example" style={{ width: "100%" }} src={previewImage} />
- </Modal>
- </div>
- );
- }
- }
- export default PicturesWall;
|