VipUserFloor.js
5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
* Description:
* vipUse:VIP专享
* Author: Bruce.Lu
* Version: 1.0
* Created on 2017/2/14.
*/
import React, {Component} from 'react';
import ReactNative, {
Image,
Text,
StyleSheet,
ListView,
View,
TouchableOpacity,
Dimensions,
} from 'react-native';
import Swiper from 'react-native-swiper';
import ImmutablePropTypes from 'react-immutable-proptypes';
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.renderRow = this.renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
renderRow(rowData, sectionID, rowID, highlightRow) {
let productName = rowData.get('product_name');;
let productPrice = '¥'+rowData.get('vip1_price').toFixed(2);
let orginPrice = '¥'+rowData.get('market_price').toFixed(2);
let productId = rowData.get('product_id');
let productSkn = rowData.get('product_skn');
let imgUrl = SlicedImage.getSlicedUrl(rowData.get('default_images'),cellWidth,120,2);
return (
<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>
</TouchableOpacity>);
}
render() {
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={title} moreUrl={moreUrl}/>
<Banner
data={bannerData}
duration={8}
width={width}
height={bannerHeight}
onPress={this.props.onPressVipBannerItem}
/>
<View style={styles.listContianer}>
{visible ?
<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(productData.toArray())}
renderRow={this.renderRow}
showsHorizontalScrollIndicator={false}
/>
</View>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let bannerHeight = Math.ceil((234 / 750) * width);
let sectionHeight = Math.ceil((419 / 750) * width);
let cellWidth = 90;
let cellHeight = 210;
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
},
listContianer: {
width:width,
height: cellHeight,
alignItems: 'center',
},
listBg: {
width: width,
height: cellHeight,
},
listContent: {
backgroundColor: 'transparent',
flexDirection: 'row',
flexWrap: 'nowrap',
justifyContent: 'flex-start',
paddingHorizontal: 5,
},
row: {
flexDirection: 'column',
width: cellWidth,
backgroundColor: '#f0f0f0',
borderRadius: 3,
justifyContent: 'center',
marginLeft: 6,
marginRight: 6
},
vipContainer: {
width: cellWidth,
height: 18,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
marginBottom: 10
},
discountText: {
fontSize: 10,
textAlign: 'center',
color: '#b0b0b0',
textDecorationLine: 'line-through',
textDecorationStyle: 'solid',
textDecorationColor: '#d0021b'
},
vipText: {
color: '#d0021b',
flex: 1,
marginTop: 7,
marginBottom: 7,
textAlign: 'center',
fontSize: 12,
},
image: {
width: cellWidth,
height: 120,
},
});