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

export default function WuYeBaoXiu () {

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

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

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

  return (
    <view className='WuYeBaoXiu'>
      <ScrollPageRefresh ApiName={`getGongDanList`} ListName={`pagelist`} RequestUrlData={{ orgId: user.orgId }} RequestParams={{ type: 2 }} Refresh={Refresh} Push={Push}>

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

        {/* 我要报修 */}
        <view className='WoYaoBaoXiu'>
          <view onClick={() => { Taro.navigateTo({ url: `/pages/WuYe/BaoXiuQuYu/index` }) }}>
            <text className='iconfont iconjia'></text>
            <text>我要报修</text>
          </view>
        </view>

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

      </ScrollPageRefresh>
    </view>
  )
}
