<!-- 招聘会/企业详情 -->
<template>
  <view>
    <view class="box">
      <scroll-view class="scrollBox" :scroll-y="true" :scroll-top="scrollTop" @scrolltolower="loadingMore" @scroll="onScroll" style="position:relative;">
        <view>
          <!-- 顶部 -->
          <view class="white-bgc stick ss-p-t-10">
            <view class="titleBox">
              <view class="entName">{{ entName }}</view>
            </view>
          </view>
          <view v-if="listData?.length" class="listDataBox defaultBgc">
			      <PositionList
              class="pb-10"
              :list="listData"
              :noMore="false"
              :showEntInfo="false"
              :jobFairId="query.jobFairId"
              updateTimeAlign="left"
            ></PositionList>
            <uni-load-more :status="more" />
          </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>
        </view>
      </scroll-view>
    </view>
  </view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app'
import { ref, reactive } from 'vue'
import { dealDictObjData } from '@/utils/position'
import { getJobFairEntJobPage } from '@/api/jobFair'
import PositionList from '@/components/PositionList'

const more = ref('more')
const listData = ref([])
const query = reactive({
  pageSize: 20, 
  pageNo: 1,
  jobFairId: undefined,
  enterpriseId: undefined,
})

const entName = ref('')

onLoad(async (options) => {
  entName.value = options.entName
  if (options?.jobFairId) {
    query.jobFairId = options.jobFairId
    query.enterpriseId = options.enterpriseId
    getData()
	}
})

const getData = async () => {
  if (!query.jobFairId) {
    uni.showToast({ title: '获取企业岗位失败，请重试！', icon: 'none', duration: 2000 })
    return
  }
  try {
    const res = await getJobFairEntJobPage(query)
    const list = res?.data?.list || []
    list.forEach(e => {
      e.job = dealDictObjData({}, e)
    })
    listData.value = listData.value.concat(list)
    if (listData.value?.length === +res?.data?.total) {
      more.value = 'noMore'
      return
    }
  } catch (error) {
    query.pageNo--
    more.value = 'more'
  }
}

const scrollTop = ref(0)
const old = ref({
  scrollTop: 0
})
const onScroll = (e) =>{
  old.value.scrollTop = e.detail.scrollTop
}

// 加载更多
const loadingMore = () => {
  more.value = 'loading'
  query.pageNo++
  getData()
}

// const goBack = () => {
// 	uni.navigateTo({
// 		url: '/pagesB/jobFair/index'
// 	})
// }

</script>

<style scoped lang="scss">
.stick {
  z-index: 1;
  position: sticky;
  top: 0;
}
.stickFilter {
  z-index: 1;
  position: sticky;
  box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  top: 120rpx;
}
.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.pb-10 {
  padding-bottom: 10px;
}
.pb-20 { padding-bottom: 20px; }
.px-5 { padding-left: 5px; padding-right: 5px; }
.px-10 { padding-left: 10px; padding-right: 10px; }
.mx-10 { margin-left: 10px; margin-right: 10px }
.mx-20 { margin-left: 20px; margin-right: 20px; }
.mb-10 { margin-bottom: 10px; }
.box {
  height: 100vh;
  overflow: hidden;
  // padding-bottom: 120rpx;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.listDataBox {
  padding: 1px 0 120rpx;
  // padding-bottom: 120rpx;
  margin: 0 30rpx;
}
.scrollBox{
  flex: 1;
  height: 0 !important;
  padding-bottom: 24rpx;
  box-sizing: border-box;
}
:deep(.uni-searchbar__box) {
  width: calc(100% - 105px);
  height: 40px !important;
  border: 1px solid #00897B;
  padding-right: 20px;
  flex: none;
}
.search-btn {
  position: absolute;
  right: 11px;
  top: 10px;
  width: 110px;
  height: 40px;
  font-size: 16px;
  background-color: #00897B;
  color: #fff;
  border-radius: 0 5px 5px 0;
  z-index: 9;
}
.goBack {
  width: 110px;
  height: 32px;
  font-size: 13px;
  background-color: #00897B;
  color: #fff;
  // border-radius: 0 5px 5px 0;
  z-index: 9;
}
:deep(.picker-view) {
  padding-bottom: 80px !important;
}

.jobCount {
  height: 40px;
  line-height: 40px;
  color: #fff;
  text-align: center;
  font-size: 15px;
  background: linear-gradient(to right, #12ebb0, #427daa);
}

:deep(.uni-card) {
  padding: 0 !important;
  .uni-card__content {
    padding: 0 !important;
  }
}

.enterpriseName {
  color: #404040;
  font-weight: 700;
}
.enterAvatar {
  width: 60px;
  height: 60px;
  // border-radius: 50%;
  margin: auto;
}
.titleBox {
  text-align: center;
  padding: 0 20rpx 15px;
  .title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
  }
  .entName {
    color: #999;
  }
}
</style>
