Authored by QC-L

修复有赚首页滚动Bug review by sunkai

'use strict';
import React, {Component} from 'react';
import {Dimensions, ListView, StyleSheet, Text, View, TouchableOpacity, Image} from 'react-native';
import {Dimensions, ListView, StyleSheet, Text, View, TouchableOpacity, Image, SectionList} from 'react-native';
import {Immutable, default as Immutables} from 'immutable';
import GuideModal from "./GuideModal";
... ... @@ -34,8 +34,8 @@ export default class Home extends Component {
});
}
_renderSectionHeader(sectionData, sectionID) {
switch (sectionID) {
_renderSectionHeader({ section: { title } }) {
switch (title) {
case 'categoryList': {
let { productList } = this.props.data;
let selectedCategoryIndex = productList.selectedCategoryIndex;
... ... @@ -55,11 +55,14 @@ export default class Home extends Component {
}
}
_renderRow(rowData, sectionID, rowID) {
_renderRow(item) {
let rowID = item.index;
let rowData = item.item;
let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft};
switch (sectionID) {
switch (item.section.title) {
case 'resourceList': {
return this._floorCellRender(rowData, rowID);
}
... ... @@ -75,7 +78,7 @@ export default class Home extends Component {
)
}
case 'productList': {
case 'categoryList': {
return (
<ProductCell
style={[styles.listContainer, customStyle]}
... ... @@ -159,11 +162,10 @@ export default class Home extends Component {
} = this.props;
let dataSource = {
resourceList: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : [],
categoryList: data.productList.msort_list ? ['1'] : [],
productList: data.productList.product_list ? data.productList.product_list.toArray() : [],
};
let dataSource = [
{title: 'resourceList', data: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : []},
{title: 'categoryList', data: data.productList.product_list ? data.productList.product_list.toArray() : []},
];
let productList = data.productList.product_list ? data.productList.product_list.toArray() : [];
return (
... ... @@ -171,16 +173,15 @@ export default class Home extends Component {
<GuideModal
isShowGuide={this.props.isShowGuide}
hiddenGuideDialog={this.props.hiddenGuideDialog}/>
<ListView
<SectionList
ref={(c) => {
this.listView = c;
}}
sections={dataSource}
renderSectionHeader={this._renderSectionHeader}
yh_viewVisible={true}
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this._renderRow}
renderItem={this._renderRow}
onEndReached={() => {
if (productList && productList.size !== 0) {
this.props.onEndReached && this.props.onEndReached();
... ...
... ... @@ -8,6 +8,7 @@ import Immutable from 'immutable';
const {
TouchableOpacity,
Dimensions,
View
} = ReactNative;
export default class ImageFour extends React.Component {
... ... @@ -50,6 +51,7 @@ export default class ImageFour extends React.Component {
let sliderWidth = width / 4;
let sliderHeight = 105 * DEVICE_WIDTH_RATIO;
return (
<View style={{flexDirection: 'row'}}>{
list.map((item, i) => {
let imageUrl = YH_Image.getSlicedUrl(item.src, sliderWidth, sliderHeight, 2);
return (
... ... @@ -57,28 +59,20 @@ export default class ImageFour extends React.Component {
key={i}
activeOpacity={1}
yh_exposureData={item.yh_exposureData}
style={{width: sliderWidth, height: sliderHeight}}
style={{ width: sliderWidth, height: sliderHeight }}
onPress={() => {
// if (i === 2) {
// this.props.jumpWithUrl && this.props.jumpWithUrl('达人排行', 'talentRank');
// } else {
this._handleParamsJumpWithUrl(i + 1, item.url);
// }
// this.props.jumpWithUrl && this.props.jumpWithUrl('商品详情', 'shareDetail');
// let url = `http://m.yohobuy.com?openby:yohobuy={"action":"go.minealliance","params":{"favType":"0", "type":"recommendProduct", "title":"商品", "src":"http://img10.static.yhbimg.com/yhb-img01/2018/08/08/21/01479a3a579091b1c198d2884f3a80b08c.png?imageView2/{mode}/w/{width}/h/{height}", "productPool":"680" }}`;
// ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
// this.props.jumpWithUrl && this.props.jumpWithUrl('商品详情', 'recommendProduct');
}}
>
<YH_Image
url={imageUrl}
style={{width: sliderWidth, height: sliderHeight}}
style={{ width: sliderWidth, height: sliderHeight }}
/>
</TouchableOpacity>
);
})
}
</View>
);
}
}
... ...
... ... @@ -40,7 +40,7 @@ export default class GroupProductCell extends React.Component {
let activityId = resource.get('activityId');
let collagePrice = resource.get('collagePrice').toFixed(2);
let joinLimit = resource.get('joinLimit');
console.log('.....: ', resource.toJS());
return (
<View>
<TouchableOpacity activeOpacity={0.8} onPress={() => {
... ...