import React, { useState, useEffect } from 'react'
import './index.scss'
import { Image } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { getImgURL } from "@/utils/image";
import { formatDate } from "@/utils/chatDate";

export default function NewsListItem (props) {
  const { data = {} } = props
  console.log(data,'data')
  return (
    <view className='components NewsListItem flex-h' onClick={() => { Taro.navigateTo({ url: `/pages/index/newsDetail/index?id=${data.newsId}` }) }}>
      <view className='Img'>
        <Image mode='aspectFill' src={getImgURL(data.newsImg)} className='centerLabel'></Image>
      </view>
      <view className='flex-item'>
        <text>{data.newsName}</text>
        <text>于{formatDate(data.createDate, "yyyy-M-d")}发布</text>
      </view>
    </view>
  )
}
