Skip to content

Commit f088fd1

Browse files
author
xujie3949
committed
整理目录结构,添加fetch库
1 parent c23f9f0 commit f088fd1

File tree

20 files changed

+268
-92
lines changed

20 files changed

+268
-92
lines changed

index.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
* @flow
55
*/
66
import { AppRegistry } from 'react-native';
7-
import app from './app'
7+
import app from './src/containers/android/app'
88

99
AppRegistry.registerComponent('wechatArticle', () => app);

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
"start": "node node_modules/react-native/local-cli/cli.js start"
77
},
88
"dependencies": {
9+
"babel-polyfill": "^6.9.1",
10+
"isomorphic-fetch": "^2.2.1",
911
"react": "15.2.1",
1012
"react-native": "0.30.0",
1113
"react-native-button": "^1.6.0",
1214
"react-native-router-flux": "^3.31.2",
1315
"react-redux": "^4.4.5",
1416
"redux": "^3.5.2",
15-
"redux-actions": "^0.10.1"
17+
"redux-actions": "^0.10.1",
18+
"redux-thunk": "^2.1.0"
1619
}
1720
}

src/actions/loginAction.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/actions/loginActions.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Created by wangtun on 2016/7/21.
3+
*/
4+
import { createAction } from 'redux-actions';
5+
import loginActionEnum from '../constants/loginActionEnum'
6+
7+
const loginActions = {
8+
login: createAction(loginActionEnum.LOGIN_REQUEST)
9+
};
10+
11+
export default loginActions;

src/apis/api.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { fetchMethod, createFetch } from '../fetch/fetch'
2+
import appConfig from '../constants/appConfig'
3+
4+
const api = {
5+
test: (parameter)=> createFetch(
6+
`${appConfig.serviceRoot}service/man/userInfo/login`,
7+
fetchMethod.Get,
8+
{parameter: parameter}
9+
)
10+
};
11+
12+
function callApi(api, success, fail){
13+
api.then(response=> {
14+
if (response.ok) {
15+
return response;
16+
} else {
17+
throw new Error(`网络错误:${response.status}`);
18+
}
19+
})
20+
.then(response=>response.json())
21+
.then(jsonResult=> {
22+
if (jsonResult.errcode === 0) {
23+
if (success) {
24+
const data = jsonResult.data;
25+
success(data);
26+
}
27+
} else {
28+
throw new Error(`服务器错误:${jsonResult.errmsg}`);
29+
}
30+
})
31+
.catch(error=> {
32+
if (fail) {
33+
fail(error.message);
34+
}
35+
})
36+
}
37+
38+
export {
39+
api,
40+
callApi
41+
};
42+
File renamed without changes.
File renamed without changes.

src/constants/actionEnum.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/constants/appConfig.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const appConfig = {
2+
serviceRoot: 'http://192.168.4.188:9000/'
3+
};
4+
5+
export default appConfig;

src/constants/loginActionEnum.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Created by wangtun on 2016/7/21.
3+
*/
4+
const loginActionEnum = {
5+
LOGIN_REQUEST: 'LOGIN_REQUEST'
6+
};
7+
8+
export default loginActionEnum;

0 commit comments

Comments
 (0)