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

export default function Banner (props) {
  const { List = [] } = props

  const handleBannerClick = (item) => {
    if (item.contentType && item.contentType != "nothing") {
      nav2Target(item)
    } 
  }
  return (
    <view className='components Banner'>
      <Swiper autoplay interval={2000} indicator-dots>
        {
          List.map((item, index) => (
            <SwiperItem key={`Banner-${index}`}>
              <view className='swiper-item'>
                <Image mode='aspectFill' className='centerLabel' onClick={()=>handleBannerClick(item)} src={getImgURL(item.image)} />
              </view>
            </SwiperItem>
          ))
        }
      </Swiper>
    </view>
  )
}
