Authored by 于良

新品到着b版优化 review by liben

... ... @@ -724,7 +724,6 @@ export default class Home extends Component {
this.props.onRefresh && this.props.onRefresh();
}}
onEndReached={() => {
console.log('onEndReachedonEndReachedonEndReached')
this.props.onEndReached && this.props.onEndReached();
}}
renderFooter={this._renderFooter}
... ... @@ -763,9 +762,6 @@ export default class Home extends Component {
}}
renderFooter={this._renderFooter}
onScroll={this._onScroll}
onChangeVisibleRows={this._onChangeVisibleRows}
onMomentumScrollBegin={this._onMomentumScrollBegin}
onMomentumScrollEnd={this._onMomentumScrollEnd}
/>
}
... ...
... ... @@ -9,6 +9,7 @@ import ReactNative, {
StyleSheet,
Dimensions,
TouchableOpacity,
TouchableHighlight,
InteractionManager,
Platform,
} from 'react-native';
... ... @@ -32,12 +33,8 @@ export default class NewArrival extends Component {
super(props);
this._renderRow = this._renderRow.bind(this);
this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
this._renderSectionHeader = this._renderSectionHeader.bind(this);
this._onPressProductFilter = this._onPressProductFilter.bind(this);
this._onChangeVisibleRows = this._onChangeVisibleRows.bind(this);
this._onMomentumScrollBegin = this._onMomentumScrollBegin.bind(this);
this._onMomentumScrollEnd = this._onMomentumScrollEnd.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
... ... @@ -46,26 +43,11 @@ export default class NewArrival extends Component {
this.state = {
showBackToTopButton: false,
selectedVisibleIndex: -1,
scrollEnd: false,
}
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
}
trigggePullToRefresh() {
if (Platform.OS === 'ios') {
InteractionManager.runAfterInteractions(() => {
this.listView && this.listView.getScrollResponder().startPullToRefresh();
});
} else {
this.props.onRefresh && this.props.onRefresh();
}
}
_onPressProductFilter(value){
... ... @@ -256,10 +238,7 @@ export default class NewArrival extends Component {
productList,
} = this.props;
let similarIndex = productList.get('similarIndex');
let showSimilarGuider = this.props.showSimilarGuider
&& this.state.scrollEnd
&& rowID == this.state.selectedVisibleIndex
&& rowID != similarIndex;
return (
<BrandProductListCell
style={[styles.listContainer, customStyle]}
... ... @@ -270,7 +249,6 @@ export default class NewArrival extends Component {
onPressProduct={this.props.onPressProductListProduct}
onLongPressProduct={this.props.onLongPressProduct}
onPressFindSimilar={this.props.onPressFindSimilar}
showSimilarGuider={showSimilarGuider}
/>
);
}
... ... @@ -325,37 +303,6 @@ export default class NewArrival extends Component {
return null;
}
_onChangeVisibleRows(visibleRows, changedRows) {
if (Object.keys(visibleRows).length == 0) {
return;
}
let selectedIndex = -1;
let sectionIDs = Object.keys(visibleRows);
let targetSection = 'latest';
if (!sectionIDs.includes(targetSection)) {
return;
}
let rowIndexs = Object.keys(visibleRows[targetSection]);
if (rowIndexs.length > 0) {
selectedIndex = rowIndexs[0];
}
if (rowIndexs.length > 3) {
selectedIndex = rowIndexs[2];
}
this.setState({selectedVisibleIndex: selectedIndex});
}
_onMomentumScrollBegin(event) {
this.setState({scrollEnd: false});
}
_onMomentumScrollEnd(event) {
this.setState({scrollEnd: true});
}
render() {
let {
... ... @@ -396,7 +343,6 @@ export default class NewArrival extends Component {
renderRow={this._renderRow}
enableEmptySections={true}
renderSectionHeader={this._renderSectionHeader}
removeClippedSubviews={true}
renderFooter={()=>{
if (endReached) {
return <View style={styles.placeholder} />;
... ... @@ -422,6 +368,7 @@ export default class NewArrival extends Component {
this.setState({showBackToTopButton: true});
}
}}
onEndReachedThreshold={2000}
/>
{productList.isFilter ?
<NewArrivalCategoryList
... ... @@ -443,14 +390,21 @@ export default class NewArrival extends Component {
onPressCloseMoreFilter={this.props.onPressCloseMoreFilter}
onPressMoreFilter={this.props.onPressMoreFilter}/> : null}
{this.state.showBackToTopButton?
<TouchableOpacity
style={styles.backToTopButton}
onPress={()=>{
this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
this.setState({showBackToTopButton: false});
}}>
<TouchableHighlight
style={styles.backToTopButton}
activeOpacity={1}
delayLongPress={1000000}
onPress={() =>{
this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
this.setState({showBackToTopButton: false});
}}
onLongPress={() =>{
this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
this.setState({showBackToTopButton: false});
}}
>
<Image style={{flex:1}} source={require('../../image/backtop.png')}/>
</TouchableOpacity>: null
</TouchableHighlight>: null
}
<LoadingIndicator
... ...
... ... @@ -299,12 +299,13 @@ class NewArrivalContainer extends Component {
shops_id,
brand_id,
shop_template_type,
is_red_shop,
} = data.toJS();
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":"${shop_template_type}","shop_name":"${shop_name}"}}`;
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shops_id}","shop_template_type":"${shop_template_type}","shop_name":"${shop_name}","is_red_shop":"${is_red_shop}","brand_id":"${brand_id}"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
let I_INDEX = parseInt(index) + 1;
... ... @@ -340,12 +341,13 @@ class NewArrivalContainer extends Component {
shops_id,
brand_id,
shop_template_type,
is_red_shop,
} = data.toJS();
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":"${shop_template_type}","shop_name":"${shop_name}"}}`;
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shops_id}","shop_template_type":"${shop_template_type}","shop_name":"${shop_name}","is_red_shop":"${is_red_shop}","brand_id":"${brand_id}"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
let I_INDEX = parseInt(index) + 1;
... ...
... ... @@ -68,6 +68,7 @@ class NewArrivalContainer extends Component {
F_NM,
I_INDEX,
shop_template_type,
is_red_shop,
} = data;
if (!shops_id||!shop_name) {
return;
... ... @@ -84,7 +85,7 @@ class NewArrivalContainer extends Component {
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_NEW_ARRIVAL_RECOMMEND_FLR_C', param);
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shops_id}","shop_template_type":"${shop_template_type}","shop_name":"${shop_name}"}}`;
let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.shop","params":{"shop_id":"${shops_id}","shop_template_type":"${shop_template_type}","shop_name":"${shop_name}","is_red_shop":"${is_red_shop}","brand_id":"${brand_id}"}}`;
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
... ...