import React from 'react'; import { Input, Button, Form, Icon, Spin } from 'antd'; import './base.less'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; const FormItem = Form.Item; import weixin from '../../../../image/weixin-w.png'; import qq from '../../../../image/qq-w.png'; import weibo from '../../../../image/weibo-w.png'; import card1 from '../../../../image/idcard1.jpg'; import card2 from '../../../../image/idcard2.jpg'; const BaseFrom = Form.create()(React.createClass({ getData() { this.props.spinState(true); $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/api/user/base", success: function (data) { if (data.data) { this.setState({ fixTel: data.data.fixedTel, contacts: data.data.contacts, qq: data.data.qq, address: data.data.postalAddress, postcode: data.data.postcode, legalPerson: data.data.legalPerson, email: data.data.email }); }; }.bind(this), }).done(function (data) { if (data.error.length) { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); }, getInitialState() { return { idcard1: '', idcard2: '' }; }, componentWillMount() { this.getData(); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/orgIdentity", data: { "contacts": values.contact, "email": values.email, "fixedTel": values.telephone, "qq": values.qq, "postalAddress": values.address, "postcode": values.postcode, "moblie": values.moblie } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); } }); }, checkidNum(rule, value, callback) { const form = this.props.form; if (value && value !== form.getFieldValue('password')) { callback('Two passwords that you enter is inconsistent!'); } else { callback(); } }, checkUpload(file) { const isJPG = file.type === 'image/jpeg'; if (!isJPG) { callback('You can only upload JPG file!'); } const isLt2M = file.size / 1024 / 1024 < 2; if (!isLt2M) { callback('Image must smaller than 2MB!'); } return isJPG && isLt2M; }, checkPhone(rule, value, callback) { const form = this.props.form; if (!(/^1[34578]\d{9}$/.test(value))) { callback('请输入正确的手机号码!'); } else { callback(); } }, render() { const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 3 }, wrapperCol: { span: 12 }, }; return (
); }, })); const Base = React.createClass({ getInitialState() { return { loading: false, }; }, spinChange(e) { this.setState({ loading: e }); }, render() { return (