recommend.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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="query.jobId && (items?.length || more !== 'loading')" :items="items" />
  14. <uni-load-more v-if="query.jobId" :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('more')
  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. // 选择招聘中职位
  58. const handleChangeJob = (e) => {
  59. query.value.pageNo = 1
  60. items.value = []
  61. total.value = 0
  62. if (e) getRecommendList()
  63. }
  64. // 加载更多
  65. const loadingMore = () => {
  66. if (more.value === 'noMore') return
  67. more.value = 'loading'
  68. query.value.pageNo++
  69. getRecommendList()
  70. }
  71. </script>
  72. <style scoped lang="scss">
  73. .noJobId {
  74. display: flex;
  75. flex-direction: column;
  76. margin-top: 26vh;
  77. color: #666;
  78. padding: 0 30rpx;
  79. view {
  80. text-align: center;
  81. margin-top: 4px;
  82. }
  83. }
  84. .box {
  85. height: 100vh;
  86. overflow: hidden;
  87. box-sizing: border-box;
  88. display: flex;
  89. flex-direction: column;
  90. }
  91. .scrollBox{
  92. flex: 1;
  93. padding-bottom: 100px;
  94. box-sizing: border-box;
  95. height: 0 !important;
  96. }
  97. // .stick {
  98. // z-index: 1;
  99. // position: sticky;
  100. // background-color: #fff;
  101. // }
  102. </style>