Authored by 于良

新品到着b版优化 review by liben

@@ -724,7 +724,6 @@ export default class Home extends Component { @@ -724,7 +724,6 @@ export default class Home extends Component {
724 this.props.onRefresh && this.props.onRefresh(); 724 this.props.onRefresh && this.props.onRefresh();
725 }} 725 }}
726 onEndReached={() => { 726 onEndReached={() => {
727 - console.log('onEndReachedonEndReachedonEndReached')  
728 this.props.onEndReached && this.props.onEndReached(); 727 this.props.onEndReached && this.props.onEndReached();
729 }} 728 }}
730 renderFooter={this._renderFooter} 729 renderFooter={this._renderFooter}
@@ -763,9 +762,6 @@ export default class Home extends Component { @@ -763,9 +762,6 @@ export default class Home extends Component {
763 }} 762 }}
764 renderFooter={this._renderFooter} 763 renderFooter={this._renderFooter}
765 onScroll={this._onScroll} 764 onScroll={this._onScroll}
766 - onChangeVisibleRows={this._onChangeVisibleRows}  
767 - onMomentumScrollBegin={this._onMomentumScrollBegin}  
768 - onMomentumScrollEnd={this._onMomentumScrollEnd}  
769 /> 765 />
770 } 766 }
771 767
@@ -9,6 +9,7 @@ import ReactNative, { @@ -9,6 +9,7 @@ import ReactNative, {
9 StyleSheet, 9 StyleSheet,
10 Dimensions, 10 Dimensions,
11 TouchableOpacity, 11 TouchableOpacity,
  12 + TouchableHighlight,
12 InteractionManager, 13 InteractionManager,
13 Platform, 14 Platform,
14 } from 'react-native'; 15 } from 'react-native';
@@ -32,12 +33,8 @@ export default class NewArrival extends Component { @@ -32,12 +33,8 @@ export default class NewArrival extends Component {
32 super(props); 33 super(props);
33 34
34 this._renderRow = this._renderRow.bind(this); 35 this._renderRow = this._renderRow.bind(this);
35 - this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);  
36 this._renderSectionHeader = this._renderSectionHeader.bind(this); 36 this._renderSectionHeader = this._renderSectionHeader.bind(this);
37 this._onPressProductFilter = this._onPressProductFilter.bind(this); 37 this._onPressProductFilter = this._onPressProductFilter.bind(this);
38 - this._onChangeVisibleRows = this._onChangeVisibleRows.bind(this);  
39 - this._onMomentumScrollBegin = this._onMomentumScrollBegin.bind(this);  
40 - this._onMomentumScrollEnd = this._onMomentumScrollEnd.bind(this);  
41 38
42 this.dataSource = new ListView.DataSource({ 39 this.dataSource = new ListView.DataSource({
43 rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), 40 rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
@@ -46,26 +43,11 @@ export default class NewArrival extends Component { @@ -46,26 +43,11 @@ export default class NewArrival extends Component {
46 43
47 this.state = { 44 this.state = {
48 showBackToTopButton: false, 45 showBackToTopButton: false,
49 - selectedVisibleIndex: -1,  
50 - scrollEnd: false,  
51 } 46 }
52 } 47 }
53 48
54 componentDidMount() { 49 componentDidMount() {
55 - }  
56 -  
57 - componentWillReceiveProps(nextProps) {  
58 -  
59 - }  
60 50
61 - trigggePullToRefresh() {  
62 - if (Platform.OS === 'ios') {  
63 - InteractionManager.runAfterInteractions(() => {  
64 - this.listView && this.listView.getScrollResponder().startPullToRefresh();  
65 - });  
66 - } else {  
67 - this.props.onRefresh && this.props.onRefresh();  
68 - }  
69 } 51 }
70 52
71 _onPressProductFilter(value){ 53 _onPressProductFilter(value){
@@ -256,10 +238,7 @@ export default class NewArrival extends Component { @@ -256,10 +238,7 @@ export default class NewArrival extends Component {
256 productList, 238 productList,
257 } = this.props; 239 } = this.props;
258 let similarIndex = productList.get('similarIndex'); 240 let similarIndex = productList.get('similarIndex');
259 - let showSimilarGuider = this.props.showSimilarGuider  
260 - && this.state.scrollEnd  
261 - && rowID == this.state.selectedVisibleIndex  
262 - && rowID != similarIndex; 241 +
263 return ( 242 return (
264 <BrandProductListCell 243 <BrandProductListCell
265 style={[styles.listContainer, customStyle]} 244 style={[styles.listContainer, customStyle]}
@@ -270,7 +249,6 @@ export default class NewArrival extends Component { @@ -270,7 +249,6 @@ export default class NewArrival extends Component {
270 onPressProduct={this.props.onPressProductListProduct} 249 onPressProduct={this.props.onPressProductListProduct}
271 onLongPressProduct={this.props.onLongPressProduct} 250 onLongPressProduct={this.props.onLongPressProduct}
272 onPressFindSimilar={this.props.onPressFindSimilar} 251 onPressFindSimilar={this.props.onPressFindSimilar}
273 - showSimilarGuider={showSimilarGuider}  
274 /> 252 />
275 ); 253 );
276 } 254 }
@@ -325,37 +303,6 @@ export default class NewArrival extends Component { @@ -325,37 +303,6 @@ export default class NewArrival extends Component {
325 return null; 303 return null;
326 } 304 }
327 305
328 - _onChangeVisibleRows(visibleRows, changedRows) {  
329 - if (Object.keys(visibleRows).length == 0) {  
330 - return;  
331 - }  
332 -  
333 - let selectedIndex = -1;  
334 - let sectionIDs = Object.keys(visibleRows);  
335 - let targetSection = 'latest';  
336 - if (!sectionIDs.includes(targetSection)) {  
337 - return;  
338 - }  
339 -  
340 - let rowIndexs = Object.keys(visibleRows[targetSection]);  
341 - if (rowIndexs.length > 0) {  
342 - selectedIndex = rowIndexs[0];  
343 - }  
344 - if (rowIndexs.length > 3) {  
345 - selectedIndex = rowIndexs[2];  
346 - }  
347 -  
348 - this.setState({selectedVisibleIndex: selectedIndex});  
349 - }  
350 -  
351 - _onMomentumScrollBegin(event) {  
352 - this.setState({scrollEnd: false});  
353 - }  
354 -  
355 - _onMomentumScrollEnd(event) {  
356 - this.setState({scrollEnd: true});  
357 - }  
358 -  
359 render() { 306 render() {
360 307
361 let { 308 let {
@@ -396,7 +343,6 @@ export default class NewArrival extends Component { @@ -396,7 +343,6 @@ export default class NewArrival extends Component {
396 renderRow={this._renderRow} 343 renderRow={this._renderRow}
397 enableEmptySections={true} 344 enableEmptySections={true}
398 renderSectionHeader={this._renderSectionHeader} 345 renderSectionHeader={this._renderSectionHeader}
399 - removeClippedSubviews={true}  
400 renderFooter={()=>{ 346 renderFooter={()=>{
401 if (endReached) { 347 if (endReached) {
402 return <View style={styles.placeholder} />; 348 return <View style={styles.placeholder} />;
@@ -422,6 +368,7 @@ export default class NewArrival extends Component { @@ -422,6 +368,7 @@ export default class NewArrival extends Component {
422 this.setState({showBackToTopButton: true}); 368 this.setState({showBackToTopButton: true});
423 } 369 }
424 }} 370 }}
  371 + onEndReachedThreshold={2000}
425 /> 372 />
426 {productList.isFilter ? 373 {productList.isFilter ?
427 <NewArrivalCategoryList 374 <NewArrivalCategoryList
@@ -443,14 +390,21 @@ export default class NewArrival extends Component { @@ -443,14 +390,21 @@ export default class NewArrival extends Component {
443 onPressCloseMoreFilter={this.props.onPressCloseMoreFilter} 390 onPressCloseMoreFilter={this.props.onPressCloseMoreFilter}
444 onPressMoreFilter={this.props.onPressMoreFilter}/> : null} 391 onPressMoreFilter={this.props.onPressMoreFilter}/> : null}
445 {this.state.showBackToTopButton? 392 {this.state.showBackToTopButton?
446 - <TouchableOpacity  
447 - style={styles.backToTopButton}  
448 - onPress={()=>{  
449 - this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});  
450 - this.setState({showBackToTopButton: false});  
451 - }}> 393 + <TouchableHighlight
  394 + style={styles.backToTopButton}
  395 + activeOpacity={1}
  396 + delayLongPress={1000000}
  397 + onPress={() =>{
  398 + this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
  399 + this.setState({showBackToTopButton: false});
  400 + }}
  401 + onLongPress={() =>{
  402 + this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
  403 + this.setState({showBackToTopButton: false});
  404 + }}
  405 + >
452 <Image style={{flex:1}} source={require('../../image/backtop.png')}/> 406 <Image style={{flex:1}} source={require('../../image/backtop.png')}/>
453 - </TouchableOpacity>: null 407 + </TouchableHighlight>: null
454 } 408 }
455 409
456 <LoadingIndicator 410 <LoadingIndicator
@@ -299,12 +299,13 @@ class NewArrivalContainer extends Component { @@ -299,12 +299,13 @@ class NewArrivalContainer extends Component {
299 shops_id, 299 shops_id,
300 brand_id, 300 brand_id,
301 shop_template_type, 301 shop_template_type,
  302 + is_red_shop,
302 } = data.toJS(); 303 } = data.toJS();
303 304
304 if (!shops_id||!shop_name) { 305 if (!shops_id||!shop_name) {
305 return; 306 return;
306 } 307 }
307 - 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}"}}`; 308 + 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}"}}`;
308 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); 309 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
309 310
310 let I_INDEX = parseInt(index) + 1; 311 let I_INDEX = parseInt(index) + 1;
@@ -340,12 +341,13 @@ class NewArrivalContainer extends Component { @@ -340,12 +341,13 @@ class NewArrivalContainer extends Component {
340 shops_id, 341 shops_id,
341 brand_id, 342 brand_id,
342 shop_template_type, 343 shop_template_type,
  344 + is_red_shop,
343 } = data.toJS(); 345 } = data.toJS();
344 346
345 if (!shops_id||!shop_name) { 347 if (!shops_id||!shop_name) {
346 return; 348 return;
347 } 349 }
348 - 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}"}}`; 350 + 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}"}}`;
349 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); 351 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
350 352
351 let I_INDEX = parseInt(index) + 1; 353 let I_INDEX = parseInt(index) + 1;
@@ -68,6 +68,7 @@ class NewArrivalContainer extends Component { @@ -68,6 +68,7 @@ class NewArrivalContainer extends Component {
68 F_NM, 68 F_NM,
69 I_INDEX, 69 I_INDEX,
70 shop_template_type, 70 shop_template_type,
  71 + is_red_shop,
71 } = data; 72 } = data;
72 if (!shops_id||!shop_name) { 73 if (!shops_id||!shop_name) {
73 return; 74 return;
@@ -84,7 +85,7 @@ class NewArrivalContainer extends Component { @@ -84,7 +85,7 @@ class NewArrivalContainer extends Component {
84 ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_NEW_ARRIVAL_RECOMMEND_FLR_C', param); 85 ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_NEW_ARRIVAL_RECOMMEND_FLR_C', param);
85 86
86 87
87 - 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}"}}`; 88 + 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}"}}`;
88 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url); 89 ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
89 } 90 }
90 91