|
|
'use strict'
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
import ReactNative, {
|
|
|
StyleSheet,
|
|
|
Dimensions,
|
|
|
Platform,
|
|
|
View,
|
|
|
Text,
|
|
|
NativeModules,
|
|
|
InteractionManager,
|
|
|
NativeAppEventEmitter,
|
|
|
} from 'react-native'
|
|
|
|
|
|
import {bindActionCreators} from 'redux';
|
|
|
import {connect} from 'react-redux';
|
|
|
import {Map} from 'immutable';
|
|
|
import * as newArrivalActions from '../reducers/newArrival/newArrivalActions';
|
|
|
import LoadingIndicator from '../../common/components/LoadingIndicator';
|
|
|
|
|
|
import RecommendForYou from '../components/newArrival/RecommendForYou';
|
|
|
|
|
|
|
|
|
const actions = [
|
|
|
newArrivalActions,
|
|
|
];
|
|
|
|
|
|
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 NewArrivalContainer extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this._onPressShop = this._onPressShop.bind(this);
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
this.props.actions.getRecommendBrand();
|
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
|
}
|
|
|
|
|
|
_onPressShop(data) {
|
|
|
let {
|
|
|
shop_name,
|
|
|
shops_id,
|
|
|
} = data;
|
|
|
if (!shops_id||!shop_name) {
|
|
|
return;
|
|
|
}
|
|
|
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shops_id}","shop_template_type":"1","shop_name":"${shop_name}"}}`;
|
|
|
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let {newArrival} = this.props;
|
|
|
|
|
|
let {recommendForYou} = newArrival;
|
|
|
let isFetching = recommendForYou.get('isFetching');
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<RecommendForYou
|
|
|
RecommendForYou={RecommendForYou}
|
|
|
onPressShop={this._onPressShop}
|
|
|
/>
|
|
|
<LoadingIndicator
|
|
|
isVisible={isFetching}
|
|
|
/>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(NewArrivalContainer); |
...
|
...
|
|