Authored by 孙凯

添加全球购楼层控件 review by hongmo

... ... @@ -17,6 +17,8 @@ import GlobalHomeSwiper from './GlobalHomeSwiper';
import RecommendContentTwo from './RecommendContentTwo';
import RecommendContentFive from './RecommendContentFive';
import RecommendContentOne from './RecommendContentOne';
import SmallPic from './SmallPic';
import {getSlicedUrl} from '../../../classify/utils/Utils';
export default class Home extends Component {
... ... @@ -54,7 +56,7 @@ export default class Home extends Component {
}
_renderRow(rowData: object, sectionID: number, rowID: number) {
console.log(rowData.toJS());
// console.log(rowData.toJS());
if (rowData.get('template_name') == 'focus') {
return (
<GlobalHomeSwiper resource={rowData}/>
... ... @@ -78,16 +80,29 @@ export default class Home extends Component {
/>
);
}else if (rowData.get('template_name') == 'divideImage') {
let data = rowData.get('data').toJS();
let divideImage = getSlicedUrl(data[0].src, width, 20, 2);
if (!divideImage) {return null;}
return (
<Text>divideImage</Text>
<Image
source={{uri: divideImage}}
style={{width: width,height: 20}}
resizeMode={'cover'}
></Image>
);
}else if (rowData.get('template_name') == 'small_pic') {
return (
<Text>small_pic</Text>
<SmallPic
resource={rowData}
// onPressRecommendItem={this.props.onPressRecommendItem}
/>
);
}else if (rowData.get('template_name') == 'paramsGroup') {
let data = rowData.get('data');
return (
<Text>paramsGroup</Text>
<View style={styles.title}>
<Text style={styles.text}>{data.get('title')}</Text>
</View>
);
}
return null;
... ... @@ -140,4 +155,17 @@ let styles = StyleSheet.create({
contentContainer: {
},
title: {
alignItems: 'center',
justifyContent: 'center',
height: 39,
width:width,
backgroundColor: 'white',
},
text: {
textAlign: 'center',
fontSize: 16,
fontWeight: 'bold',
color: '#444',
},
});
... ...
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import {getSlicedUrl} from '../../../classify/utils/Utils';
const {
Image,
View,
StyleSheet,
Dimensions,
TouchableOpacity,
} = ReactNative;
import Immutable, {Map} from 'immutable';
export default class SmallPic extends React.Component {
constructor(props) {
super (props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
if (this.props.resource.size == 0) {
return null;
}
let res = this.props.resource.get('data');
let list = res.toJS();
let image0 = getSlicedUrl(list[0].src, 100, 50, 2);
let image1 = getSlicedUrl(list[1].src, 100, 50, 2);
return (
<View style={styles.viewStyle}>
<Image
source={{uri: image0}}
style={styles.thumbnail}
resizeMode={'cover'}
></Image>
<Image
source={{uri: image1}}
style={styles.thumbnail}
resizeMode={'cover'}
></Image>
</View>
);
}
};
let width = (Dimensions.get('window').width - 45)/2;
let height = (9*width)/16;
const styles = StyleSheet.create({
thumbnail: {
width: width,
height: height,
borderRadius: 10,
marginLeft: 15,
},
viewStyle:{
flexDirection: 'row',
alignItems: 'center',
width: Dimensions.get('window').width,
height: height,
backgroundColor: '#f0f0f0',
},
});
... ...