Authored by 鹿亮亮

填充vip和新用户楼层数据 review by 陈林

... ... @@ -25,6 +25,8 @@ import Immutable, {
} from 'immutable';
import HeadTitleCell from '../cell/HeadTitleCell';
import YH_Image from '../../../common/components/YH_Image';
import SlicedImage from '../../../common/components/SlicedImage';
export default class KidsBrandFloor extends Component {
constructor(props) {
... ... @@ -42,41 +44,73 @@ export default class KidsBrandFloor extends Component {
}
}
_getImageUrl(rowId){
if (rowId == 7){
return require('../../images/brandicon_more.png');
_renderRow(rowData,sectionID,rowID,highlightRow){
let moreUrl = this.props.data.get('title').get('more_url');
let imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'), itemWidth, itemWidth, 2);
let title = rowData.get('title');
let actionUrl = rowData.get('url');
if (rowID <= 7){
if (rowID == 7){
return (
<TouchableOpacity onPress={()=>{this.props.onPressBrandItem&&this.props.onPressBrandItem(moreUrl,rowID)}}>
<View style={styles.row}>
<View style={styles.imageContainer}>
<Image
source={require('../../images/brandicon_more.png')}/>
</View>
<Text style={styles.text} numberOfLines={1}>
MORE
</Text>
</View>
</TouchableOpacity>
);
} else {
let curW,curH,mr;
if (rowID < 3){
curW = itemWidth - 0.5;
curH = itemHeight - 0.5;
mr = 0.5;
} else if (rowID == 3){
curW = itemWidth;
curH = itemHeight - 0.5;
mr = 0;
} else if (rowID > 3 && rowID < 7){
curW = itemWidth - 0.5;
curH = itemHeight;
mr = 0.5;
} else {
curW = itemWidth;
curH = itemHeight;
mr = 0;
}
return (
<TouchableOpacity activeOpacity={1} onPress={()=>{this.props.onPressBrandItem&&this.props.onPressBrandItem(actionUrl,rowID)}}>
<View style={styles.row,{width:curW,height:curH,marginRight:mr}}>
<YH_Image style={styles.image}
url={imgUrl}/>
<Text style={styles.text} numberOfLines={1}>
{title}
</Text>
</View>
</TouchableOpacity>
);
}
} else {
return {uri:'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'};
return null;
}
}
_renderRow(rowData,sectionID,rowID,highlightRow){
return (
<TouchableOpacity activeOpacity={0.5}>
<View style={styles.row}>
<Image style={styles.image}
source={this._getImageUrl(rowID)}
resizeMode={'contain'}/>
<Text style={styles.text} numberOfLines={1}>
测试标题
</Text>
</View>
</TouchableOpacity>
);
}
render() {
let data = [1,1,1,1,1,1,1,1]
if (!data.length) {
return null;
}
let data = this.props.data;
let title = data.get('title').get('title');
let moreurl = data.get('title').get('more_url');
let dataList = data.get('list');
return (
<View style={styles.container}>
<HeadTitleCell title={'潮童热门品牌推荐'}/>
<HeadTitleCell title={title} moreUrl={moreurl}/>
<ListView
contentContainerStyle={styles.list}
dataSource={this.dataSource.cloneWithRows(data)}
dataSource={this.dataSource.cloneWithRows(dataList.toArray())}
initialListSize={data.length}
renderRow={this._renderRow.bind(this)}
/>
... ... @@ -88,15 +122,13 @@ export default class KidsBrandFloor extends Component {
let {width, height} = Dimensions.get('window');
let itemWidth = width / 4;
let itemHeight = 70;
let itemHeight = itemWidth+20;
let styles = StyleSheet.create({
container:{
backgroundColor:'white'
},
list: {
backgroundColor: 'white',
borderColor: 'rgb(215, 215, 215)',
borderBottomWidth: 0.5,
backgroundColor: '#7f808080',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent:'space-around',
... ... @@ -116,10 +148,21 @@ let styles = StyleSheet.create({
text:{
width:itemWidth,
height:20,
backgroundColor:'transparent',
fontWeight: 'bold',
backgroundColor:'white',
color: 'gray',
textAlign:'center',
fontSize:12,
}
},
imageContainer:{
width:itemWidth,
height:itemWidth,
backgroundColor:'white',
justifyContent:'center',
alignItems:'center'
},
row:{
width:itemWidth,
height:itemHeight,
backgroundColor:'white'
},
});
... ...
... ... @@ -21,38 +21,32 @@ import Immutable from 'immutable';
import SlicedImage from '../../../common/components/SlicedImage';
import HeadTitleCell from '../cell/HeadTitleCell';
import Banner from '../../../common/components/Banner'
import YH_Image from '../../../common/components/YH_Image';
export default class NewUserFloor extends Component {
constructor(props) {
super(props);
this.onPressBanner = this.onPressBanner.bind(this);
this.renderRow = this.renderRow.bind(this);
this.onPressBuy = this.onPressBuy.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
onPressBanner() {
console.log("banner on press");
}
_getImageUrl(rowId) {
return {uri: 'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'};
}
renderRow(rowData, sectionID, rowID, highlightRow) {
let productName = '商品名称';
let productPrice = '888.88';
let productName = rowData.get('product_name');
let productPrice = rowData.get('sales_price');
let productId = rowData.get('product_id');
let productSkn = rowData.get('product_skn');
let imgUrl = SlicedImage.getSlicedUrl(rowData.get('default_images'),cellWidth / 2,cellHeight,2);
return (
<View style={styles.row}>
<Image style={styles.image}
source={this._getImageUrl(rowID)}
resizeMode={'cover'}/>
<YH_Image style={styles.image}
source={imgUrl}/>
<View style={styles.detailContainer}>
<Text style={styles.detail} numberOfLines={2}>{productName}</Text>
<Text style={styles.detail} numberOfLines={2}>{productPrice}</Text>
<TouchableOpacity style={styles.buyContainer} onPress={this.onPressBuy}>
<TouchableOpacity style={styles.buyContainer}
onPress={()=>{this.props.onPressVipProduct&&this.props.onPressVipProduct(productId,productSkn)}}>
<Text style={styles.buy} numberOfLines={1}>立即购买</Text>
<Image style={{width:4,height:7,marginLeft:2}}
source={require('../../images/ic_small_arrow_right.png')}/>
... ... @@ -61,42 +55,29 @@ export default class NewUserFloor extends Component {
</View>);
}
onPressBuy() {
console.log('buy');
}
render() {
let bannerData = Immutable.fromJS(
[{
"src": "http://img10.static.yhbimg.com/yhb-img01/2017/02/13/10/01d3b3208f7b4971396981debc758c7275.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html?title=超值精选&share_id=1637&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"share_id\":\"1637\",\"title\":\"超值精选\"},\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"1637\"},\"title\":\"超值精选\",\"url\":\"https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html\"}}"
}
,
{
"src": "http://img10.static.yhbimg.com/yhb-img01/2017/02/13/10/01d3b3208f7b4971396981debc758c7275.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html?title=超值精选&share_id=1637&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"share_id\":\"1637\",\"title\":\"超值精选\"},\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"1637\"},\"title\":\"超值精选\",\"url\":\"https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html\"}}"
}
]
);
let data = [1, 1, 1];
let data = this.props.data;
let title = data.get('title').get('title');
let moreUrl = data.get('title').get('more_url');
let bgUrl = data.get('background').get('src');
let visible = bgUrl ? true : false;
let bannerData = data.get('banner_image');
let productData = data.get('list');
return (
<View style={styles.container}>
<HeadTitleCell title={'新人专享'}/>
<HeadTitleCell title={title}/>
<Banner
data={bannerData}
duration={8}
width={width}
height={bannerHeight}
onPress={this.onPressBanner}
onPress={this.props.onPressVipBannerItem}
/>
<View style={styles.listContianer}>
<Image style={styles.listBg}
source={{uri: 'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'}}
resizeMode={'cover'}/>
<YH_Image style={styles.listBg}
url={SlicedImage.getSlicedUrl(bgUrl,width,130,2)}/>
<View>
<ListView
contentContainerStyle={styles.list}
... ...
... ... @@ -21,86 +21,68 @@ import Immutable from 'immutable';
import SlicedImage from '../../../common/components/SlicedImage';
import HeadTitleCell from '../cell/HeadTitleCell';
import Banner from '../../../common/components/Banner'
import YH_Image from '../../../common/components/YH_Image';
export default class VipUserFloor extends Component {
constructor(props) {
super(props);
this.onPressBanner = this.onPressBanner.bind(this);
this.renderRow = this.renderRow.bind(this);
this.onPressBuy = this.onPressBuy.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
onPressBanner() {
console.log("banner on press");
}
_getImageUrl(rowId) {
return {uri: 'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'};
}
renderRow(rowData, sectionID, rowID, highlightRow) {
let productName = '商品名称';
let productPrice = '888.88';
let orginPrice = '999.999';
let productName = rowData.get('product_name');;
let productPrice = rowData.get('vip1_price');
let orginPrice = rowData.get('market_price');
let productId = rowData.get('product_id');
let productSkn = rowData.get('product_skn');
let imgUrl = SlicedImage.getSlicedUrl(rowData.get('default_images'),cellWidth,120,2);
return (
<View style={styles.row}>
<Image style={styles.image}
source={this._getImageUrl(rowID)}
resizeMode={'cover'}/>
<TouchableOpacity style={styles.row}
onPress={()=>this.props.onPressVipProduct && this.props.onPressVipProduct(productId,productSkn)}>
<YH_Image style={styles.image}
url={imgUrl}
/>
<Text style={styles.vipText} numberOfLines={1}>{productPrice}</Text>
<View style={styles.vipContainer}>
<Text style={styles.discountText} numberOfLines={1}>{orginPrice}</Text>
<Image style={{width:33,height:12,marginLeft:2}}
source={require('../../images/ic_vip_red.png')}/>
</View>
</View>);
}
onPressBuy() {
console.log('buy');
</TouchableOpacity>);
}
render() {
let bannerData = Immutable.fromJS(
[{
"src": "http://img10.static.yhbimg.com/yhb-img01/2017/02/13/10/01d3b3208f7b4971396981debc758c7275.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html?title=超值精选&share_id=1637&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"share_id\":\"1637\",\"title\":\"超值精选\"},\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"1637\"},\"title\":\"超值精选\",\"url\":\"https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html\"}}"
}
,
{
"src": "http://img10.static.yhbimg.com/yhb-img01/2017/02/13/10/01d3b3208f7b4971396981debc758c7275.jpg?imageView2/{mode}/w/{width}/h/{height}",
"title": "",
"url": "https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html?title=超值精选&share_id=1637&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"share_id\":\"1637\",\"title\":\"超值精选\"},\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"1637\"},\"title\":\"超值精选\",\"url\":\"https://feature.yoho.cn/0116/0116SELECTITEMSBOY/index.html\"}}"
}
]
);
let data = [1, 1, 1, 1, 1, 1];
let visible = false;
let data = this.props.data;
let title = data.get('title').get('title');
let moreUrl = data.get('title').get('more_url');
let bgUrl = data.get('background').get('src');
let visible = bgUrl ? true : false;
let bannerData = data.get('banner_image');
let productData = data.get('list');
return (
<View style={styles.container}>
<HeadTitleCell title={'VIP专享'}/>
<HeadTitleCell title={title} moreUrl={moreUrl}/>
<Banner
data={bannerData}
duration={8}
width={width}
height={bannerHeight}
onPress={this.onPressBanner}
onPress={this.props.onPressVipBannerItem}
/>
<View style={styles.listContianer}>
{visible ?
<Image style={styles.listBg}
source={{uri: 'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'}}
resizeMode={'cover'}/> : null}
<YH_Image style={styles.listBg}
url={SlicedImage.getSlicedUrl(bgUrl,width,cellHeight,2)}
/> : null}
<ListView
style={{position:'absolute',left:0,top:5,paddingTop:12,paddingBottom:12}}
contentContainerStyle={styles.listContent}
horizontal={true}
dataSource={this.dataSource.cloneWithRows(data)}
dataSource={this.dataSource.cloneWithRows(productData.toArray())}
renderRow={this.renderRow}
showsHorizontalScrollIndicator={false}
/>
... ... @@ -120,20 +102,15 @@ let cellHeight = 210;
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1
},
listContianer: {
width:width,
height: cellHeight,
alignItems: 'center',
paddingTop: 16,
paddingBottom: 12,
},
listBg: {
width: width,
height: cellHeight,
position: 'absolute',
top: 0,
left: 0,
},
listContent: {
backgroundColor: 'transparent',
... ...
... ... @@ -146,8 +146,8 @@ export default class Home extends Component {
}
case 'recommend_content_one': {
return (
<RecommendContentOne
data={rowData.get('data')}
<RecommendContentOne
data={rowData.get('data')}
onPressRecommendSlideItem={this.props.onPressRecommendSlideItem}
onPressRecommendListItem={this.props.onPressRecommendListItem}
/>
... ... @@ -155,8 +155,8 @@ export default class Home extends Component {
}
case 'recommend_content_two': {
return (
<RecommendContentTwo
data={rowData.get('data')}
<RecommendContentTwo
data={rowData.get('data')}
onPressRecommendSlideItem={this.props.onPressRecommendSlideItem}
onPressRecommendListItem={this.props.onPressRecommendListItem}
/>
... ... @@ -164,8 +164,8 @@ export default class Home extends Component {
}
case 'recommend_content_three': {
return (
<RecommendContentThree
data={rowData.get('data')}
<RecommendContentThree
data={rowData.get('data')}
onPressRecommendSlideItem={this.props.onPressRecommendSlideItem}
onPressRecommendListItem={this.props.onPressRecommendListItem}
/>
... ... @@ -173,8 +173,8 @@ export default class Home extends Component {
}
case 'recommend_content_five': {
return (
<RecommendContentFive
data={rowData.get('data')}
<RecommendContentFive
data={rowData.get('data')}
onPressRecommendSlideItem={this.props.onPressRecommendSlideItem}
onPressRecommendListItem={this.props.onPressRecommendListItem}
/>
... ... @@ -182,7 +182,7 @@ export default class Home extends Component {
}
case 'trendsetter_collocation': {
return (
<TrendsetterCollocation
<TrendsetterCollocation
data={rowData.get('data')}
onPressTrendArticleItem={this.props.onPressTrendArticleItem}
onPressTrendRecommendItem={this.props.onPressTrendRecommendItem}
... ... @@ -191,7 +191,7 @@ export default class Home extends Component {
}
case 'trendgoods_topic': {
return (
<TrendgoodsTopic
<TrendgoodsTopic
data={rowData.get('data')}
onPressTrendTopicItem={this.props.onPressTrendTopicItem}
/>
... ... @@ -200,7 +200,7 @@ export default class Home extends Component {
case 'custom_brands': {
return (
<CustomBrands
data={rowData.get('data')}
data={rowData.get('data')}
onPressCustomBrandItem={this.props.onPressCustomBrandItem}
/>
);
... ... @@ -208,7 +208,10 @@ export default class Home extends Component {
break;
case 'kids_brands':{
return (
<KidsBrandFloor />
<KidsBrandFloor
data={rowData.get('data')}
onPressBrandItem={this.props.onPressBrandItem}
/>
);
}
case 'small_pic': {
... ... @@ -234,7 +237,7 @@ export default class Home extends Component {
}
case 'popular_single_product':{
return (
<PopularSingleProduct
<PopularSingleProduct
data={rowData.get('data')}
onPressImageItem={this.props.onPressImageItem}/>
)
... ... @@ -246,14 +249,14 @@ export default class Home extends Component {
}
case 'sixLinesFloor':{
return (
<SixLinesFloor
<SixLinesFloor
data={rowData.get('data')}
onPressImageItem={this.props.onPressImageItem} />
)
}
case 'livePicture':{
return (
<LivePicture
return (
<LivePicture
data={rowData.get('data')}
onPressImageItem={this.props.onPressImageItem} />
)
... ... @@ -261,7 +264,9 @@ export default class Home extends Component {
case 'vipUse':{
return (
<VipUserFloor
data={rowData.get('data')}/>
data={rowData.get('data')}
onPressVipBannerItem={this.props.onPressVipBannerItem}
onPressVipProduct={this.props.onPressVipProduct} />
);
}
case 'activityProductFloor':{
... ... @@ -272,6 +277,12 @@ export default class Home extends Component {
return <HotCategoryIndividualization
data = {rowData.get('data')}/>
}
case 'new_user_floor':{
return <NewUserFloor
data = {rowData.get('data')}
onPressVipBannerItem={this.props.onPressVipBannerItem}
onPressVipProduct={this.props.onPressVipProduct}/>
}
default:
return null;
}
... ...
... ... @@ -60,6 +60,10 @@ class HomeContainer extends Component {
this.onPressTrendArticleItem = this.onPressTrendArticleItem.bind(this);
this.onPressTrendRecommendItem = this.onPressTrendRecommendItem.bind(this);
this.onPressTrendTopicItem = this.onPressTrendTopicItem.bind(this);
this.onPressBrandItem = this.onPressBrandItem.bind(this);
this.onPressVipBannerItem = this.onPressVipBannerItem.bind(this);
this.onPressVipBuy = this.onPressVipBuy.bind(this);
this.onPressVipProduct = this.onPressVipProduct.bind(this);
this.subscription = NativeAppEventEmitter.addListener(
... ... @@ -145,6 +149,21 @@ class HomeContainer extends Component {
this.jumpWithUrl(url);
}
onPressBrandItem(url,index){
this.jumpWithUrl(url);
}
onPressVipBannerItem(url,index){
console.log("banner is pressed" + url);
this.jumpWithUrl(url);
}
onPressVipBuy(){
}
onPressVipProduct(productId,productName){
console.log('productId=' + productId + " productName=" + productName);
}
render() {
let {app, home} = this.props;
return (
... ... @@ -167,6 +186,10 @@ class HomeContainer extends Component {
onPressTrendArticleItem={this.onPressTrendArticleItem}
onPressTrendRecommendItem={this.onPressTrendRecommendItem}
onPressTrendTopicItem={this.onPressTrendTopicItem}
onPressBrandItem={this.onPressBrandItem}
onPressVipBannerItem={this.onPressVipBannerItem}
onPressVipBuy={this.onPressVipBuy}
onPressVipProduct={this.onPressVipProduct}
/>
</View>
);
... ...