
import { Swiper, SwiperItem, Image } from '@tarojs/components'
import { getImgURL } from '@/utils/image'
import './index.scss'

export default function Banner (props) {
  const { List, onClick } = props
  return (
    <view className='components Banner'>
      <Swiper autoplay interval={2000} indicator-dots>
        {
          (List||[]).map((item, index) => (
            <SwiperItem key={`Banner-${index}`}>
              <view className='swiper-item' onClick={() => onClick(item, List)}>
                <Image mode='aspectFill' className='centerLabel' src={getImgURL(item.image || item.coverImg || item.url || item.img)} />
              </view>
            </SwiperItem>
          ))
        }
      </Swiper>
    </view>
  )
}
