import Taro from '@tarojs/taro'
import { getImgURL } from '@/utils/image'
import { Image } from '@tarojs/components'
import './index.scss'

export default function VideoListItem (props) {
  const { Data = {} } = props

  const toDetail=()=>{
    if(Data.type=='video'){
      Taro.navigateTo({ url: `/pages/video/videoDetail/index?id=${Data.id}` })
    }else{
      Taro.navigateTo({ url: `/pages/video/liveDetail/index?id=${Data.id}` })
    }
    // 
  }
  // onClick={()=>{}
  return (
    <view className='components VideoListItem' onClick={()=>toDetail()}>
      <view className='Img'>
        <view>
          <Image mode='aspectFill' className='centerLabel' src={getImgURL(Data.images || Data.videImg) || null} />
          {
            Data.type === 'live' && new Date(Data.startTime).getTime() <= Date.now() &&
            <text className='active'>直播中</text>
          }
          {
            Data.type === 'live' && new Date(Data.startTime).getTime() > Date.now() &&
            <text>预告</text>
          }
          {
            Data.type === 'video' &&
            <Image mode='aspectFill' className='centerLabel Icon' src={require('@/assets/index-icon19.png')} />
          }
        </view>
      </view>
      <view className='Title'>
        <text>{Data.title || Data.name}</text>
      </view>
      <view className='Location flex-h'>
        <text className='iconfont icon-dingwei'></text>
        <view className='flex-item'>
          <view>
            <text>{Data.buildingName}</text>
          </view>
        </view>
      </view>
    </view>
  )
}
