import Taro, { Component } from '@tarojs/taro';
import dayjs from 'dayjs'
import './item.scss'
import { getThumbnail } from '@utils/tools'

export default class NewsItem extends Component {
  static defaultProps = {
    data: []
  }
  handleClick() {
    this.props.onClick(this.props.data)
  }
  render() {
    const { data } = this.props
    return (
      <View className="item" key={data.newsId} onClick={this.handleClick}>
        <Image className="item-img"  src={getThumbnail(data.newsImg)}></Image>
        <View className="item-con">
          <View className="item-con__title">{data.newsName}</View>
          <View className="item-con__date">于{dayjs(data.createDate).format('YYYY-MM-DD  HH:mm:ss')}发布</View>
        </View>
      </View>
    );
  }
}