Commit 907f1a5c authored by ddcat1115's avatar ddcat1115

fix register page mobile style

parent 0a462242
...@@ -30,7 +30,8 @@ export default class Register extends Component { ...@@ -30,7 +30,8 @@ export default class Register extends Component {
confirmDirty: false, confirmDirty: false,
visible: false, visible: false,
help: '', help: '',
} prefix: '86',
};
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (nextProps.register.status === 'ok') { if (nextProps.register.status === 'ok') {
...@@ -52,7 +53,7 @@ export default class Register extends Component { ...@@ -52,7 +53,7 @@ export default class Register extends Component {
clearInterval(this.interval); clearInterval(this.interval);
} }
}, 1000); }, 1000);
} };
getPasswordStatus = () => { getPasswordStatus = () => {
const { form } = this.props; const { form } = this.props;
...@@ -64,26 +65,27 @@ export default class Register extends Component { ...@@ -64,26 +65,27 @@ export default class Register extends Component {
return 'pass'; return 'pass';
} }
return 'pool'; return 'pool';
} };
handleSubmit = (e) => { handleSubmit = (e) => {
e.preventDefault(); e.preventDefault();
this.props.form.validateFields({ force: true }, this.props.form.validateFields({ force: true }, (err, values) => {
(err, values) => { if (!err) {
if (!err) { this.props.dispatch({
this.props.dispatch({ type: 'register/submit',
type: 'register/submit', payload: {
payload: values, ...values,
}); prefix: this.state.prefix,
} },
});
} }
); });
} };
handleConfirmBlur = (e) => { handleConfirmBlur = (e) => {
const { value } = e.target; const { value } = e.target;
this.setState({ confirmDirty: this.state.confirmDirty || !!value }); this.setState({ confirmDirty: this.state.confirmDirty || !!value });
} };
checkConfirm = (rule, value, callback) => { checkConfirm = (rule, value, callback) => {
const { form } = this.props; const { form } = this.props;
...@@ -92,7 +94,7 @@ export default class Register extends Component { ...@@ -92,7 +94,7 @@ export default class Register extends Component {
} else { } else {
callback(); callback();
} }
} };
checkPassword = (rule, value, callback) => { checkPassword = (rule, value, callback) => {
if (!value) { if (!value) {
...@@ -120,13 +122,19 @@ export default class Register extends Component { ...@@ -120,13 +122,19 @@ export default class Register extends Component {
callback(); callback();
} }
} }
} };
changePrefix = (value) => {
this.setState({
prefix: value,
});
};
renderPasswordProgress = () => { renderPasswordProgress = () => {
const { form } = this.props; const { form } = this.props;
const value = form.getFieldValue('password'); const value = form.getFieldValue('password');
const passwordStatus = this.getPasswordStatus(); const passwordStatus = this.getPasswordStatus();
return value && value.length ? return value && value.length ? (
<div className={styles[`progress-${passwordStatus}`]}> <div className={styles[`progress-${passwordStatus}`]}>
<Progress <Progress
status={passwordProgressMap[passwordStatus]} status={passwordProgressMap[passwordStatus]}
...@@ -135,27 +143,31 @@ export default class Register extends Component { ...@@ -135,27 +143,31 @@ export default class Register extends Component {
percent={value.length * 10 > 100 ? 100 : value.length * 10} percent={value.length * 10 > 100 ? 100 : value.length * 10}
showInfo={false} showInfo={false}
/> />
</div> : null; </div>
} ) : null;
};
render() { render() {
const { form, register } = this.props; const { form, register } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const { count } = this.state; const { count, prefix } = this.state;
return ( return (
<div className={styles.main}> <div className={styles.main}>
<h3>注册</h3> <h3>注册</h3>
<Form onSubmit={this.handleSubmit}> <Form onSubmit={this.handleSubmit}>
<FormItem> <FormItem>
{getFieldDecorator('mail', { {getFieldDecorator('mail', {
rules: [{ rules: [
required: true, message: '请输入邮箱地址!', {
}, { required: true,
type: 'email', message: '邮箱地址格式错误!', message: '请输入邮箱地址!',
}], },
})( {
<Input size="large" placeholder="邮箱" /> type: 'email',
)} message: '邮箱地址格式错误!',
},
],
})(<Input size="large" placeholder="邮箱" />)}
</FormItem> </FormItem>
<FormItem help={this.state.help}> <FormItem help={this.state.help}>
<Popover <Popover
...@@ -163,7 +175,9 @@ export default class Register extends Component { ...@@ -163,7 +175,9 @@ export default class Register extends Component {
<div style={{ padding: '4px 0' }}> <div style={{ padding: '4px 0' }}>
{passwordStatusMap[this.getPasswordStatus()]} {passwordStatusMap[this.getPasswordStatus()]}
{this.renderPasswordProgress()} {this.renderPasswordProgress()}
<div style={{ marginTop: 10 }}>请至少输入 6 个字符请不要使用容易被猜到的密码</div> <div style={{ marginTop: 10 }}>
请至少输入 6 个字符请不要使用容易被猜到的密码
</div>
</div> </div>
} }
overlayStyle={{ width: 240 }} overlayStyle={{ width: 240 }}
...@@ -171,9 +185,11 @@ export default class Register extends Component { ...@@ -171,9 +185,11 @@ export default class Register extends Component {
visible={this.state.visible} visible={this.state.visible}
> >
{getFieldDecorator('password', { {getFieldDecorator('password', {
rules: [{ rules: [
validator: this.checkPassword, {
}], validator: this.checkPassword,
},
],
})( })(
<Input <Input
size="large" size="large"
...@@ -185,57 +201,59 @@ export default class Register extends Component { ...@@ -185,57 +201,59 @@ export default class Register extends Component {
</FormItem> </FormItem>
<FormItem> <FormItem>
{getFieldDecorator('confirm', { {getFieldDecorator('confirm', {
rules: [{ rules: [
required: true, message: '请确认密码!', {
}, { required: true,
validator: this.checkConfirm, message: '请确认密码!',
}], },
})( {
<Input validator: this.checkConfirm,
size="large" },
type="password" ],
placeholder="确认密码" })(<Input size="large" type="password" placeholder="确认密码" />)}
/>
)}
</FormItem> </FormItem>
<FormItem> <FormItem>
<InputGroup size="large" className={styles.mobileGroup} compact> <InputGroup compact>
<FormItem style={{ width: '20%' }}> <Select
{getFieldDecorator('prefix', { size="large"
initialValue: '86', value={prefix}
})( onChange={this.changePrefix}
<Select size="large"> style={{ width: '20%' }}
<Option value="86">+86</Option> >
<Option value="87">+87</Option> <Option value="86">+86</Option>
</Select> <Option value="87">+87</Option>
)} </Select>
</FormItem> {getFieldDecorator('mobile', {
<FormItem style={{ width: '80%' }}> rules: [
{getFieldDecorator('mobile', { {
rules: [{ required: true,
required: true, message: '请输入手机号!', message: '请输入手机号!',
}, { },
pattern: /^1\d{10}$/, message: '手机号格式错误!', {
}], pattern: /^1\d{10}$/,
})( message: '手机号格式错误!',
<Input placeholder="11位手机号" /> },
)} ],
</FormItem> })(
<Input
size="large"
style={{ width: '80%' }}
placeholder="11位手机号"
/>
)}
</InputGroup> </InputGroup>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Row gutter={8}> <Row gutter={8}>
<Col span={16}> <Col span={16}>
{getFieldDecorator('captcha', { {getFieldDecorator('captcha', {
rules: [{ rules: [
required: true, message: '请输入验证码!', {
}], required: true,
})( message: '请输入验证码!',
<Input },
size="large" ],
placeholder="验证码" })(<Input size="large" placeholder="验证码" />)}
/>
)}
</Col> </Col>
<Col span={8}> <Col span={8}>
<Button <Button
...@@ -250,10 +268,18 @@ export default class Register extends Component { ...@@ -250,10 +268,18 @@ export default class Register extends Component {
</Row> </Row>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Button size="large" loading={register.submitting} className={styles.submit} type="primary" htmlType="submit"> <Button
size="large"
loading={register.submitting}
className={styles.submit}
type="primary"
htmlType="submit"
>
注册 注册
</Button> </Button>
<Link className={styles.login} to="/user/login">使用已有账户登录</Link> <Link className={styles.login} to="/user/login">
使用已有账户登录
</Link>
</FormItem> </FormItem>
</Form> </Form>
</div> </div>
......
...@@ -15,26 +15,6 @@ ...@@ -15,26 +15,6 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
.mobileGroup {
:global {
.ant-form-item {
margin-bottom: 0;
vertical-align: top;
&:first-child .ant-select-selection {
border-right-width: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
&:last-child .ant-input {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
}
}
}
.getCaptcha { .getCaptcha {
display: block; display: block;
width: 100%; width: 100%;
...@@ -50,8 +30,10 @@ ...@@ -50,8 +30,10 @@
} }
} }
.success, .warning, .error { .success,
transition: color .3s; .warning,
.error {
transition: color 0.3s;
} }
.success { .success {
...@@ -73,4 +55,3 @@ ...@@ -73,4 +55,3 @@
} }
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment