From 1337ca675ff41d7ecfadd34d17c8196b7dc73d63 Mon Sep 17 00:00:00 2001 From: "wenbo.dong" Date: Tue, 18 Jul 2017 10:56:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/ReduxContainer.js | 4 +++- client/actions/login.js | 22 +++++++++++++--------- client/actions/project.js | 2 +- client/reducer/Login/login.js | 1 + client/reducer/group/project.js | 19 +++++++++++++++++++ 5 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 client/reducer/group/project.js diff --git a/client/ReduxContainer.js b/client/ReduxContainer.js index 92ace258..0d284b68 100644 --- a/client/ReduxContainer.js +++ b/client/ReduxContainer.js @@ -1,11 +1,13 @@ import LoginRedux from './reducer/Login/Login_redux.js' import login from './reducer/Login/login.js' import group from './reducer/group/group.js' +import project from './reducer/group/project.js' import Interface from './reducer/Interface/InterfaceReducer.js' export default { group, login, LoginRedux, - Interface + Interface, + project } diff --git a/client/actions/login.js b/client/actions/login.js index be866b50..15becaa3 100644 --- a/client/actions/login.js +++ b/client/actions/login.js @@ -8,14 +8,18 @@ const cookies = new Cookies(); const loginActions = (data) => { return (dispatch) => { - axios.get('/user/login', data).then((res) => { - cookies.set(data.email, data.password); - dispatch({ - type: LOGIN, - payload: { - data: res - } - }); + axios.post('/user/login', data).then((res) => { + if (res.data.data.errcode === 0) { + cookies.set(data.email, data.password); + dispatch({ + type: LOGIN, + payload: { + data: res + } + }); + } else { + console.log('登录失败'); + } }).catch((err) => { console.log(err); }); @@ -30,7 +34,7 @@ const regActions = (data) => { username: data.userName } return () => { - axios.get('/user/login', param).then((res) => { + axios.post('/user/login', param).then((res) => { console.log(res); }).catch((err) => { console.log(err); diff --git a/client/actions/project.js b/client/actions/project.js index 4bbd8e0e..738dcc69 100644 --- a/client/actions/project.js +++ b/client/actions/project.js @@ -15,7 +15,7 @@ const addProject = (data) => { return { type: PROJECT_ADD, // payload 可以返回 Promise,异步请求使用 axios 即可 - payload: axios.get('/project/add', param) + payload: axios.post('/project/add', param) } } diff --git a/client/reducer/Login/login.js b/client/reducer/Login/login.js index c258b49f..a65a0c5b 100644 --- a/client/reducer/Login/login.js +++ b/client/reducer/Login/login.js @@ -13,6 +13,7 @@ const initialState = { export default (state = initialState, action) => { switch (action.type) { case LOGIN: { + console.log(action); return { ...state, isLogin: true, diff --git a/client/reducer/group/project.js b/client/reducer/group/project.js new file mode 100644 index 00000000..0ed8ec16 --- /dev/null +++ b/client/reducer/group/project.js @@ -0,0 +1,19 @@ +import { + PROJECT_ADD +} from '../../constants/action-types'; + +const initialState = { + groupList: [], + currGroup: 'MFE' +}; + +export default (state = initialState, action) => { + switch (action.type) { + case PROJECT_ADD: { + console.log(action.payload); + return state; + } + default: + return state; + } +};