position.vue 3.1 KB

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