position.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="box defaultBgc">
  3. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  4. <view class="white-bgc">
  5. <uni-search-bar
  6. v-model="query.content"
  7. radius="8"
  8. placeholder="请输入关键字"
  9. cancelButton="none"
  10. :focus="false"
  11. @confirm="onSearch($event.value)"
  12. @clear="query.content = ''; onSearch()"
  13. />
  14. </view>
  15. <view class="white-bgc px-10 mb-10">
  16. <SwiperAd :list="swiperAdList"></SwiperAd>
  17. <view class="px-5">
  18. <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
  19. </view>
  20. </view>
  21. <PositionList class="pb-10" :list="positionListData" :noMore="noMore"></PositionList>
  22. </scroll-view>
  23. </view>
  24. </template>
  25. <script setup>
  26. import SwiperAd from '@/components/SwiperAd'
  27. import FilterList from '@/components/FilterList'
  28. import PositionList from '@/components/PositionList'
  29. import { swiperAdListTest } from '@/utils/testData'
  30. import { dealDictObjData } from '@/utils/position'
  31. import { getJobAdvertisedSearch } from '@/api/position';
  32. import { ref, reactive } from 'vue'
  33. const swiperAdList = ref(swiperAdListTest)
  34. const filterList = ref([
  35. { label: '城市', dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
  36. { label: '行业', dictType: 'industryTreeData',key: 'industryIds', map: { text: 'nameCn', value: 'id' } },
  37. { label: '求职类型', dictType: 'menduner_job_type', key: 'jobType' },
  38. { label: '薪资待遇', dictType: 'menduner_pay_scope', key: 'payType' },
  39. { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  40. ])
  41. //
  42. const positionListData = ref([])
  43. const noMore = ref(false)
  44. const query = reactive({
  45. pageSize: 10,
  46. pageNo: 1,
  47. content: '',
  48. areaIds: [],
  49. industryIds: [],
  50. jobType: [],
  51. payType: [],
  52. expType: []
  53. })
  54. //
  55. const getData = async () => {
  56. // console.log('query', query)
  57. const res = await getJobAdvertisedSearch(query)
  58. const list = res?.data?.list || []
  59. if (list?.length) {
  60. list.forEach(e => {
  61. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  62. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  63. })
  64. positionListData.value = positionListData.value.concat(list)
  65. }
  66. if (list?.length < query.pageSize) noMore.value = true
  67. }
  68. getData()
  69. const handleSearch = (key, value) => {
  70. query[key] = value ? [value] : []
  71. onSearch()
  72. }
  73. const onSearch = () => {
  74. query.pageNo = 1
  75. noMore.value = false
  76. positionListData.value = []
  77. getData()
  78. }
  79. const loadingMore = () => { // 加载更多
  80. query.pageNo++
  81. getData()
  82. }
  83. </script>
  84. <style scoped lang="scss">
  85. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  86. .pb-10 { padding-bottom: 10px; }
  87. .pb-20 { padding-bottom: 20px; }
  88. .px-5 { padding-left: 5px; padding-right: 5px; }
  89. .px-10 { padding-left: 10px; padding-right: 10px; }
  90. .mx-10 { margin-left: 10px; margin-right: 10px }
  91. .mx-20 { margin-left: 20px; margin-right: 20px; }
  92. .mb-10 { margin-bottom: 10px; }
  93. .box {
  94. height: 100vh;
  95. overflow: hidden;
  96. }
  97. .scrollBox{
  98. height: 100%;
  99. }
  100. </style>