1
|
-'use strict';
|
|
|
2
|
-
|
1
|
+/**
|
|
|
2
|
+ * Description:
|
|
|
3
|
+ * activityProductFloor: 添加活动+商品推荐楼层(内含 1 VIP 专享 2 新人专享 3 学生专享 4 新品到着)
|
|
|
4
|
+ * Author: Bruce.Lu
|
|
|
5
|
+ * Version: 1.0
|
|
|
6
|
+ * Created on 2017/2/14.
|
|
|
7
|
+ */
|
3
|
import React, {Component} from 'react';
|
8
|
import React, {Component} from 'react';
|
4
|
-import SlicedImage from '../../../common/components/SlicedImage';
|
|
|
5
|
-
|
|
|
6
|
import ReactNative, {
|
9
|
import ReactNative, {
|
7
|
- View,
|
|
|
8
|
- Text,
|
|
|
9
|
Image,
|
10
|
Image,
|
10
|
- ListView,
|
11
|
+ Text,
|
11
|
StyleSheet,
|
12
|
StyleSheet,
|
12
|
- Dimensions,
|
13
|
+ ListView,
|
|
|
14
|
+ View,
|
13
|
TouchableOpacity,
|
15
|
TouchableOpacity,
|
|
|
16
|
+ Dimensions,
|
14
|
} from 'react-native';
|
17
|
} from 'react-native';
|
|
|
18
|
+import Swiper from 'react-native-swiper';
|
|
|
19
|
+import ImmutablePropTypes from 'react-immutable-proptypes';
|
15
|
import Immutable from 'immutable';
|
20
|
import Immutable from 'immutable';
|
16
|
-
|
|
|
17
|
-/**
|
|
|
18
|
- * 这个楼层还没有做,涉及到几个组合的,后面再做
|
|
|
19
|
- *
|
|
|
20
|
- **/
|
|
|
21
|
-export default class ActivityProductFloor extends Component{
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
- constructor(props) {
|
|
|
25
|
- super(props);
|
|
|
26
|
-
|
|
|
27
|
- this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => !Immutable.is(r1, r2)});
|
|
|
28
|
- this.renderHeader = this.renderHeader.bind(this);
|
|
|
29
|
- this.renderRow = this.renderRow.bind(this);
|
|
|
30
|
-
|
|
|
31
|
- }
|
|
|
32
|
-
|
|
|
33
|
- renderHeader(){
|
|
|
34
|
-
|
|
|
35
|
- let {title} = this.props;
|
|
|
36
|
-
|
|
|
37
|
- return(
|
|
|
38
|
- <View style={styles.headerContainer}>
|
|
|
39
|
- <Text style={styles.headerText}>{title}</Text>
|
|
|
40
|
- <TouchableOpacity style={styles.headerMore} activeOpacity={1} onPress={() => this.props.onPressCategoryBMore && this.props.onPressCategoryBMore()}>
|
|
|
41
|
- <Text style={styles.headerMoreText}>MORE</Text>
|
|
|
42
|
- <Image style={styles.headerMoreArrow} source={require("../../images/category_b_arrow.png")}/>
|
|
|
43
|
- </TouchableOpacity>
|
|
|
44
|
- <View style={styles.headerLine}/>
|
|
|
45
|
- </View>
|
|
|
46
|
- );
|
|
|
47
|
- }
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
- renderRow(rowData, sectionID, rowID, highlightRow){
|
|
|
52
|
-
|
|
|
53
|
- if (!rowData || rowData.length == 0) {
|
|
|
54
|
- return null;
|
|
|
55
|
- }
|
|
|
56
|
-
|
|
|
57
|
- let imageUrl = SlicedImage.getSlicedUrl(rowData.get("default_images"), 98, 128, 2);
|
|
|
58
|
- // let categoryName = rowData.get("category_name");
|
|
|
59
|
-
|
|
|
60
|
- //数据类型,纯文字型和图片型,列表中会出现纯文本的情况,比如MORE
|
|
|
61
|
- let dataType = rowData.get("data_type");
|
|
|
62
|
-
|
|
|
63
|
- if(dataType && dataType == 'text')
|
|
|
64
|
- return (
|
|
|
65
|
- <TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressHotCategoryItem && this.props.onPressHotCategoryItem(rowData.toJS(),rowID)}>
|
|
|
66
|
- <View style={styles.rowContainer}>
|
|
|
67
|
- <Text style={styles.rowText} numberOfLines={1}>{rowData.get("show_category_name")}</Text>
|
|
|
68
|
- </View>
|
|
|
69
|
- </TouchableOpacity>
|
|
|
70
|
- );
|
|
|
71
|
- else{
|
|
|
72
|
- return (
|
|
|
73
|
- <TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressHotCategoryItem && this.props.onPressHotCategoryItem(rowData.toJS(),rowID)}>
|
|
|
74
|
- <View style={styles.rowContainer}>
|
|
|
75
|
- <Image style={styles.rowThumbnail} source={{uri: imageUrl}}/>
|
|
|
76
|
- <View style={styles.rowTextContainer}><Text style={styles.rowText} numberOfLines={2}>{rowData.get("category_name")}</Text></View>
|
|
|
77
|
- </View>
|
|
|
78
|
- </TouchableOpacity>
|
|
|
79
|
- );
|
|
|
80
|
- }
|
|
|
81
|
-
|
|
|
82
|
- }
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
- render(){
|
|
|
86
|
- let {data} = this.props;
|
|
|
87
|
-
|
|
|
88
|
- return(
|
|
|
89
|
- <View style={styles.container}>
|
|
|
90
|
- <ListView
|
|
|
91
|
- pageSize={3}
|
|
|
92
|
- contentContainerStyle={styles.contentContainer}
|
|
|
93
|
- dataSource={this.dataSource.cloneWithRows(data)}
|
|
|
94
|
- enableEmptySections={true}
|
|
|
95
|
- renderRow={this.renderRow}
|
|
|
96
|
- renderHeader={this.renderHeader}
|
|
|
97
|
- />
|
|
|
98
|
- </View>
|
21
|
+import SlicedImage from '../../../common/components/SlicedImage';
|
|
|
22
|
+import HeadTitleCell from '../cell/HeadTitleCell';
|
|
|
23
|
+import Banner from '../../../common/components/Banner'
|
|
|
24
|
+
|
|
|
25
|
+export default class ActivityProductFloor extends Component {
|
|
|
26
|
+ constructor(props) {
|
|
|
27
|
+ super(props);
|
|
|
28
|
+ this.onPressBanner = this.onPressBanner.bind(this);
|
|
|
29
|
+ this.renderRow = this.renderRow.bind(this);
|
|
|
30
|
+ this.onPressBuy = this.onPressBuy.bind(this);
|
|
|
31
|
+ this.dataSource = new ListView.DataSource({
|
|
|
32
|
+ rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
33
|
+ });
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ onPressBanner() {
|
|
|
37
|
+ console.log("banner on press");
|
|
|
38
|
+ }
|
|
|
39
|
+
|
|
|
40
|
+ _getImageUrl(rowId) {
|
|
|
41
|
+ return {uri: 'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'};
|
|
|
42
|
+ }
|
|
|
43
|
+
|
|
|
44
|
+ _isShowVip(type){
|
|
|
45
|
+ if (type == TYPE_STUDENT){
|
|
|
46
|
+ return false;
|
|
|
47
|
+ } else {
|
|
|
48
|
+ return true;
|
|
|
49
|
+ }
|
|
|
50
|
+ }
|
|
|
51
|
+
|
|
|
52
|
+ _isShowOrignPrice(type){
|
|
|
53
|
+ if (type == TYPE_VIP || type == TYPE_STUDENT){
|
|
|
54
|
+ return true;
|
|
|
55
|
+ } else {
|
|
|
56
|
+ return false;
|
|
|
57
|
+ }
|
|
|
58
|
+ }
|
|
|
59
|
+
|
|
|
60
|
+ renderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
61
|
+ let productName = '商品名称';
|
|
|
62
|
+ let productPrice = '888.88';
|
|
|
63
|
+ let orginPrice = '999.999';
|
|
|
64
|
+ return (
|
|
|
65
|
+ <View style={styles.row}>
|
|
|
66
|
+ <Image style={styles.image}
|
|
|
67
|
+ source={this._getImageUrl(rowID)}
|
|
|
68
|
+ resizeMode={'cover'}/>
|
|
|
69
|
+ <Text style={styles.vipText} numberOfLines={1}>{productPrice}</Text>
|
|
|
70
|
+ {
|
|
|
71
|
+ this._isShowOrignPrice(type) ?
|
|
|
72
|
+ <View style={styles.vipContainer}>
|
|
|
73
|
+ <Text style={styles.discountText} numberOfLines={1}>{orginPrice}</Text>
|
|
|
74
|
+ {
|
|
|
75
|
+ this._isShowVip(type) ? <Image style={{width:33,height:12,marginLeft:2}}
|
|
|
76
|
+ source={require('../../images/ic_vip_red.png')}/> : null
|
|
|
77
|
+ }
|
|
|
78
|
+ </View> : null
|
|
|
79
|
+ }
|
|
|
80
|
+ </View>);
|
|
|
81
|
+ }
|
|
|
82
|
+
|
|
|
83
|
+ onPressBuy() {
|
|
|
84
|
+ console.log('buy');
|
|
|
85
|
+ }
|
|
|
86
|
+
|
|
|
87
|
+ render() {
|
|
|
88
|
+ let bannerData = Immutable.fromJS(
|
|
|
89
|
+ [{
|
|
|
90
|
+ "src": "http://img10.static.yhbimg.com/yhb-img01/2017/02/13/10/01d3b3208f7b4971396981debc758c7275.jpg?imageView2/{mode}/w/{width}/h/{height}",
|
|
|
91
|
+ "title": "",
|
|
|
92
|
+ "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\"}}"
|
|
|
93
|
+ }
|
|
|
94
|
+ ,
|
|
|
95
|
+ {
|
|
|
96
|
+ "src": "http://img10.static.yhbimg.com/yhb-img01/2017/02/13/10/01d3b3208f7b4971396981debc758c7275.jpg?imageView2/{mode}/w/{width}/h/{height}",
|
|
|
97
|
+ "title": "",
|
|
|
98
|
+ "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\"}}"
|
|
|
99
|
+ }
|
|
|
100
|
+ ]
|
99
|
);
|
101
|
);
|
100
|
- }
|
|
|
101
|
-
|
|
|
102
|
-};
|
102
|
+ let data = [1, 1, 1, 1, 1, 1];
|
|
|
103
|
+ let visible = true;
|
|
|
104
|
+ let cellH = this._isShowOrignPrice(type) ? cellHeight : cellHeight - 20;
|
|
|
105
|
+ return (
|
|
|
106
|
+ <View style={styles.container}>
|
|
|
107
|
+ <HeadTitleCell title={'VIP专享'}/>
|
|
|
108
|
+ <Banner
|
|
|
109
|
+ data={bannerData}
|
|
|
110
|
+ duration={8}
|
|
|
111
|
+ width={width}
|
|
|
112
|
+ height={bannerHeight}
|
|
|
113
|
+ onPress={this.onPressBanner}
|
|
|
114
|
+ />
|
|
|
115
|
+
|
|
|
116
|
+ <View style={styles.listContianer,{height:cellH}}>
|
|
|
117
|
+ {visible ?
|
|
|
118
|
+ <Image style={styles.listBg,{height:cellH}}
|
|
|
119
|
+ source={{uri: 'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'}}
|
|
|
120
|
+ resizeMode={'cover'}/> : null}
|
|
|
121
|
+ <ListView
|
|
|
122
|
+ style={{position:'absolute',left:0,top:5,paddingTop:12,paddingBottom:12}}
|
|
|
123
|
+ contentContainerStyle={styles.listContent}
|
|
|
124
|
+ horizontal={true}
|
|
|
125
|
+ dataSource={this.dataSource.cloneWithRows(data)}
|
|
|
126
|
+ renderRow={this.renderRow}
|
|
|
127
|
+ showsHorizontalScrollIndicator={false}
|
|
|
128
|
+ />
|
|
|
129
|
+ </View>
|
|
|
130
|
+ </View>
|
|
|
131
|
+ );
|
|
|
132
|
+ }
|
|
|
133
|
+}
|
103
|
|
134
|
|
104
|
let {width, height} = Dimensions.get('window');
|
135
|
let {width, height} = Dimensions.get('window');
|
105
|
-const DEVICE_WIDTH_RATIO = width / 320;
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-let styles = StyleSheet.create({
|
|
|
109
|
-
|
|
|
110
|
- container: {
|
|
|
111
|
- flexWrap: 'wrap',
|
136
|
+let bannerHeight = Math.ceil((234 / 750) * width);
|
|
|
137
|
+let sectionHeight = Math.ceil((419 / 750) * width);
|
|
|
138
|
+let cellWidth = 95;
|
|
|
139
|
+let cellHeight = 210;
|
|
|
140
|
+
|
|
|
141
|
+//1 VIP 专享 2 新人专享 3 学生专享 4 新品到着
|
|
|
142
|
+const TYPE_VIP = 1;
|
|
|
143
|
+const TYPE_NEW_USER = 2;
|
|
|
144
|
+const TYPE_STUDENT = 3;
|
|
|
145
|
+const TYPE_NEW_PRODUCT = 4;
|
|
|
146
|
+const type = TYPE_VIP;
|
|
|
147
|
+const styles = StyleSheet.create({
|
|
|
148
|
+ container: {
|
|
|
149
|
+ backgroundColor: 'white',
|
|
|
150
|
+ flex: 1
|
112
|
},
|
151
|
},
|
113
|
-
|
|
|
114
|
- contentContainer: {
|
|
|
115
|
- flexDirection: 'row',
|
|
|
116
|
- flexWrap: 'wrap',
|
|
|
117
|
- alignItems:'center',
|
|
|
118
|
- backgroundColor: '#f5f7f6',
|
|
|
119
|
- },
|
|
|
120
|
-
|
|
|
121
|
- headerContainer:{
|
|
|
122
|
- width: 210 * DEVICE_WIDTH_RATIO,
|
|
|
123
|
- height: 40 * DEVICE_WIDTH_RATIO,
|
|
|
124
|
- paddingLeft: 5 * DEVICE_WIDTH_RATIO,
|
|
|
125
|
- paddingRight: 5 * DEVICE_WIDTH_RATIO,
|
|
|
126
|
- backgroundColor: '#ffffff',
|
|
|
127
|
- },
|
|
|
128
|
-
|
|
|
129
|
- headerText:{
|
|
|
130
|
- position: 'absolute',
|
|
|
131
|
- left: 5 * DEVICE_WIDTH_RATIO,
|
|
|
132
|
- bottom: 11 * DEVICE_WIDTH_RATIO,
|
|
|
133
|
- fontSize: 12 * DEVICE_WIDTH_RATIO,
|
|
|
134
|
- color: '#B0B0B0',
|
|
|
135
|
- },
|
|
|
136
|
-
|
|
|
137
|
- headerMore:{
|
|
|
138
|
- position: 'absolute',
|
|
|
139
|
- right: 5 * DEVICE_WIDTH_RATIO,
|
|
|
140
|
- bottom: 11 * DEVICE_WIDTH_RATIO,
|
|
|
141
|
- flexDirection: 'row',
|
|
|
142
|
- justifyContent: 'center',
|
|
|
143
|
- alignItems: 'center',
|
|
|
144
|
- },
|
|
|
145
|
-
|
|
|
146
|
- headerMoreText:{
|
|
|
147
|
- fontSize: 10 * DEVICE_WIDTH_RATIO,
|
|
|
148
|
- color: '#B0B0B0',
|
|
|
149
|
- marginRight: 5 * DEVICE_WIDTH_RATIO,
|
|
|
150
|
- },
|
|
|
151
|
-
|
|
|
152
|
- headerMoreArrow: {
|
|
|
153
|
- width: 4 * DEVICE_WIDTH_RATIO,
|
|
|
154
|
- height: 7 * DEVICE_WIDTH_RATIO,
|
152
|
+ listContianer: {
|
|
|
153
|
+ alignItems: 'center',
|
|
|
154
|
+ },
|
|
|
155
|
+ listBg: {
|
|
|
156
|
+ width: width,
|
|
|
157
|
+ position: 'absolute',
|
|
|
158
|
+ top: 0,
|
|
|
159
|
+ left: 0,
|
|
|
160
|
+ },
|
|
|
161
|
+ listContent: {
|
|
|
162
|
+ backgroundColor: 'transparent',
|
|
|
163
|
+ flexDirection: 'row',
|
|
|
164
|
+ flexWrap: 'nowrap',
|
|
|
165
|
+ justifyContent: 'flex-start',
|
|
|
166
|
+ paddingHorizontal: 5,
|
|
|
167
|
+ },
|
|
|
168
|
+ row: {
|
|
|
169
|
+ flexDirection: 'column',
|
|
|
170
|
+ width: cellWidth,
|
|
|
171
|
+ backgroundColor: 'white',
|
|
|
172
|
+ borderRadius: 3,
|
|
|
173
|
+ justifyContent: 'center',
|
|
|
174
|
+ marginLeft: 6,
|
|
|
175
|
+ marginRight: 6
|
|
|
176
|
+ },
|
|
|
177
|
+ vipContainer: {
|
|
|
178
|
+ width: cellWidth,
|
|
|
179
|
+ height: 18,
|
|
|
180
|
+ flexDirection: 'row',
|
|
|
181
|
+ alignItems: 'center',
|
|
|
182
|
+ justifyContent: 'center',
|
|
|
183
|
+ marginBottom: 10
|
|
|
184
|
+ },
|
|
|
185
|
+ discountText: {
|
|
|
186
|
+ fontSize: 10,
|
|
|
187
|
+ textAlign: 'center',
|
|
|
188
|
+ color: '#b0b0b0',
|
|
|
189
|
+ textDecorationLine: 'line-through',
|
|
|
190
|
+ textDecorationStyle: 'solid',
|
|
|
191
|
+ textDecorationColor: '#d0021b'
|
|
|
192
|
+ },
|
|
|
193
|
+ vipText: {
|
|
|
194
|
+ color: '#d0021b',
|
|
|
195
|
+ flex: 1,
|
|
|
196
|
+ marginTop: 7,
|
|
|
197
|
+ marginBottom: 7,
|
|
|
198
|
+ textAlign: 'center',
|
|
|
199
|
+ fontSize: 12,
|
|
|
200
|
+ },
|
|
|
201
|
+ image: {
|
|
|
202
|
+ width: cellWidth,
|
|
|
203
|
+ height: 120,
|
155
|
},
|
204
|
},
|
156
|
-
|
|
|
157
|
- headerLine:{
|
|
|
158
|
- width: 200 * DEVICE_WIDTH_RATIO,
|
|
|
159
|
- height: 0.5 * DEVICE_WIDTH_RATIO,
|
|
|
160
|
- backgroundColor: '#E0E0E0',
|
|
|
161
|
- left: 0,
|
|
|
162
|
- top: 35 * DEVICE_WIDTH_RATIO,
|
|
|
163
|
- },
|
|
|
164
|
-
|
|
|
165
|
- rowContainer:{
|
|
|
166
|
- width: 70 * DEVICE_WIDTH_RATIO,
|
|
|
167
|
- height: 93 * DEVICE_WIDTH_RATIO,
|
|
|
168
|
- paddingLeft: 5 * DEVICE_WIDTH_RATIO,
|
|
|
169
|
- paddingRight: 5 * DEVICE_WIDTH_RATIO,
|
|
|
170
|
- justifyContent: 'center',
|
|
|
171
|
- alignItems: 'center',
|
|
|
172
|
- backgroundColor: '#f5f7f6',
|
|
|
173
|
- },
|
|
|
174
|
-
|
|
|
175
|
- rowThumbnail:{
|
|
|
176
|
- width: 48 * DEVICE_WIDTH_RATIO,
|
|
|
177
|
- height: 65 * DEVICE_WIDTH_RATIO,
|
|
|
178
|
- },
|
|
|
179
|
-
|
|
|
180
|
- rowTextContainer:{
|
|
|
181
|
- width: 53 * DEVICE_WIDTH_RATIO,
|
|
|
182
|
- height: 28 * DEVICE_WIDTH_RATIO,
|
|
|
183
|
- marginTop: 2 * DEVICE_WIDTH_RATIO,
|
|
|
184
|
- },
|
|
|
185
|
-
|
|
|
186
|
- rowText:{
|
|
|
187
|
- fontSize: 9 * DEVICE_WIDTH_RATIO,
|
|
|
188
|
- color: '#B0B0B0',
|
|
|
189
|
- textAlign: 'center',
|
|
|
190
|
- },
|
|
|
191
|
-
|
|
|
192
|
-
|
|
|
193
|
}); |
205
|
}); |
194
|
- |
|
|