recommend.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 () => {
  39. try {
  40. more.value = 'loading'
  41. const { data } = await getPersonRecommendPage(query.value)
  42. if (!data.list.length) {
  43. more.value = 'noMore'
  44. return
  45. }
  46. const list = dealDictArrayData([], data.list)
  47. items.value = items.value.concat(list)
  48. total.value = data.total
  49. if (items.value.length === +data.total) {
  50. more.value = 'noMore'
  51. return
  52. }
  53. } catch {
  54. query.value.pageNo--
  55. more.value = 'more'
  56. }
  57. }
  58. getRecommendList()
  59. // 选择招聘中职位
  60. const handleChangeJob = () => {
  61. query.value.pageNo = 1
  62. items.value = []
  63. total.value = 0
  64. getRecommendList()
  65. }
  66. // 加载更多
  67. const loadingMore = () => {
  68. if (more.value === 'noMore') return
  69. more.value = 'loading'
  70. query.value.pageNo++
  71. getRecommendList()
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .noJobId {
  76. display: flex;
  77. flex-direction: column;
  78. margin-top: 26vh;
  79. color: #666;
  80. padding: 0 30rpx;
  81. view {
  82. text-align: center;
  83. margin-top: 4px;
  84. }
  85. }
  86. .box {
  87. height: 100vh;
  88. overflow: hidden;
  89. box-sizing: border-box;
  90. display: flex;
  91. flex-direction: column;
  92. }
  93. .scrollBox{
  94. flex: 1;
  95. padding-bottom: 100px;
  96. box-sizing: border-box;
  97. height: 0 !important;
  98. }
  99. // .stick {
  100. // z-index: 1;
  101. // position: sticky;
  102. // background-color: #fff;
  103. // }
  104. </style>