position.vue 2.9 KB

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