import { useEffect, useState } from 'react'
import { Swiper } from '@nutui/nutui-react-taro'
import {CmsAd} from "@/api/cms/cmsAd/model";
import {Image} from '@nutui/nutui-react-taro'
import {getCmsAdByCode} from "@/api/cms/cmsAd";

const MyPage = () => {
  const [item, setItem] = useState<CmsAd>()
  const reload = async () => {
    const flash = await getCmsAdByCode('flash')
    console.log(flash)
    setItem(flash)
  }

  useEffect(() => {
    reload().then()
  }, [])

  return (
    <>
      <Swiper defaultValue={0} height={item?.height} indicator style={{ height: item?.height + 'px' }}>
        {item?.imageList?.map((item) => (
          <Swiper.Item key={item}>
            <Image width="100%" height="100%" src={item.url} mode={'scaleToFill'} lazyLoad={false} style={{ height: item.height + 'px' }} />
          </Swiper.Item>
        ))}
      </Swiper>
    </>
  )
}
export default MyPage
