bug fix
This commit is contained in:
@@ -32,23 +32,25 @@ export interface CheckModelState {
|
||||
codeTimer: number;
|
||||
}
|
||||
|
||||
const initState: CheckModelState = {
|
||||
pageState: PageState.Pending,
|
||||
pageStep: PageStep.Check,
|
||||
areacodes: [],
|
||||
areacode: undefined,
|
||||
phone: '',
|
||||
password: '',
|
||||
pwdConfirm: '',
|
||||
inviter: '',
|
||||
verifyCode: '',
|
||||
submitting: false,
|
||||
sendingCode: false,
|
||||
codeTimer: -1,
|
||||
};
|
||||
|
||||
const model: Model = {
|
||||
namespace: 'check',
|
||||
|
||||
state: {
|
||||
pageState: PageState.Pending,
|
||||
pageStep: PageStep.Check,
|
||||
areacodes: [],
|
||||
areacode: undefined,
|
||||
phone: '',
|
||||
password: '',
|
||||
pwdConfirm: '',
|
||||
inviter: '',
|
||||
verifyCode: '',
|
||||
submitting: false,
|
||||
sendingCode: false,
|
||||
codeTimer: -1,
|
||||
} as CheckModelState,
|
||||
state: initState,
|
||||
|
||||
effects: {
|
||||
*back(_, { select, put }) {
|
||||
@@ -123,7 +125,7 @@ const model: Model = {
|
||||
}
|
||||
},
|
||||
|
||||
*submitLogin(_, { put, call, select }) {
|
||||
*submitLogin(_, { put, call, select, all }) {
|
||||
const { areacode, phone, password } = 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' }));
|
||||
@@ -135,16 +137,20 @@ const model: Model = {
|
||||
yield put({ type: 'user/updateToken', payload: token });
|
||||
yield delay(10);
|
||||
const user = yield call(getUserInfo, true);
|
||||
yield put({ type: 'user/updateUser', payload: user });
|
||||
yield all([
|
||||
put({ type: 'user/updateUser', payload: user }),
|
||||
put({ type: 'onUpdateState', ...initState }),
|
||||
]);
|
||||
} catch(e) {
|
||||
message.error(e.message);
|
||||
yield put({ type: 'user/logout' });
|
||||
} finally {
|
||||
yield put({ type: 'onUpdateState', submitting: false });
|
||||
yield all([
|
||||
put({ type: 'user/logout' }),
|
||||
put({ type: 'onUpdateState', submitting: false }),
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
||||
*submitRegister(_, { put, select, call }) {
|
||||
*submitRegister(_, { put, select, call, all }) {
|
||||
const { areacode, phone, password, verifyCode, inviter, 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' }));
|
||||
@@ -159,12 +165,16 @@ const model: Model = {
|
||||
yield put({ type: 'user/updateToken', payload: token });
|
||||
yield delay(10);
|
||||
const user = yield call(getUserInfo, true);
|
||||
yield put({ type: 'user/updateUser', payload: user });
|
||||
yield all([
|
||||
put({ type: 'user/updateUser', payload: user }),
|
||||
put({ type: 'onUpdateState', ...initState }),
|
||||
]);
|
||||
} catch(e) {
|
||||
message.error(e.message);
|
||||
yield put({ type: 'user/logout' });
|
||||
} finally {
|
||||
yield put({ type: 'onUpdateState', submitting: false });
|
||||
yield all([
|
||||
put({ type: 'user/logout' }),
|
||||
put({ type: 'onUpdateState', submitting: false }),
|
||||
]);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user