<template>
  <view class="defaultBgc">
    <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="height: 100vh;">
      <view v-if="items.length">
        <PositionList class="pb-10" :list="items" :noMore="false"></PositionList>
        <uni-load-more :status="status" />
      </view>
      <view v-else class="nodata-img-parent">
        <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
      </view>
    </scroll-view>
  </view>
</template>

<script setup>
import { ref } from 'vue'
import { getJobFavoriteList } from '@/api/user'
import { dealDictObjData } from '@/utils/position'
import PositionList from '@/pagesB/positionList/index'

const status = ref('more')
const queryParams = ref({
  pageSize: 10,
  pageNo: 1
})
const items = ref([])

const getList = async () => {
  const { data } = await getJobFavoriteList(queryParams.value)
  const list = data?.list || []
  if (list?.length) {
    list.forEach(e => {
      e.job = { ...e.job, ...dealDictObjData({}, e.job) }
      e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
    })
    items.value = items.value.concat(list)
  }
  status.value = list?.length < queryParams.value.pageSize ? 'noMore' : 'more'
}
getList()

const loadingMore = () => {
  status.value = 'loading'
  queryParams.value.pageNo++
  getList()
}
</script>

<style scoped lang="scss">

</style>
