|
|
'use strict';
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
import ReactNative, {
|
|
|
View,
|
|
|
Text,
|
|
|
Image,
|
|
|
ListView,
|
|
|
TouchableOpacity,
|
|
|
StyleSheet,
|
|
|
Dimensions,
|
|
|
} from 'react-native';
|
|
|
import Immutable, {Map, List} from 'immutable';
|
|
|
|
|
|
import YH_Image from '../../../common/components/YH_Image';
|
|
|
import DeleteLineText from '../../../common/components/DeleteLineText';
|
|
|
|
|
|
export default class ProductCell extends Component{
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let data = this.props.data;
|
|
|
|
|
|
let prdImage = YH_Image.getSlicedUrl(data.get('image', ''), 113, 150, 2);
|
|
|
|
|
|
let salePrice = 0; // 售卖价
|
|
|
let originPrice = 0; // 原价
|
|
|
let salePriceStr = ''; // 拼接的售卖价
|
|
|
let originPriceStr = ''; // 拼接的原价
|
|
|
let showOriginPrice = true; // 是否显示原价
|
|
|
let salePriceColor = '#d0021b'; // 不显示原价时,售卖价颜色
|
|
|
|
|
|
salePrice = parseFloat(data.get('sales_price'));
|
|
|
originPrice = parseFloat(data.get('market_price'));
|
|
|
salePriceStr = '¥' + salePrice.toFixed(2);
|
|
|
originPriceStr = '¥' + originPrice.toFixed(2);
|
|
|
|
|
|
if (!originPrice || (salePrice == originPrice)) {
|
|
|
showOriginPrice = false;
|
|
|
salePriceColor = '#444444';
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<YH_Image style={styles.prdImage} url={prdImage} />
|
|
|
<View style={styles.leftContainer}>
|
|
|
<Text>{data.get('product_name', '')}</Text>
|
|
|
<View style={styles.priceContainer}>
|
|
|
<Text style={[styles.nowPrice, {color: salePriceColor}]} numberOfLines={1}>{salePriceStr}</Text>
|
|
|
{showOriginPrice ? <DeleteLineText
|
|
|
style={styles.oldPriceContainer}
|
|
|
textStyle={styles.oldPrice}
|
|
|
lineStyle={styles.deleteLine}
|
|
|
text={originPriceStr}
|
|
|
/> : null}
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let {width} = Dimensions.get('window');
|
|
|
const DEVICE_WIDTH_RATIO = width / 320;
|
|
|
|
|
|
let imageWidth = Math.floor(width / 2);
|
|
|
let imageHeight = Math.floor(imageWidth * 180 / 375);
|
|
|
|
|
|
let topRightWidth = Math.ceil(80 * DEVICE_WIDTH_RATIO);
|
|
|
let topLeftWidth = width - Math.ceil(84 * DEVICE_WIDTH_RATIO);
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flexDirection: 'column',
|
|
|
width: width,
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
prdImage: {
|
|
|
width: 113,
|
|
|
height: 150,
|
|
|
},
|
|
|
priceContainer: {
|
|
|
flexDirection: 'row',
|
|
|
justifyContent: 'center',
|
|
|
marginTop: 10,
|
|
|
},
|
|
|
nowPrice: {
|
|
|
fontSize: 10,
|
|
|
color: '#d0021b',
|
|
|
},
|
|
|
oldPriceContainer: {
|
|
|
flexDirection: 'row',
|
|
|
marginLeft: 5,
|
|
|
},
|
|
|
oldPrice: {
|
|
|
fontSize: 10,
|
|
|
color: '#b0b0b0',
|
|
|
height: 16,
|
|
|
},
|
|
|
deleteLine: {
|
|
|
position: 'absolute',
|
|
|
top: (16 / 2) - 2,
|
|
|
left: 0,
|
|
|
right: 0,
|
|
|
height: 1,
|
|
|
backgroundColor: '#b0b0b0',
|
|
|
},
|
|
|
}); |
...
|
...
|
|