Authored by chenl

Merge branch 'local' into 5.4.1

  1 +import React from 'react';
  2 +import ReactNative from 'react-native';
  3 +import ImmutablePropTypes from 'react-immutable-proptypes';
  4 +
  5 +let {
  6 + requireNativeComponent,
  7 + View
  8 +} = ReactNative;
  9 +
  10 +
  11 +let YH_GoodsStoreView = requireNativeComponent('YH_GoodsStoreView', null);
  12 +
  13 +export default class YH_GoodsStore extends React.Component {
  14 +
  15 + static propTypes = {
  16 + data: React.PropTypes.string,
  17 + ...View.propTypes // 包含默认的View的属性
  18 + };
  19 +
  20 + constructor(props) {
  21 + super(props);
  22 + }
  23 +
  24 + render() {
  25 + return <YH_GoodsStoreView {...this.props} data={this.props.data} />;
  26 + }
  27 +}
  28 +
  1 +'use strict';
  2 +
  3 +import React, {Component} from 'react';
  4 +import ReactNative, {
  5 + View,
  6 + TouchableOpacity,
  7 + StyleSheet,
  8 + Dimensions,
  9 +} from 'react-native';
  10 +import Immutable, {Map} from 'immutable';
  11 +
  12 +
  13 +import SlicedImage from '../../../common/components/SlicedImage';
  14 +import YH_Image from '../../../common/components/YH_Image';
  15 +
  16 +import HeadTitleCell from '../cell/HeadTitleCell';
  17 +
  18 +/**
  19 + * 直播资源位楼层
  20 + * 这个楼层是三张大图构成
  21 + **/
  22 +export default class LivePicture extends Component{
  23 +
  24 +
  25 + constructor(props) {
  26 + super(props);
  27 + }
  28 +
  29 +
  30 + render(){
  31 +
  32 + let data = this.props.data;
  33 + let title = data.get("title");
  34 + let imglst = data.get("list");
  35 +
  36 + let image1Url = SlicedImage.getSlicedUrl(imglst.get(0).get("src"), imageWidth, imageHeight, 2);
  37 + let image2Url = SlicedImage.getSlicedUrl(imglst.get(1).get("src"), imageWidth, imageHeight, 2);
  38 + let image3Url = SlicedImage.getSlicedUrl(imglst.get(2).get("src"), imageWidth, imageHeight, 2);
  39 +
  40 + return(
  41 + <View style={styles.container}>
  42 + <HeadTitleCell title={title.get('title')} moreUrl={title.get('more_url')} />
  43 +
  44 + <View style={styles.imageContainer}>
  45 +
  46 + <TouchableOpacity activeOpacity={1}
  47 + onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(0).toJS())}>
  48 + <YH_Image style={styles.imageLeftAndRight} url={image1Url}/>
  49 + </TouchableOpacity>
  50 +
  51 + <TouchableOpacity activeOpacity={1}
  52 + onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(1).toJS())}>
  53 + <YH_Image style={styles.imageMiddle} url={image2Url}/>
  54 + </TouchableOpacity>
  55 +
  56 + <TouchableOpacity activeOpacity={1}
  57 + onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(2).toJS())}>
  58 + <YH_Image style={styles.imageLeftAndRight} url={image3Url}/>
  59 + </TouchableOpacity>
  60 +
  61 + </View>
  62 + </View>
  63 + );
  64 + }
  65 +
  66 +};
  67 +
  68 +let {width} = Dimensions.get('window');
  69 +const DEVICE_WIDTH_RATIO = width / 320;
  70 +
  71 +let imageWidth = Math.ceil((width - 64) / 3);
  72 +let imageHeight = Math.ceil(imageWidth * 86 / 64);
  73 +
  74 +
  75 +let styles = StyleSheet.create({
  76 +
  77 + container: {
  78 + width: width,
  79 + },
  80 +
  81 + imageContainer: {
  82 + width: width,
  83 + paddingLeft: 16 * DEVICE_WIDTH_RATIO,
  84 + paddingRight: 16 * DEVICE_WIDTH_RATIO,
  85 + paddingTop: 16 * DEVICE_WIDTH_RATIO,
  86 + paddingBottom: 16 * DEVICE_WIDTH_RATIO,
  87 + flexDirection: "row",
  88 + },
  89 +
  90 + imageLeftAndRight: {
  91 + width: imageWidth,
  92 + height: imageHeight,
  93 + },
  94 +
  95 + imageMiddle: {
  96 + width: imageWidth,
  97 + height: imageHeight,
  98 + marginLeft: 16 * DEVICE_WIDTH_RATIO,
  99 + marginRight: 16 * DEVICE_WIDTH_RATIO,
  100 + },
  101 +
  102 +});
  103 +
@@ -3,7 +3,8 @@ @@ -3,7 +3,8 @@
3 import React, {Component} from 'react'; 3 import React, {Component} from 'react';
4 import ReactNative, { 4 import ReactNative, {
5 View, 5 View,
6 - Image, 6 + Text,
  7 + ListView,
7 TouchableOpacity, 8 TouchableOpacity,
8 StyleSheet, 9 StyleSheet,
9 Dimensions, 10 Dimensions,
@@ -12,6 +13,7 @@ import Immutable, {Map} from 'immutable'; @@ -12,6 +13,7 @@ import Immutable, {Map} from 'immutable';
12 13
13 14
14 import SlicedImage from '../../../common/components/SlicedImage'; 15 import SlicedImage from '../../../common/components/SlicedImage';
  16 +import YH_Image from '../../../common/components/YH_Image';
15 import HeadTitleCell from '../cell/HeadTitleCell'; 17 import HeadTitleCell from '../cell/HeadTitleCell';
16 18
17 /** 19 /**
@@ -23,32 +25,68 @@ export default class PopularSingleProduct extends Component{ @@ -23,32 +25,68 @@ export default class PopularSingleProduct extends Component{
23 25
24 constructor(props) { 26 constructor(props) {
25 super(props); 27 super(props);
  28 + this.dataSource = new ListView.DataSource({
  29 + rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
  30 + });
  31 + this.renderRow = this.renderRow.bind(this);
  32 + }
  33 +
  34 + renderRow(rowData,sectionID,rowID,highlightRow){
  35 +
  36 + let goodsImageUrl = rowData.get('default_images');
  37 + goodsImageUrl = SlicedImage.getSlicedUrl(goodsImageUrl, goodsImageWidth, goodsImageHeight, 2);
  38 + let goodsPrice = "¥" + rowData.get('sales_price');
  39 + let goodsLookNum = rowData.get('sales_num') + "人";
  40 +
  41 + return(
  42 + <TouchableOpacity activeOpacity={1}
  43 + onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(rowData.toJS())}>
  44 +
  45 + <View style={styles.goodsContainer}>
  46 + <YH_Image style={styles.goodsImage} url={goodsImageUrl} />
  47 + <Text style={styles.goodsPrice} numberOfLines={1}>{goodsPrice}</Text>
  48 + <Text style={styles.goodsLookNum} numberOfLines={1}>{goodsLookNum}</Text>
  49 + <Text style={styles.goodsLookNum} numberOfLines={1}>正在浏览</Text>
  50 + </View>
  51 +
  52 + </TouchableOpacity>
  53 + );
  54 +
26 } 55 }
27 56
28 57
29 render(){ 58 render(){
30 59
31 - //测试数据  
32 - let rowData = Immutable.fromJS(  
33 - {"template_name":"NewProductFloor","data":{"title":{"more_name":"...","name":"一周精选","title":"一周精选","more_url":""},"list":[{"src":"http://img11.static.yhbimg.com/yhb-img01/2017/01/20/11/01b18ee60e2e9609033a5ad38efc613c8e.jpg?imageView2/{mode}/w/{width}/h/{height}","title":"","url":"https://feature.yoho.cn/0120/0120FENQI/index.html?title=有货分期&share_id=1439&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"share_id\":\"1439\",\"title\":\"有货分期\"},\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"1439\"},\"title\":\"有货分期\",\"url\":\"https://feature.yoho.cn/0120/0120FENQI/index.html\"}}"},{"src":"http://img11.static.yhbimg.com/yhb-img01/2016/12/20/17/01f0604dfef7a6cc75b33c62fcb5acdecb.jpg?imageView2/{mode}/w/{width}/h/{height}","title":"","url":"https://m.yohobuy.com/activity/shopCollect?channel_id=3&title=vip新品抢鲜&code=8eea98740b3645cddb41629aa5dbf6ab&share_id=25&tab_name=欧美大牌&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"code\":\"8eea98740b3645cddb41629aa5dbf6ab\",\"param\":{\"share_id\":\"25\",\"code\":\"8eea98740b3645cddb41629aa5dbf6ab\",\"tab_name\":\"欧美大牌\",\"title\":\"vip新品抢鲜\",\"channel_id\":\"3\"},\"tab_name\":\"欧美大牌\",\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"25\"},\"title\":\"vip新品抢鲜\",\"channel_id\":\"3\",\"url\":\"https://m.yohobuy.com/activity/shopCollect\"}}"},{"src":"http://img11.static.yhbimg.com/yhb-img01/2016/12/20/17/011c7324b07161859654c6bc512cc2bc21.jpg?imageView2/{mode}/w/{width}/h/{height}","title":"","url":"https://feature.yoho.cn/0124/0124PINPAIBOY/index.html?title=精选潮牌专场&share_id=1607&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{\"share_id\":\"1607\",\"title\":\"精选潮牌专场\"},\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"1607\"},\"title\":\"精选潮牌专场\",\"url\":\"https://feature.yoho.cn/0124/0124PINPAIBOY/index.html\"}}"},{"src":"http://img10.static.yhbimg.com/yhb-img01/2016/12/20/17/0113067023a8f323294982d391fc2534eb.jpg?imageView2/{mode}/w/{width}/h/{height}","title":"","url":"https://m.yohobuy.com/activity/shopCollect?channel_id=3&title=vip新品抢鲜&code=8eea98740b3645cddb41629aa5dbf6ab&share_id=25&tab_name=欧美大牌&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"code\":\"8eea98740b3645cddb41629aa5dbf6ab\",\"param\":{\"share_id\":\"25\",\"code\":\"8eea98740b3645cddb41629aa5dbf6ab\",\"tab_name\":\"欧美大牌\",\"title\":\"vip新品抢鲜\",\"channel_id\":\"3\"},\"tab_name\":\"欧美大牌\",\"share\":\"/operations/api/v5/webshare/getShare\",\"shareparam\":{\"share_id\":\"25\"},\"title\":\"vip新品抢鲜\",\"channel_id\":\"3\",\"url\":\"https://m.yohobuy.com/activity/shopCollect\"}}"},{"src":"http://img11.static.yhbimg.com/yhb-img01/2016/12/13/09/01f52bb02ed578eab606cbf402430e7cfe.jpg?imageView2/{mode}/w/{width}/h/{height}","title":"","url":"https://m.yohobuy.com/guang/star/?openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"param\":{},\"url\":\"https://m.yohobuy.com/guang/star/\"}}"}]}});  
34 - let title = rowData.get("data").get("title");  
35 - let imglst = rowData.get("data").get("list"); 60 + let data = this.props.data;
  61 + let background = Immutable.fromJS({"color": "#000000", "src": "?imageView2/{mode}/w/{width}/h/{height}"}); //data.get("background");
  62 + let bannerImage = data.get("banner_image");
  63 + let title = data.get("title");
  64 + let imglst = data.get("list");
  65 +
  66 + // let backgroundStyle = background.get("color") ? {backgroundColor: background.get("color")} : null;
  67 +
  68 + let bannerImageUrl = SlicedImage.getSlicedUrl(bannerImage.get(0).get("src"), width, bannerHeight, 2);
36 69
37 - let leftBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(0).get("src"), leftBigImageWidth, leftBigImageHeight, 2);  
38 - let rightSmallTopLeftImageUrl = SlicedImage.getSlicedUrl(imglst.get(1).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);  
39 - let rightSmallBottomLeftImageUrl = SlicedImage.getSlicedUrl(imglst.get(2).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);  
40 - let rightSmallTopRightImageUrl = SlicedImage.getSlicedUrl(imglst.get(3).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);  
41 - let rightSmallBottomRightImageUrl = SlicedImage.getSlicedUrl(imglst.get(4).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);  
42 70
43 return( 71 return(
44 <View style={styles.container}> 72 <View style={styles.container}>
  73 +
  74 +
45 <HeadTitleCell title={title.get('title')} moreUrl={title.get('more_url')} /> 75 <HeadTitleCell title={title.get('title')} moreUrl={title.get('more_url')} />
46 76
47 - <TouchableOpacity activeOpacity={1}  
48 - onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(0).toJS())}>  
49 - <Image style={styles.bannerImage} key={bannerImageUrl} source={{uri: bannerImageUrl}}/> 77 + <TouchableOpacity activeOpacity={1} style={styles.bannerImage}
  78 + onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(bannerImage.get(0).toJS())}>
  79 + <YH_Image style={styles.bannerImage} url={bannerImageUrl}/>
50 </TouchableOpacity> 80 </TouchableOpacity>
51 81
  82 + <ListView
  83 + style={styles.listViewContainer}
  84 + dataSource={this.dataSource.cloneWithRows(imglst.toArray())}
  85 + horizontal={true}
  86 + renderRow={this.renderRow}
  87 + />
  88 +
  89 +
52 90
53 </View> 91 </View>
54 ); 92 );
@@ -59,17 +97,16 @@ export default class PopularSingleProduct extends Component{ @@ -59,17 +97,16 @@ export default class PopularSingleProduct extends Component{
59 let {width} = Dimensions.get('window'); 97 let {width} = Dimensions.get('window');
60 const DEVICE_WIDTH_RATIO = width / 320; 98 const DEVICE_WIDTH_RATIO = width / 320;
61 99
62 -let bannerHeight = width * 234 / 750;  
63 -  
64 -let goodsImageWidth = 90 * DEVICE_WIDTH_RATIO;  
65 -let goodsImageHeight = 120 * DEVICE_WIDTH_RATIO; 100 +let bannerHeight = Math.ceil(width * 234 / 750);
  101 +let goodsImageWidth = Math.ceil(90 * DEVICE_WIDTH_RATIO);
  102 +let goodsImageHeight = Math.ceil(120 * DEVICE_WIDTH_RATIO);
  103 +width = Math.ceil(width);
66 104
67 105
68 let styles = StyleSheet.create({ 106 let styles = StyleSheet.create({
69 107
70 container: { 108 container: {
71 width: width, 109 width: width,
72 - backgroundColor: "#e5e5e5",  
73 }, 110 },
74 111
75 bannerImage: { 112 bannerImage: {
@@ -77,71 +114,44 @@ let styles = StyleSheet.create({ @@ -77,71 +114,44 @@ let styles = StyleSheet.create({
77 height: bannerHeight, 114 height: bannerHeight,
78 }, 115 },
79 116
80 - leftBigImageContainer: {  
81 - position: 'absolute',  
82 - top: 0,  
83 - left: 0,  
84 - width: leftBigImageWidth,  
85 - height: leftBigImageHeight,  
86 - },  
87 117
88 - leftBigImage: {  
89 - width: leftBigImageWidth,  
90 - height: leftBigImageHeight, 118 + listViewContainer: {
  119 + width: width,
  120 + height: 202 * DEVICE_WIDTH_RATIO,
  121 + paddingTop: 12 * DEVICE_WIDTH_RATIO,
  122 + paddingBottom: 12 * DEVICE_WIDTH_RATIO,
91 }, 123 },
92 124
93 - rightSmallTopLeftImageContainer: {  
94 - position: 'absolute',  
95 - top: 0,  
96 - left: leftBigImageWidth,  
97 - width: rightSmallImageWidth,  
98 - height: rightSmallImageHeight,  
99 - },  
100 125
101 - rightSmallTopLeftImage: {  
102 - width: rightSmallImageWidth,  
103 - height: rightSmallImageHeight, 126 + goodsContainer: {
  127 + width: 90 * DEVICE_WIDTH_RATIO,
  128 + height: 178 * DEVICE_WIDTH_RATIO,
  129 + marginLeft: 11 * DEVICE_WIDTH_RATIO,
  130 + backgroundColor: '#f0f0f0',
104 }, 131 },
105 132
106 - rightSmallBottomLeftImageContainer: {  
107 - position: 'absolute',  
108 - top: rightSmallImageHeight,  
109 - left: leftBigImageWidth,  
110 - width: rightSmallImageWidth,  
111 - height: rightSmallImageHeight,  
112 - },  
113 133
114 - rightSmallBottomLeftImage: {  
115 - width: rightSmallImageWidth,  
116 - height: rightSmallImageHeight, 134 + goodsImage: {
  135 + width: goodsImageWidth,
  136 + height: goodsImageHeight,
117 }, 137 },
118 138
119 - rightSmallTopRightImageContainer: {  
120 - position: 'absolute',  
121 - top: 0,  
122 - left: leftBigImageWidth + rightSmallImageWidth,  
123 - width: rightSmallImageWidth,  
124 - height: rightSmallImageHeight, 139 + goodsPrice: {
  140 + width: goodsImageWidth,
  141 + fontSize: 12,
  142 + color: '#444444',
  143 + textAlign: 'center',
  144 + marginTop: 3 * DEVICE_WIDTH_RATIO,
125 }, 145 },
126 146
127 - rightSmallTopRightImage: {  
128 - width: rightSmallImageWidth,  
129 - height: rightSmallImageHeight, 147 + goodsLookNum: {
  148 + width: goodsImageWidth,
  149 + fontSize: 10,
  150 + color: '#b0b0b0',
  151 + textAlign: 'center',
130 }, 152 },
131 153
132 154
133 - rightSmallBottomRightImageContainer: {  
134 - position: 'absolute',  
135 - top: rightSmallImageHeight,  
136 - left: leftBigImageWidth + rightSmallImageWidth,  
137 - width: rightSmallImageWidth,  
138 - height: rightSmallImageHeight,  
139 - },  
140 -  
141 - rightSmallBottomRightImage: {  
142 - width: rightSmallImageWidth,  
143 - height: rightSmallImageHeight,  
144 - },  
145 155
146 156
147 157
  1 +'use strict';
  2 +
  3 +import React, {Component} from 'react';
  4 +import ReactNative, {
  5 + View,
  6 + Text,
  7 + ListView,
  8 + TouchableOpacity,
  9 + StyleSheet,
  10 + Dimensions,
  11 +} from 'react-native';
  12 +import Immutable, {Map} from 'immutable';
  13 +
  14 +
  15 +import SlicedImage from '../../../common/components/SlicedImage';
  16 +import YH_Image from '../../../common/components/YH_Image';
  17 +import YH_GoodsStore from '../../../common/components/YH_GoodsStore';
  18 +
  19 +
  20 +/**
  21 + * 好店推荐楼层,
  22 + * 这个楼层是滚动的3D大图
  23 + **/
  24 +export default class ShopRecommend extends Component{
  25 +
  26 +
  27 + constructor(props) {
  28 + super(props);
  29 + this.dataSource = new ListView.DataSource({
  30 + rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
  31 + });
  32 + }
  33 +
  34 +
  35 +
  36 + render(){
  37 +
  38 + let data = this.props.data;
  39 +
  40 + return(
  41 + <View style={styles.container}>
  42 +
  43 + <YH_GoodsStore style={styles.container} data={data} />
  44 +
  45 + </View>
  46 + );
  47 + }
  48 +
  49 +};
  50 +
  51 +let {width} = Dimensions.get('window');
  52 +const DEVICE_WIDTH_RATIO = width / 320;
  53 +
  54 +width = Math.ceil(width);
  55 +
  56 +
  57 +let styles = StyleSheet.create({
  58 +
  59 + container: {
  60 + width: width,
  61 + height: 279 * DEVICE_WIDTH_RATIO,
  62 + },
  63 +
  64 +
  65 +
  66 +});
  67 +
  1 +'use strict';
  2 +
  3 +import React, {Component} from 'react';
  4 +import ReactNative, {
  5 + View,
  6 + ListView,
  7 + TouchableOpacity,
  8 + StyleSheet,
  9 + Dimensions,
  10 +} from 'react-native';
  11 +import Immutable, {Map} from 'immutable';
  12 +
  13 +
  14 +import SlicedImage from '../../../common/components/SlicedImage';
  15 +import YH_Image from '../../../common/components/YH_Image';
  16 +import HeadTitleCell from '../cell/HeadTitleCell';
  17 +
  18 +/**
  19 + * 六图并列楼层,
  20 + * 这个楼层是六个图片,一行两个展示
  21 + **/
  22 +export default class SixLinesFloor extends Component{
  23 +
  24 +
  25 + constructor(props) {
  26 + super(props);
  27 + this.dataSource = new ListView.DataSource({
  28 + rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
  29 + });
  30 + this.renderRow = this.renderRow.bind(this);
  31 +
  32 + }
  33 +
  34 + renderRow(rowData,sectionID,rowID,highlightRow){
  35 +
  36 + let goodsImageUrl = rowData.get('src');
  37 + goodsImageUrl = SlicedImage.getSlicedUrl(goodsImageUrl, imageWidth, imageHeight, 2);
  38 +
  39 + return(
  40 + <TouchableOpacity activeOpacity={1}
  41 + onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(rowData.toJS())}>
  42 +
  43 + <YH_Image style={styles.goodsImage} url={goodsImageUrl} />
  44 +
  45 + </TouchableOpacity>
  46 + );
  47 +
  48 + }
  49 +
  50 +
  51 + render(){
  52 +
  53 + let data = this.props.data;
  54 + let title = data.get("title");
  55 + let imglst = data.get("list");
  56 +
  57 + return(
  58 + <View style={styles.container}>
  59 +
  60 + <HeadTitleCell title={title.get('name')} moreUrl={title.get('more_url')} />
  61 +
  62 + <ListView
  63 + contentContainerStyle={styles.listViewContainer}
  64 + dataSource={this.dataSource.cloneWithRows(imglst.toArray())}
  65 + renderRow={this.renderRow}/>
  66 + </View>
  67 + );
  68 + }
  69 +
  70 +};
  71 +
  72 +let {width} = Dimensions.get('window');
  73 +const DEVICE_WIDTH_RATIO = width / 320;
  74 +
  75 +let imageWidth = Math.ceil(width / 2);
  76 +let imageHeight = Math.ceil(imageWidth * 180 / 375);
  77 +
  78 +
  79 +let styles = StyleSheet.create({
  80 +
  81 + container: {
  82 + width: width,
  83 + },
  84 +
  85 + listViewContainer: {
  86 + width: width,
  87 + flexDirection: 'row',
  88 + flexWrap: 'wrap',
  89 + alignItems:'flex-start',
  90 + },
  91 +
  92 + goodsImage: {
  93 + width: imageWidth,
  94 + height: imageHeight,
  95 + },
  96 +
  97 +
  98 +});
  99 +