👨🏻‍💻👩🏻‍💻 Use Ant Design like a Pro!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

68 lines
1.4 KiB

import { routerRedux } from 'dva/router';
import { fakeAccountLogin, fakeMobileLogin } from '../services/api';
export default {
namespace: 'login',
state: {
status: undefined,
},
effects: {
*accountSubmit({ payload }, { call, put }) {
yield put({
type: 'changeSubmitting',
payload: true,
});
const response = yield call(fakeAccountLogin, payload);
yield put({
type: 'changeLoginStatus',
payload: response,
});
yield put({
type: 'changeSubmitting',
payload: false,
});
},
*mobileSubmit(_, { call, put }) {
yield put({
type: 'changeSubmitting',
payload: true,
});
const response = yield call(fakeMobileLogin);
yield put({
type: 'changeLoginStatus',
payload: response,
});
yield put({
type: 'changeSubmitting',
payload: false,
});
},
*logout(_, { put }) {
yield put({
type: 'changeLoginStatus',
payload: {
status: false,
},
});
yield put(routerRedux.push('/user/login'));
},
},
reducers: {
changeLoginStatus(state, { payload }) {
return {
...state,
status: payload.status,
type: payload.type,
};
},
changeSubmitting(state, { payload }) {
return {
...state,
submitting: payload,
};
},
},
};