-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hiphonezhu
committed
Aug 19, 2016
1 parent
c4fa9d6
commit 393b2b6
Showing
5 changed files
with
55 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
'use strict'; | ||
import * as types from '../constants/ActionTypes'; | ||
|
||
// 模拟服务器返回的用户信息 | ||
let user = { | ||
'name': 'admin', | ||
'age': '24' | ||
} | ||
|
||
export function doLogin() | ||
{ | ||
return dispatch => { | ||
dispatch(isLogining()); | ||
// 模拟用户登录 | ||
let result = fetch('http://www.baidu.com') | ||
let result = fetch('https://github.com/') | ||
.then((res)=>{ | ||
dispatch(loginSuccess(true)); | ||
dispatch(loginSuccess(true, user)); | ||
}).catch((e)=>{ | ||
dispatch(loginSuccess(false)); | ||
dispatch(loginSuccess(false, null)); | ||
}); | ||
} | ||
} | ||
|
||
function isLogining() | ||
{ | ||
return { | ||
type: types.LOGIN_IN | ||
type: types.LOGIN_IN_DOING | ||
} | ||
} | ||
|
||
function loginSuccess(isSuccess) | ||
function loginSuccess(isSuccess, user) | ||
{ | ||
return{ | ||
type: types.LOGIN_IN_COMPLETED, | ||
isSuccess: isSuccess | ||
type: types.LOGIN_IN_DONE, | ||
isSuccess: isSuccess, | ||
user: user | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const LOGIN_IN = 'LOGIN_IN'; | ||
export const LOGIN_IN_COMPLETED = 'LOGIN_IN_COMPLETED'; | ||
export const LOGIN_IN_INIT = 'LOGIN_IN_INIT'; // 初始状态 | ||
export const LOGIN_IN_DOING = 'LOGIN_IN_DOING'; // 正在登陆 | ||
export const LOGIN_IN_DONE = 'LOGIN_IN_DONE'; // 登陆完成 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters