关于ant-design-pro与Java后台+mysql数据库实现简单的登录注册
这是我登录和注册写在service/api⾥⾯的⽅法
// 登录⽅法 才⽤POST⽅法 /server/api/代表的是之前的设置好的地址根据情况⽽定,static/user/login是后台接⼝
export async function fakeAccountLogin(params) {
return request(’/server/api/static/user/login’, {
method: ‘POST’,
body: params,
});
}
// 注册⽅法,与登录⼀样
export async function fakeRegister(params) {
return request(’/server/api/static/user/register’, {
method: ‘POST’,
body: params,
});
}
注册中的模型代码
import { fakeRegister } from ‘@/services/api’;
import { setAuthority } from ‘@/utils/authority’;
import { reloadAuthorized } from ‘@/utils/Authorized’;
export default {
namespace: ‘register’,
state: {
status: undefined,
},
effects: {
* submit({ payload }, { call, put }) {
const response = yield call(fakeRegister, payload);
yield put({
type: ‘registerHandle’,
payload: response,
});
},
},
reducers: {
registerHandle(state, action) {
let items= action.payload
console.log(action.payload)
//console.log(sult))
sult===1) {
return { status:'ok' };
}else {
return { status:'false' };
}
return {
...state,
status: {
...state.status,
...action.payload,
}
};
},
},
};
注册页⾯代码
import React, { Component } from ‘react’;
import { connect } from ‘dva’;
import { formatMessage, FormattedMessage } from ‘umi/locale’;
import Link from ‘umi/link’;
import router from ‘umi/router’;
import { Form, Input, Button, Select, Row, Col, Popover, Progress, message } from ‘antd’; import styles from ‘./Register.less’;
const FormItem = Form.Item;
const { Option } = Select;
const InputGroup = Input.Group;
const passwordStatusMap = {
ok: (
),
pass: (
),
poor: (
),
};
const passwordProgressMap = {
ok: ‘success’,
pass: ‘normal’,
poor: ‘exception’,
};
@connect(({ register, loading }) => ({
register,
submitting: loading.effects[‘register/submit’],
}))
@ate()
class Register extends Component {
state = {
count: 0,
confirmDirty: false,
visible: false,
help: ‘’,
prefix: ‘86’,
};
componentDidUpdate() {
const { form, register } = this.props;
if (register.status === 'ok') {
router.push({
pathname: '/user/register-result',
});
}
distinctly的形容词形式
if (register.status === 'false') {
router.push({
html5官方
pathname: '/user/register-result-false',
});
}
}
componentWillUnmount() {
clearInterval(this.interval);
}
// 验证码倒计时
手机mysql安装配置教程
onGetCaptcha = () => {
let count = 59;
this.setState({ count });
this.interval = setInterval(() => {
count -= 1;
this.setState({ count });
if (count === 0) {
clearInterval(this.interval);
}
}, 1000);
};
// 密码长度验证
getPasswordStatus = () => {
const { form } = this.props;
const value = FieldValue(‘password’); if (value && value.length > 9) {
return ‘ok’;
}
if (value && value.length > 5) {
return ‘pass’;
}
return ‘poor’;
};
// 提交信息
handleSubmit = e => {
e.preventDefault();
const { form, dispatch,register } = this.props; form.validateFields({ force: true }, (err, values) => { if (!err) {
const { prefix } = this.state;
dispatch({
type: ‘register/submit’,
payload: {
…values,
prefix,
},
});
}
});
};
handleConfirmBlur = e => {
const { value } = e.target;
const { confirmDirty } = this.state;
this.setState({ confirmDirty: confirmDirty || !!value });
};
// 检验两次密码是否⼀致
checkConfirm = (rule, value, callback) => {
const { form } = this.props;
if (value && value !== FieldValue(‘password’)) { callback(formatMessage({ id: ‘validation.password.twice’ })); } else {
callback();
}
fseek的功能};
// 检验两次密码是否⼀致
checkPassword = (rule, value, callback) => {
jquery循环遍历对象const { visible, confirmDirty } = this.state;
if (!value) {
this.setState({
help: formatMessage({ id: ‘quired’ }), visible: !!value,
});
callback(‘error’);
} else {
this.setState({
help: ‘’,
});
if (!visible) {
this.setState({
visible: !!value,
});
}
if (value.length < 6) {
callback(‘error’);
} else {
const { form } = this.props;
if (value && confirmDirty) {
form.validateFields([‘confirm’], { force: true });
}
callback();
}
}
};
>原码反码补码是干嘛的

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。