recommend.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="box defaultBgc">
  3. <view style="padding: 10px">
  4. <uni-data-select
  5. v-model="query.jobId"
  6. :clear="false"
  7. :localdata="jobList"
  8. @change="handleChangeJob"
  9. placeholder="招聘中职位"
  10. ></uni-data-select>
  11. </view>
  12. <scroll-view class="scrollBox" :scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  13. <TalentItem v-if="items?.length || more !== 'loading'" :items="items" />
  14. <uni-load-more v-if="items?.length" :status="more" />
  15. <view v-if="!jobList?.length" class="noJobId text-center">暂无正在招聘中的职位</view>
  16. <view v-if="jobList?.length && !items?.length" class="noJobId">
  17. <view>请先选择上方正在招聘的职位</view>
  18. <view>我们将根据您选择的职位为您推荐合适的人才</view>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. </template>
  23. <script setup>
  24. import { ref } from 'vue'
  25. import TalentItem from './talentItem.vue'
  26. import { getPersonRecommendPage } from '@/api/search'
  27. import { dealDictArrayData } from '@/utils/position'
  28. defineProps({ jobList: Array, navbarHeight: [Number, String] })
  29. const query = ref({
  30. pageNo: 1,
  31. paeSize: 20,
  32. jobId: null
  33. })
  34. const items = ref([])
  35. const more = ref('noMore')
  36. const total = ref(0)
  37. // 根据职位id获取推荐人才列表
  38. const getRecommendList = async (loading = false) => {
  39. if (loading) uni.showLoading({ title: '加载中' })
  40. try {
  41. more.value = 'loading'
  42. const { data } = await getPersonRecommendPage(query.value)
  43. if (!data.list.length) {
  44. more.value = 'noMore'
  45. return
  46. }
  47. const list = dealDictArrayData([], data.list)
  48. items.value = items.value.concat(list)
  49. total.value = data.total
  50. if (items.value.length === +data.total) {
  51. more.value = 'noMore'
  52. return
  53. }
  54. } catch {
  55. query.value.pageNo--
  56. more.value = 'more'
  57. } finally {
  58. if (loading) uni.hideLoading()
  59. }
  60. }
  61. getRecommendList()
  62. // 选择招聘中职位
  63. const handleChangeJob = () => {
  64. query.value.pageNo = 1
  65. items.value = []
  66. total.value = 0
  67. getRecommendList(true)
  68. }
  69. // 加载更多
  70. const loadingMore = () => {
  71. if (more.value === 'noMore') return
  72. more.value = 'loading'
  73. query.value.pageNo++
  74. getRecommendList()
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. .noJobId {
  79. display: flex;
  80. flex-direction: column;
  81. margin-top: 26vh;
  82. color: #666;
  83. padding: 0 30rpx;
  84. view {
  85. text-align: center;
  86. margin-top: 4px;
  87. }
  88. }
  89. .box {
  90. height: 100vh;
  91. overflow: hidden;
  92. box-sizing: border-box;
  93. display: flex;
  94. flex-direction: column;
  95. }
  96. .scrollBox{
  97. flex: 1;
  98. padding-bottom: 100px;
  99. box-sizing: border-box;
  100. height: 0 !important;
  101. }
  102. // .stick {
  103. // z-index: 1;
  104. // position: sticky;
  105. // background-color: #fff;
  106. // }
  107. </style>