SingleFocusProduct.js
2.18 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
'use strict';
import React from 'react';
import ReactNative, {StyleSheet,View,TouchableOpacity,Text,Image} from 'react-native';
import Immutable from 'immutable';
import YH_Image from '../../../common/components/YH_Image';
const {Dimensions} = ReactNative;
export default class SingleFocusProduct extends React.Component {
constructor(props) {
super(props);
}
shouldComponentUpdate(nextProps) {
if (Immutable.is(nextProps.data, this.props.data)) {
return false;
} else {
return true;
}
}
render() {
let {data} = this.props;
let prdImage = YH_Image.getSlicedUrl(data.default_images, 107, 142, 2);
return (
<View style={styles.container}>
<TouchableOpacity activeOpacity={1} style={styles.prdImage} onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(Immutable.fromJS(data),null);
}}>
<YH_Image style={styles.prdImage} url={prdImage}/>
</TouchableOpacity>
<Text style={styles.nowPrice} numberOfLines={1}>¥{data.sales_price || '-'}</Text>
<View style={styles.priceReturnContainer}>
<Image source={require('../../images/money_back.png')} />
<Text style={styles.returnPrice} numberOfLines={1}>¥{data.rebates_amount || '-'}</Text>
</View>
</View>
)
}
}
let {width} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 375;
let styles = StyleSheet.create({
container: {
height: 210*DEVICE_WIDTH_RATIO,
width: 107*DEVICE_WIDTH_RATIO,
flexDirection: 'column',
},
prdImage: {
width: 107*DEVICE_WIDTH_RATIO,
height: 142*DEVICE_WIDTH_RATIO
},
nowPrice: {
fontSize: 12,
color: '#222222',
fontFamily: 'PingFang-SC-Regular',
marginTop: 10*DEVICE_WIDTH_RATIO,
},
priceReturnContainer: {
flexDirection: 'row',
marginTop: 10*DEVICE_WIDTH_RATIO,
},
returnPrice: {
fontSize: 16,
color: '#d0021b',
marginLeft: 3,
fontWeight: 'bold',
}
})