忘记密码
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { Model } from "dva";
|
||||
import _ from 'lodash';
|
||||
import { message } from 'antd';
|
||||
import { message, Modal } from 'antd';
|
||||
import { delay } from 'dva/saga';
|
||||
import { PageState, AreaCode, AreaCodes } from '@/types/common';
|
||||
import { getAreaCodes, getUserInfo } from '@/services/common';
|
||||
import { validPhoneInput, validPwdInput, validPhone, validPwd } from '@/utils/validate';
|
||||
import { checkExistence, CheckResult, signIn, signUp, sendCode } from './service';
|
||||
import { checkExistence, CheckResult, signIn, signUp, sendCode, reset } from './service';
|
||||
import { formatMessage } from 'umi-plugin-locale';
|
||||
import { dispatch } from '@/utils/utils';
|
||||
|
||||
export enum PageStep {
|
||||
Check = 'check',
|
||||
@@ -121,7 +122,7 @@ const model: Model = {
|
||||
try {
|
||||
const token = yield call(signIn, areacode, phone, password);
|
||||
yield put({ type: 'user/updateToken', payload: token });
|
||||
yield delay(0);
|
||||
yield delay(10);
|
||||
const user = yield call(getUserInfo, true);
|
||||
yield put({ type: 'user/updateUser', payload: user });
|
||||
} catch(e) {
|
||||
@@ -145,7 +146,7 @@ const model: Model = {
|
||||
try {
|
||||
const token = yield call(signUp, areacode, phone, password, verifyCode, inviter);
|
||||
yield put({ type: 'user/updateToken', payload: token });
|
||||
yield delay(0);
|
||||
yield delay(10);
|
||||
const user = yield call(getUserInfo, true);
|
||||
yield put({ type: 'user/updateUser', payload: user });
|
||||
} catch(e) {
|
||||
@@ -156,14 +157,38 @@ const model: Model = {
|
||||
}
|
||||
},
|
||||
|
||||
*sendCode(_, { select, put, call }) {
|
||||
*submitReset(_, { put, select, call }) {
|
||||
const { areacode, phone, password, verifyCode, pwdConfirm } = yield select((state: any) => state.check);
|
||||
if (!areacode) return message.warn(formatMessage({ id: 'check.msgArea' }));
|
||||
if (!validPhone(phone)) return message.warn(formatMessage({ id: 'check.msgPhone' }));
|
||||
if (!verifyCode) return message.warn(formatMessage({ id: 'check.msgCode' }));
|
||||
if (!validPwd(password)) return message.warn(formatMessage({ id: 'check.msgPwd' }));
|
||||
if (password !== pwdConfirm) return message.warn(formatMessage({ id: 'check.msgConfirm' }));
|
||||
|
||||
yield put({ type: 'onUpdateState', submitting: true });
|
||||
try {
|
||||
yield call(reset, areacode, phone, password, verifyCode);
|
||||
Modal.success({
|
||||
okText: formatMessage({ id: 'common.iknow' }),
|
||||
title: formatMessage({ id: 'common.prompt' }),
|
||||
content: formatMessage({ id: 'check.resetSuccess' }),
|
||||
onOk: () => dispatch({ type: 'check/back' }),
|
||||
});
|
||||
} catch(e) {
|
||||
message.error(e.message);
|
||||
} finally {
|
||||
yield put({ type: 'onUpdateState', submitting: false });
|
||||
}
|
||||
},
|
||||
|
||||
*sendCode({ payload }, { select, put, call }) {
|
||||
const { areacode, phone } = yield select((state: any) => state.check);
|
||||
if (!areacode) return message.warn(formatMessage({ id: 'check.msgArea' }));
|
||||
if (!validPhone(phone)) return message.warn(formatMessage({ id: 'check.msgPhone' }));
|
||||
|
||||
yield put({ type: 'onUpdateState', sendingCode: true });
|
||||
try {
|
||||
yield call(sendCode, areacode, phone);
|
||||
yield call(sendCode, areacode, phone, payload);
|
||||
yield put({ type: 'timer', payload: 60 });
|
||||
} catch(e) {
|
||||
message.error(e.message);
|
||||
|
||||
Reference in New Issue
Block a user