...
|
...
|
@@ -12,6 +12,7 @@ const { |
|
|
ListView,
|
|
|
Dimensions,
|
|
|
TouchableOpacity,
|
|
|
PixelRatio,
|
|
|
} = ReactNative;
|
|
|
|
|
|
export default class BannerReourceList extends React.Component {
|
...
|
...
|
@@ -22,15 +23,31 @@ export default class BannerReourceList extends React.Component { |
|
|
});
|
|
|
}
|
|
|
|
|
|
static getSlicedUrl(src, width, height, mode = 1) {
|
|
|
if (!src) {
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
width = PixelRatio.getPixelSizeForLayoutSize(width);
|
|
|
height = PixelRatio.getPixelSizeForLayoutSize(height);
|
|
|
let newSrc = src;
|
|
|
if (src.indexOf('imageView') === -1 && src.indexOf('imageMogr') === -1) {
|
|
|
newSrc = src + '?imageView2/' + mode + '/w/' + width + '/h/' + height;
|
|
|
} else {
|
|
|
newSrc = src.replace('{mode}', mode)
|
|
|
.replace('{width}', width)
|
|
|
.replace('{height}', height);
|
|
|
}
|
|
|
return newSrc;
|
|
|
}
|
|
|
|
|
|
_pressRow(rowData){
|
|
|
this.props.onPressBrandItem(rowData.url)
|
|
|
}
|
|
|
|
|
|
renderRow(rowData,sectionID,rowID,highlightRow) {
|
|
|
|
|
|
let newSrc = rowData?rowData.src.replace('{mode}', 1)
|
|
|
.replace('{width}', itemHeight)
|
|
|
.replace('{height}', itemHeight):rowData.src;
|
|
|
let newSrc = BannerReourceList.getSlicedUrl(rowData.src, itemWidth, itemWidth, 1);
|
|
|
return (
|
|
|
<TouchableOpacity activeOpacity={0.5} onPress={() => {
|
|
|
this.props.onPressBrandItem && this.props.onPressBrandItem(rowData.url);
|
...
|
...
|
@@ -54,10 +71,10 @@ export default class BannerReourceList extends React.Component { |
|
|
}
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let {resource} = this.props;
|
|
|
let res = resource.toJS();
|
|
|
let data = res.data;
|
|
|
let title = data?data.title:null;
|
|
|
let list = data?data.list:null;
|
|
|
|
|
|
if (!resource || resource.size == 0 || !list) {
|
...
|
...
|
@@ -67,7 +84,7 @@ export default class BannerReourceList extends React.Component { |
|
|
return (
|
|
|
<View style={styles.cellList}>
|
|
|
<View style={styles.titleStyle}>
|
|
|
<Text style={styles.titleText} numberOfLines={1}>推荐品牌</Text>
|
|
|
<Text style={styles.titleText} numberOfLines={1}>{title.title}</Text>
|
|
|
</View>
|
|
|
<ListView
|
|
|
showsHorizontalScrollIndicator ={false}
|
...
|
...
|
@@ -82,7 +99,7 @@ export default class BannerReourceList extends React.Component { |
|
|
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let itemWidth= width/4;
|
|
|
let itemWidth= Math.ceil(width/4);
|
|
|
let itemHeight = 50;
|
|
|
|
|
|
let styles = StyleSheet.create({
|
...
|
...
|
|