Authored by 孙凯

add 礼包模块 review by daiqiang

... ... @@ -29,6 +29,8 @@ import Order from './order/Order'
import Recorder from './recorder/Recorder'
import Installment from './installment/Installment'
import Setting from './setting/Setting'
import AssociatorGift from './associatorGift/AssociatorGift'
console.disableYellowBox = true
... ... @@ -57,7 +59,8 @@ export default function native(platform) {
Installment(platform);
PersonalInfo(platform);
Setting(platform);
AssociatorGift(platform);
if (Platform.OS === 'ios') {
// Community(platform);
QRCode(platform);
... ...
'use strict';
import React from 'react';
import ReactNative, {
AppRegistry,
Platform,
StyleSheet,
Dimensions,
TouchableOpacity,
} from 'react-native';
import {
Provider,
connect
} from 'react-redux';
import configureStore from './store/configureStore';
import {Record, List, Map} from 'immutable';
import appInitialState from './reducers/app/appInitialState';
import associatorGiftInitialState from './reducers/associatorGift/associatorGiftInitialState';
import AssociatorGiftContainer from './containers/AssociatorGiftContainer';
import {
setPlatform,
setChannel,
setHost,
} from './reducers/app/appActions';
function getInitialState() {
const _initState = {
app: (new appInitialState()),
associatorGift: (new associatorGiftInitialState()),
};
return _initState;
}
export default function native(platform) {
let YH_AssociatorGift = React.createClass({
render() {
const store = configureStore(getInitialState());
store.dispatch(setPlatform(platform));
let channel = this.props.channel;
channel && store.dispatch(setChannel(channel));
store.dispatch(setHost(this.props.host));
return (
<Provider store={store}>
<AssociatorGiftContainer />
</Provider>
);
}
});
AppRegistry.registerComponent('YH_AssociatorGift', () => YH_AssociatorGift);
}
let styles = StyleSheet.create({
});
... ...
'use strict'
import React, {Component} from 'react';
import {
StyleSheet,
Dimensions,
Platform,
View,
Text,
Image,
ListView,
TouchableOpacity,
} from 'react-native';
import {Map} from 'immutable';
export default class AssociatorGift extends Component {
constructor(props) {
super(props);
}
render() {
let {
demo,
} = this.props;
return (
<View style={styles.container}>
<Text>aaaaaaaaaaaaa</Text>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
},
});
... ...
import keyMirror from 'key-mirror';
export default keyMirror({
SET_PLATFORM: null,
SET_HOST: null,
SET_CHANNEL: null,
});
... ...
'use strict'
import React, {Component} from 'react';
import ReactNative, {
StyleSheet,
Platform,
InteractionManager,
NativeAppEventEmitter,
} from 'react-native'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import * as associatorGiftActions from '../reducers/associatorGift/associatorGiftActions';
import AssociatorGift from '../components/AssociatorGift';
const actions = [
associatorGiftActions,
];
function mapStateToProps(state) {
return {
...state
};
}
function mapDispatchToProps(dispatch) {
const creators = Map()
.merge(...actions)
.filter(value => typeof value === 'function')
.toObject();
return {
actions: bindActionCreators(creators, dispatch),
dispatch
};
}
class AssociatorGiftContainer extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
}
componentWillUnmount() {
}
render() {
let {
demo
} = this.props.associatorGift;
return (
<AssociatorGift />
);
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(AssociatorGiftContainer);
... ...
'use strict';
import ReactNative from 'react-native';
const {
SET_PLATFORM,
SET_CHANNEL,
SET_HOST,
} = require('../../constants/actionTypes').default;
export function setPlatform(platform) {
return {
type: SET_PLATFORM,
payload: platform
};
}
export function setChannel(channel) {
return {
type: SET_CHANNEL,
payload: channel
};
}
export function setHost(host) {
return {
type: SET_HOST,
payload: host,
}
}
... ...
'use strict';
import {Record, List, Map} from 'immutable';
let InitialState = Record({
platform: 'ios', // ios, android
channel: 1, // 1 - boy, 2 - girl, 3 - kid, 4 - lifestyle, 5 - yoho
host:'api.yoho.cn',
});
export default InitialState;
... ...
'use strict';
import InitialState from './appInitialState';
const {
SET_PLATFORM,
SET_CHANNEL,
SET_HOST,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function appReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case SET_PLATFORM:
return state.set('platform', action.payload);
case SET_CHANNEL:
return state.set('channel', action.payload);
case SET_HOST:
return state.set('host', action.payload);
break;
}
return state;
}
... ...
'use strict';
import ReactNative from 'react-native';
import CouponService from '../../services/AssociatorGiftService';
const Platform = require('Platform');
const {
SET_HOST,
} = require('../../constants/actionTypes').default;
... ...
'use strict';
import {Record, List, Map} from 'immutable';
let InitialState = Record({
demo: 1,
});
export default InitialState;
... ...
'use strict';
import InitialState from './associatorGiftInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_HOST,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function couponReducer(state=initialState, action) {
switch(action.type) {
}
return state;
}
... ...
import {combineReducers} from 'redux';
import app from './app/appReducer';
import associatorGift from './associatorGift/associatorGiftReducer';
const rootReducer = combineReducers({
app,
associatorGift,
});
export default rootReducer;
... ...
'use strict';
import Request from '../../common/services/NativeRequest';
export default class AssociatorGiftService {
constructor (host) {
let baseURL = 'http://api.yoho.cn';
if(host){
baseURL = host;
}
this.api = new Request(baseURL);
}
}
... ...
/**
* # configureStore.js
*
* A Redux boilerplate setup
*
*/
'use strict';
/**
* ## Imports
*
* redux functions
*/
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
/**
* ## Reducer
* The reducer contains the 4 reducers from
* device, global, auth, profile
*/
import reducer from '../reducers';
const logger = createLogger({
predicate: (getState, action) => process.env.NODE_ENV === `development`
});
/**
* ## creatStoreWithMiddleware
* Like the name...
*/
const createStoreWithMiddleware = applyMiddleware(
thunk,
logger
)(createStore);
/**
* ## configureStore
* @param {Object} the state with for keys:
* device, global, auth, profile
*
*/
export default function configureStore(initialState) {
return createStoreWithMiddleware(reducer, initialState);
};
... ...