position.vue 2.9 KB

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