add 礼包模块 review by daiqiang
Showing
14 changed files
with
364 additions
and
1 deletions
@@ -29,6 +29,8 @@ import Order from './order/Order' | @@ -29,6 +29,8 @@ import Order from './order/Order' | ||
29 | import Recorder from './recorder/Recorder' | 29 | import Recorder from './recorder/Recorder' |
30 | import Installment from './installment/Installment' | 30 | import Installment from './installment/Installment' |
31 | import Setting from './setting/Setting' | 31 | import Setting from './setting/Setting' |
32 | +import AssociatorGift from './associatorGift/AssociatorGift' | ||
33 | + | ||
32 | 34 | ||
33 | console.disableYellowBox = true | 35 | console.disableYellowBox = true |
34 | 36 | ||
@@ -57,7 +59,8 @@ export default function native(platform) { | @@ -57,7 +59,8 @@ export default function native(platform) { | ||
57 | Installment(platform); | 59 | Installment(platform); |
58 | PersonalInfo(platform); | 60 | PersonalInfo(platform); |
59 | Setting(platform); | 61 | Setting(platform); |
60 | - | 62 | + AssociatorGift(platform); |
63 | + | ||
61 | if (Platform.OS === 'ios') { | 64 | if (Platform.OS === 'ios') { |
62 | // Community(platform); | 65 | // Community(platform); |
63 | QRCode(platform); | 66 | QRCode(platform); |
js/associatorGift/AssociatorGift.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative, { | ||
5 | + AppRegistry, | ||
6 | + Platform, | ||
7 | + StyleSheet, | ||
8 | + Dimensions, | ||
9 | + TouchableOpacity, | ||
10 | +} from 'react-native'; | ||
11 | + | ||
12 | +import { | ||
13 | + Provider, | ||
14 | + connect | ||
15 | +} from 'react-redux'; | ||
16 | + | ||
17 | +import configureStore from './store/configureStore'; | ||
18 | +import {Record, List, Map} from 'immutable'; | ||
19 | + | ||
20 | +import appInitialState from './reducers/app/appInitialState'; | ||
21 | +import associatorGiftInitialState from './reducers/associatorGift/associatorGiftInitialState'; | ||
22 | + | ||
23 | +import AssociatorGiftContainer from './containers/AssociatorGiftContainer'; | ||
24 | + | ||
25 | +import { | ||
26 | + setPlatform, | ||
27 | + setChannel, | ||
28 | + setHost, | ||
29 | +} from './reducers/app/appActions'; | ||
30 | + | ||
31 | +function getInitialState() { | ||
32 | + const _initState = { | ||
33 | + app: (new appInitialState()), | ||
34 | + associatorGift: (new associatorGiftInitialState()), | ||
35 | + }; | ||
36 | + return _initState; | ||
37 | +} | ||
38 | + | ||
39 | +export default function native(platform) { | ||
40 | + | ||
41 | + let YH_AssociatorGift = React.createClass({ | ||
42 | + | ||
43 | + render() { | ||
44 | + const store = configureStore(getInitialState()); | ||
45 | + store.dispatch(setPlatform(platform)); | ||
46 | + let channel = this.props.channel; | ||
47 | + channel && store.dispatch(setChannel(channel)); | ||
48 | + store.dispatch(setHost(this.props.host)); | ||
49 | + return ( | ||
50 | + <Provider store={store}> | ||
51 | + <AssociatorGiftContainer /> | ||
52 | + </Provider> | ||
53 | + ); | ||
54 | + } | ||
55 | + }); | ||
56 | + | ||
57 | + AppRegistry.registerComponent('YH_AssociatorGift', () => YH_AssociatorGift); | ||
58 | +} | ||
59 | + | ||
60 | +let styles = StyleSheet.create({ | ||
61 | + | ||
62 | +}); |
1 | +'use strict' | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import { | ||
5 | + StyleSheet, | ||
6 | + Dimensions, | ||
7 | + Platform, | ||
8 | + View, | ||
9 | + Text, | ||
10 | + Image, | ||
11 | + ListView, | ||
12 | + TouchableOpacity, | ||
13 | +} from 'react-native'; | ||
14 | + | ||
15 | +import {Map} from 'immutable'; | ||
16 | + | ||
17 | +export default class AssociatorGift extends Component { | ||
18 | + constructor(props) { | ||
19 | + super(props); | ||
20 | + } | ||
21 | + | ||
22 | + render() { | ||
23 | + let { | ||
24 | + demo, | ||
25 | + } = this.props; | ||
26 | + | ||
27 | + return ( | ||
28 | + <View style={styles.container}> | ||
29 | + <Text>aaaaaaaaaaaaa</Text> | ||
30 | + </View> | ||
31 | + ); | ||
32 | + } | ||
33 | +} | ||
34 | +let {width, height} = Dimensions.get('window'); | ||
35 | +let styles = StyleSheet.create({ | ||
36 | + container: { | ||
37 | + flex: 1, | ||
38 | + }, | ||
39 | +}); |
js/associatorGift/constants/actionTypes.js
0 → 100644
1 | +'use strict' | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import ReactNative, { | ||
5 | + StyleSheet, | ||
6 | + Platform, | ||
7 | + InteractionManager, | ||
8 | + NativeAppEventEmitter, | ||
9 | +} from 'react-native' | ||
10 | + | ||
11 | +import {bindActionCreators} from 'redux'; | ||
12 | +import {connect} from 'react-redux'; | ||
13 | +import {Map} from 'immutable'; | ||
14 | +import * as associatorGiftActions from '../reducers/associatorGift/associatorGiftActions'; | ||
15 | +import AssociatorGift from '../components/AssociatorGift'; | ||
16 | + | ||
17 | +const actions = [ | ||
18 | + associatorGiftActions, | ||
19 | +]; | ||
20 | + | ||
21 | +function mapStateToProps(state) { | ||
22 | + return { | ||
23 | + ...state | ||
24 | + }; | ||
25 | +} | ||
26 | + | ||
27 | +function mapDispatchToProps(dispatch) { | ||
28 | + | ||
29 | + const creators = Map() | ||
30 | + .merge(...actions) | ||
31 | + .filter(value => typeof value === 'function') | ||
32 | + .toObject(); | ||
33 | + | ||
34 | + return { | ||
35 | + actions: bindActionCreators(creators, dispatch), | ||
36 | + dispatch | ||
37 | + }; | ||
38 | +} | ||
39 | + | ||
40 | + | ||
41 | +class AssociatorGiftContainer extends Component { | ||
42 | + constructor(props) { | ||
43 | + super(props); | ||
44 | + } | ||
45 | + | ||
46 | + componentDidMount() { | ||
47 | + | ||
48 | + } | ||
49 | + | ||
50 | + componentWillUnmount() { | ||
51 | + | ||
52 | + } | ||
53 | + | ||
54 | + render() { | ||
55 | + | ||
56 | + let { | ||
57 | + demo | ||
58 | + } = this.props.associatorGift; | ||
59 | + | ||
60 | + return ( | ||
61 | + <AssociatorGift /> | ||
62 | + ); | ||
63 | + } | ||
64 | +} | ||
65 | + | ||
66 | +let styles = StyleSheet.create({ | ||
67 | + container: { | ||
68 | + flex: 1, | ||
69 | + }, | ||
70 | +}); | ||
71 | + | ||
72 | +export default connect(mapStateToProps, mapDispatchToProps)(AssociatorGiftContainer); |
js/associatorGift/reducers/app/appActions.js
0 → 100755
1 | +'use strict'; | ||
2 | + | ||
3 | +import ReactNative from 'react-native'; | ||
4 | + | ||
5 | +const { | ||
6 | + SET_PLATFORM, | ||
7 | + SET_CHANNEL, | ||
8 | + SET_HOST, | ||
9 | +} = require('../../constants/actionTypes').default; | ||
10 | + | ||
11 | +export function setPlatform(platform) { | ||
12 | + return { | ||
13 | + type: SET_PLATFORM, | ||
14 | + payload: platform | ||
15 | + }; | ||
16 | +} | ||
17 | + | ||
18 | +export function setChannel(channel) { | ||
19 | + return { | ||
20 | + type: SET_CHANNEL, | ||
21 | + payload: channel | ||
22 | + }; | ||
23 | +} | ||
24 | + | ||
25 | +export function setHost(host) { | ||
26 | + return { | ||
27 | + type: SET_HOST, | ||
28 | + payload: host, | ||
29 | + } | ||
30 | +} |
js/associatorGift/reducers/app/appReducer.js
0 → 100755
1 | +'use strict'; | ||
2 | + | ||
3 | +import InitialState from './appInitialState'; | ||
4 | + | ||
5 | +const { | ||
6 | + SET_PLATFORM, | ||
7 | + SET_CHANNEL, | ||
8 | + SET_HOST, | ||
9 | +} = require('../../constants/actionTypes').default; | ||
10 | + | ||
11 | +const initialState = new InitialState; | ||
12 | + | ||
13 | +export default function appReducer(state = initialState, action) { | ||
14 | + if (!(state instanceof InitialState)) return initialState.merge(state); | ||
15 | + | ||
16 | + switch (action.type) { | ||
17 | + case SET_PLATFORM: | ||
18 | + return state.set('platform', action.payload); | ||
19 | + case SET_CHANNEL: | ||
20 | + return state.set('channel', action.payload); | ||
21 | + case SET_HOST: | ||
22 | + return state.set('host', action.payload); | ||
23 | + | ||
24 | + break; | ||
25 | + } | ||
26 | + | ||
27 | + return state; | ||
28 | +} |
1 | +'use strict'; | ||
2 | + | ||
3 | +import InitialState from './associatorGiftInitialState'; | ||
4 | +import Immutable, {Map} from 'immutable'; | ||
5 | + | ||
6 | +const { | ||
7 | + SET_HOST, | ||
8 | + | ||
9 | +} = require('../../constants/actionTypes').default; | ||
10 | + | ||
11 | +const initialState = new InitialState; | ||
12 | + | ||
13 | +export default function couponReducer(state=initialState, action) { | ||
14 | + switch(action.type) { | ||
15 | + | ||
16 | + } | ||
17 | + | ||
18 | + return state; | ||
19 | +} |
js/associatorGift/reducers/index.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import Request from '../../common/services/NativeRequest'; | ||
4 | + | ||
5 | +export default class AssociatorGiftService { | ||
6 | + | ||
7 | + constructor (host) { | ||
8 | + let baseURL = 'http://api.yoho.cn'; | ||
9 | + if(host){ | ||
10 | + baseURL = host; | ||
11 | + } | ||
12 | + this.api = new Request(baseURL); | ||
13 | + } | ||
14 | + | ||
15 | +} |
js/associatorGift/store/configureStore.js
0 → 100644
1 | +/** | ||
2 | + * # configureStore.js | ||
3 | + * | ||
4 | + * A Redux boilerplate setup | ||
5 | + * | ||
6 | + */ | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +/** | ||
10 | + * ## Imports | ||
11 | + * | ||
12 | + * redux functions | ||
13 | + */ | ||
14 | +import { createStore, applyMiddleware } from 'redux'; | ||
15 | +import thunk from 'redux-thunk'; | ||
16 | +import createLogger from 'redux-logger'; | ||
17 | + | ||
18 | +/** | ||
19 | +* ## Reducer | ||
20 | +* The reducer contains the 4 reducers from | ||
21 | +* device, global, auth, profile | ||
22 | +*/ | ||
23 | +import reducer from '../reducers'; | ||
24 | + | ||
25 | +const logger = createLogger({ | ||
26 | + predicate: (getState, action) => process.env.NODE_ENV === `development` | ||
27 | +}); | ||
28 | + | ||
29 | +/** | ||
30 | + * ## creatStoreWithMiddleware | ||
31 | + * Like the name... | ||
32 | + */ | ||
33 | +const createStoreWithMiddleware = applyMiddleware( | ||
34 | + thunk, | ||
35 | + logger | ||
36 | +)(createStore); | ||
37 | + | ||
38 | +/** | ||
39 | + * ## configureStore | ||
40 | + * @param {Object} the state with for keys: | ||
41 | + * device, global, auth, profile | ||
42 | + * | ||
43 | + */ | ||
44 | +export default function configureStore(initialState) { | ||
45 | + return createStoreWithMiddleware(reducer, initialState); | ||
46 | +}; |
-
Please register or login to post a comment