import React from 'react'; import { Cascader, Input, Button, Form, Select, Radio, Upload, Icon, Spin, message, Modal } from 'antd'; import './person.less'; import { splitUrl, getBase64, beforeUpload } from '../../tools.js'; import { areaSelect } from '../../NewDicProvinceList'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import ImgList from "../../common/imgList"; const FormItem = Form.Item; const Option = Select.Option; const RadioGroup = Radio.Group; class Avatar extends React.Component { constructor(props) { super(props); this.state = { imageUrl: '', propsbool: true, } } handleChange(info) { if (info.file.status === 'done') { // Get this url from response in real world. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl })); this.props.urlData(info.file.response.data); } } componentWillReceiveProps(nextProps) { if (nextProps.picUrl && this.state.propsbool) { this.state.imageUrl = globalConfig.avatarHost + "/upload" + nextProps.picUrl; this.state.propsbool = false; } } render() { const imageUrl = this.state.imageUrl; return ( { imageUrl ? : } ); } }; class PicturesWall extends React.Component { constructor(props) { super(props); this.state = { previewVisible: false, propsbool: true, previewImage: '', fileList: [], } } 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) { if (nextProps.lifePhotoList.length && this.state.propsbool) { this.state.fileList = nextProps.lifePhotoList ; this.state.propsbool = false; } } render() { const { previewVisible, previewImage, fileList } = this.state; const uploadButton = (
Upload
); return (
{ this.handleChange(infor) }} fileList={fileList} />
); } }; const PersonFrom = Form.create()(React.createClass({ getData() { this.props.spinState(true); $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/api/user/member", success: function (data) { if (data.data) { let theArr = splitUrl(data.data.lifePhotoUrl, ',', globalConfig.avatarHost + '/upload'); this.setState({ id: data.data.id, nickname: data.data.nickname, theAddress: [data.data.residenceProvince, data.data.residenceCity, data.data.residenceArea], intro: data.data.personalProfile, email: data.data.email, fixTelArea: data.data.fixedTelArea, fixTel: data.data.fixedTel, fixTelExtension: data.data.fixedTelExtension, qq: data.data.qq, personPortraitUrl: data.data.personPortraitUrl, address: data.data.postalAddress, postcode: data.data.postcode, lifePhotoList: theArr }); } }.bind(this), }).always(function () { this.props.spinState(false); }.bind(this)); }, getInitialState() { return { loading: false, livePicUrlArr: [], lifePhotoList: [] }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { //lifePhotoUrl let livePicArr = []; this.state.lifePhotoList.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ livePicArr.push(item.response.data); } }); let lifePhotoUrl = livePicArr.join(","); if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/userInfo", data: { "id": this.state.id, "nickname": values.nickname, "residenceProvince": values.theAddress[0], "residenceCity": values.theAddress[1], "residenceArea": values.theAddress[2], "personPortraitUrl": this.state.avatarUrlData, "lifePhotoUrl": lifePhotoUrl, "personalProfile": values.intro, "email": values.email, "fixedTelArea": this.state.fixTelArea, "fixedTel": this.state.fixTel, "fixedTelExtension": this.state.fixTelExtension, "qq": values.qq, "postalAddress": values.address, "postcode": values.postcode } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); this.getData(); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); } }); }, avatarUrl(e) { this.state.avatarUrlData = e; }, livePicFileList(e) { this.state.lifePhotoList = e; }, componentWillMount() { this.getData(); }, fixTelAreaChange(e) { this.setState({ fixTelArea: e.target.value }); }, fixTelChange(e) { this.setState({ fixTel: e.target.value }); }, fixTelExtensionChange(e) { this.setState({ fixTelExtension: e.target.value }); }, render() { const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 3 }, wrapperCol: { span: 12 }, }; const _me = this; return (
{getFieldDecorator('nickname', { initialValue: this.state.nickname || null })( )} {getFieldDecorator('theAddress', { initialValue: this.state.theAddress || [] })( )} {getFieldDecorator('avatar')( )}

请上传清晰的个人身份证正反面原件照片/扫描件 (不能截图、图片内容要求完整 ),

要求2M 以下的jpg、jpeg格式的图片。该资料不会公开展示,仅作为审核材料使用。

{getFieldDecorator('livePic')( )} {getFieldDecorator('intro', { initialValue: this.state.intro || null })( )}

还可输入{ (() => { if (_me.props.form.getFieldValue('intro') && _me.props.form.getFieldValue('intro').length) { return 1000 - _me.props.form.getFieldValue('intro').length; } else { return 1000; } })() }字/1000

{getFieldDecorator('email', { rules: [{ type: 'email', message: '请输入正确的邮箱地址!', }], initialValue: this.state.email || null })( )} {getFieldDecorator('telephone')(

- -

)}
{getFieldDecorator('qq', { initialValue: this.state.qq || null })( )} {getFieldDecorator('address', { initialValue: this.state.address || null })( )} {getFieldDecorator('postcode', { initialValue: this.state.postcode || null })( )}
); }, })); const Person = React.createClass({ getInitialState() { return { loading: false }; }, spinChange(e) { this.setState({ loading: e }); }, render() { return (

个人资料

) } }); export default Person;