import React, { useState } from 'react'
import { useModel } from '@/store'
import WuYeGongGaoItem from '@/components/WuYeGongGaoItem/index'
import ScrollPageRefresh from '@/components/ScrollPageRefresh/index'
import '@/assets/css/reset.less'
import '@/assets/css/iconfont.less'
import './index.less'

export default function WuYeGongGao () {

  const { user } = useModel('user')
  const [PageList, setPageList] = useState([])

  const Refresh = (e) => { // 下拉刷新
    setPageList(e)
  }

  const Push = (e) => { // 上拉加载
    setPageList(PageList.concat(e))
  }

  return (
    <view className='WuYeGongGao'>
      <ScrollPageRefresh ApiName={`getGongGaoList`} RequestUrlData={{ orgId: user.orgId }} Refresh={Refresh} Push={Push}>

        {/* 大图 */}
        <view className='BigImg'>
          <image mode='aspectFill' src={null} className='centerLabel'></image>
        </view>

        {/* 列表 */}
        <view className='List'>
          {
            PageList.map((item, index) => (
              <view key={`WuYeGongGaoItem-${index}`}>
                <WuYeGongGaoItem Data={item}></WuYeGongGaoItem>
              </view>
            ))
          }
        </view>

      </ScrollPageRefresh>
    </view>
  )
}
