...
|
...
|
@@ -15,6 +15,8 @@ import ReactNative, { |
|
|
NativeAppEventEmitter,
|
|
|
StyleSheet,
|
|
|
} from 'react-native';
|
|
|
import SingleImage from './SingleImage';
|
|
|
|
|
|
import {SlicedImage} from '../../../common/components/SlicedImage';
|
|
|
|
|
|
|
...
|
...
|
@@ -27,30 +29,28 @@ export default class BrandArticleCell extends Component { |
|
|
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//时间和访问次数以及是否喜欢
|
|
|
_renderTimeAndVisit(time, visit, likeNum, id, isliked){
|
|
|
_renderTimeAndVisit(time, visit, likeNum, id, rowID, isliked){
|
|
|
|
|
|
let likeicon = isliked ? require("../../images/like_on.png") : require("../../images/like_off.png");
|
|
|
let likestyle = isliked ? styles.darkgrayfont : styles.grayfont;
|
|
|
|
|
|
return (
|
|
|
<View style={styles.timebar}>
|
|
|
<Text style={styles.time} numberOfLines={1}>{time} </Text>
|
|
|
<Image style={styles.timeicon} source={require("../../images/time_icon.png")} />
|
|
|
<Text style={styles.grayfont} numberOfLines={1}>{time} </Text>
|
|
|
|
|
|
<Text style={styles.time} numberOfLines={1}>{visit} </Text>
|
|
|
<Image style={styles.eyeicon} source={require("../../images/eye_icon.png")} />
|
|
|
<Text style={styles.grayfont} numberOfLines={1}>{visit} </Text>
|
|
|
|
|
|
<TouchableOpacity
|
|
|
style={styles.likecontainer}
|
|
|
activeOpacity={1}
|
|
|
onPress={()=>{
|
|
|
this.props.onPressArticleLike && this.props.onPressArticleLike(id, !isliked)
|
|
|
this.props.onPressArticleLike && this.props.onPressArticleLike(id, rowID, !isliked, likeNum)
|
|
|
}}>
|
|
|
<Image style={styles.likeicon} source={likeicon} />
|
|
|
|
|
|
<Text style={styles.time} numberOfLines={1}>{likeNum}</Text>
|
|
|
<Text style={likestyle} numberOfLines={1}>{likeNum}</Text>
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
|
...
|
...
|
@@ -61,7 +61,7 @@ export default class BrandArticleCell extends Component { |
|
|
|
|
|
|
|
|
render() {
|
|
|
let {rowData} = this.props;
|
|
|
let {rowData, rowID} = this.props;
|
|
|
//url跳转地址
|
|
|
let url = rowData.get('url');
|
|
|
//id
|
...
|
...
|
@@ -69,9 +69,8 @@ export default class BrandArticleCell extends Component { |
|
|
//标题
|
|
|
let title = rowData.get('title');
|
|
|
//图片
|
|
|
let imgUrl = rowData.get('src').replace('{mode}', 2).replace('{width}', 290).replace('{height}', 386);
|
|
|
//imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'), 290, 386, 2);
|
|
|
//let brandIconUrl = SlicedImage.getSlicedUrl(data.get('brand_img', ''), 150, 80, 2);
|
|
|
let imgUrl = rowData.get('src').replace('{mode}', 2).replace('{width}', width).replace('{height}', width);
|
|
|
// let imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'), width, width, 2);
|
|
|
//介绍
|
|
|
let intro = rowData.get('intro');
|
|
|
//发布时间
|
...
|
...
|
@@ -79,11 +78,11 @@ export default class BrandArticleCell extends Component { |
|
|
//访问次数
|
|
|
let viewsNum = rowData.get('views_num');
|
|
|
//喜欢信息
|
|
|
let like = rowData.get('like');
|
|
|
let likedata = rowData.get('like');
|
|
|
//是否喜欢
|
|
|
let isLiked = like.get("isLiked");
|
|
|
let isLiked = likedata ? likedata.get("isLiked") : false;
|
|
|
//喜欢人数
|
|
|
let likeCount = like.get("count");
|
|
|
let likeCount = likedata ? likedata.get("count") : "0";
|
|
|
|
|
|
return (
|
|
|
<View style={styles.cellContainer}>
|
...
|
...
|
@@ -95,7 +94,7 @@ export default class BrandArticleCell extends Component { |
|
|
this.props.onPressArticle && this.props.onPressArticle(url)
|
|
|
}}>
|
|
|
|
|
|
<Image style={styles.image} source={{uri:imgUrl}} />
|
|
|
<SingleImage source={imgUrl} />
|
|
|
|
|
|
<Text style={styles.title}>{title}</Text>
|
|
|
|
...
|
...
|
@@ -103,7 +102,7 @@ export default class BrandArticleCell extends Component { |
|
|
|
|
|
<Text style={styles.content} numberOfLines={4}>{intro}</Text>
|
|
|
|
|
|
{this._renderTimeAndVisit(publishTime, viewsNum, likeCount, id, isLiked)}
|
|
|
{this._renderTimeAndVisit(publishTime, viewsNum, likeCount, id, rowID, isLiked)}
|
|
|
|
|
|
|
|
|
</View>
|
...
|
...
|
@@ -121,11 +120,10 @@ let styles = StyleSheet.create({ |
|
|
touchableContainer: {
|
|
|
width: width,
|
|
|
},
|
|
|
image: {
|
|
|
width: width,
|
|
|
height: width / 1.5,
|
|
|
},
|
|
|
|
|
|
// image: {
|
|
|
// width: width,
|
|
|
// height: Math.ceil(width * 410 / 655),
|
|
|
// },
|
|
|
|
|
|
title:{
|
|
|
width: width,
|
...
|
...
|
@@ -139,24 +137,49 @@ let styles = StyleSheet.create({ |
|
|
content:{
|
|
|
width: width,
|
|
|
fontSize: 15,
|
|
|
color: '#999999',
|
|
|
color: '#3E3A39',
|
|
|
paddingLeft: 15,
|
|
|
paddingRight: 15,
|
|
|
paddingBottom:5,
|
|
|
},
|
|
|
timebar:{
|
|
|
width: width,
|
|
|
height: 30,
|
|
|
flexDirection: 'row',
|
|
|
justifyContent: 'center',
|
|
|
alignItems: 'center',
|
|
|
paddingLeft: 15,
|
|
|
paddingRight: 15,
|
|
|
paddingBottom:5,
|
|
|
},
|
|
|
time:{
|
|
|
likecontainer:{
|
|
|
flex: 1,
|
|
|
flexDirection: 'row',
|
|
|
justifyContent: 'flex-end',
|
|
|
|
|
|
},
|
|
|
grayfont:{
|
|
|
fontSize: 15,
|
|
|
color: '#b0b0b0',
|
|
|
color: '#A5A5A5',
|
|
|
marginLeft: 5,
|
|
|
},
|
|
|
darkgrayfont:{
|
|
|
fontSize: 15,
|
|
|
color: '#444444',
|
|
|
marginLeft: 5,
|
|
|
},
|
|
|
timeicon:{
|
|
|
width: 12,
|
|
|
height:12,
|
|
|
},
|
|
|
eyeicon:{
|
|
|
width: 16,
|
|
|
height:12,
|
|
|
marginLeft: 6,
|
|
|
},
|
|
|
likeicon:{
|
|
|
width: 20,
|
|
|
height:20,
|
|
|
width: 18,
|
|
|
height:17,
|
|
|
marginTop: 1,
|
|
|
},
|
|
|
}); |
...
|
...
|
|