Authored by 孙凯

修改 价格显示问题 review by zhanglixia

... ... @@ -4,6 +4,7 @@ import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import BrandProductListCell from '../../../common/components/ListCell/ProductListCell';
import DeleteLineText from '../../../common/components/DeleteLineText';
const {
AppRegistry,
... ... @@ -35,7 +36,6 @@ export default class GoodsCell extends React.Component {
}
}
renderRow(rowData, sectionID, rowID, highlightRow) {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
... ... @@ -76,9 +76,32 @@ export default class GoodsCell extends React.Component {
let obj = list0[0];
let product_name = obj.product_name;
let default_images = obj.default_images;
let sales_price = obj.sales_price;
console.log(obj);
let isGlobalProduct = obj.is_global && obj.is_global == 'Y'; // 是否全球购商品
let salePrice = 0; // 售卖价
let originPrice = 0; // 原价
let salePriceStr = ''; // 拼接的售卖价
let originPriceStr = ''; // 拼接的原价
let showOriginPrice = true; // 是否显示原价
let salePriceColor = '#d0021b'; // 不显示原价时,售卖价颜色
if (isGlobalProduct) {
salePrice = parseFloat(obj.final_price);
originPrice = parseFloat(obj.orign_price);
salePriceStr = obj.formart_final_price;
originPriceStr = obj.formart_orign_price;
} else {
salePrice = parseFloat(obj.sales_price);
originPrice = parseFloat(obj.market_price);
salePriceStr = '¥' + salePrice.toFixed(2);
originPriceStr = '¥' + originPrice.toFixed(2);
}
if (!originPrice || (salePrice == originPrice)) {
showOriginPrice = false;
salePriceColor = '#444444';
}
return(
<View style={{width: backgroundWidth, height:backgroundHeight, backgroundColor:'white'}}>
<View style={styles.titleB}>
... ... @@ -91,8 +114,17 @@ export default class GoodsCell extends React.Component {
<Image source={{uri: default_images}} style={styles.timeThumb} resizeMode={'contain'}></Image>
<View style={styles.nameView}>
<Text style={styles.name}>{product_name}</Text>
<View style={styles.salesView}>
<Text style={styles.sales}>¥{sales_price}</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>
<TouchableOpacity activeOpacity={0.5} onPress={() => {
// this.props.onPressBrandItem && this.props.onPressBrandItem(rowData.url, rowID);
}}>
... ... @@ -169,7 +201,7 @@ let styles = StyleSheet.create({
backgroundColor: 'white',
},
name: {
marginTop: 30,
marginTop: 20,
marginLeft:15,
height: 20,
width:width,
... ... @@ -182,12 +214,6 @@ let styles = StyleSheet.create({
width:width - 80,
backgroundColor: 'white',
},
sales: {
height: 20,
width: 100,
marginLeft: 15,
backgroundColor: 'white',
},
button: {
height: 20,
width: 60,
... ... @@ -199,8 +225,38 @@ let styles = StyleSheet.create({
borderRadius: 2,
},
timeThumb: {
marginTop: 10,
marginLeft: 20,
height: 80,
height: 50,
width:40,
backgroundColor: 'white',
},
priceContainer: {
marginLeft: 15,
flexDirection: 'row',
marginTop: 1,
alignItems: 'center',
justifyContent: 'center',
},
nowPrice: {
fontSize: 12,
color: '#d0021b',
},
oldPriceContainer: {
flexDirection: 'row',
marginLeft: 5,
},
oldPrice: {
fontSize: 12,
color: '#b0b0b0',
height: 16,
},
deleteLine: {
position: 'absolute',
top: (16 / 2) - 0.8,
left: 0,
right: 0,
height: 1,
backgroundColor: '#b0b0b0',
},
});
... ...