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