position.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="box defaultBgc">
  3. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" @refresherrefresh="refresh" 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"></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 SearchBar from '@/components/SearchBar'
  25. import FilterList from '@/components/FilterList'
  26. import PositionList from '@/components/PositionList'
  27. import { swiperAdListTest, positionList } from '@/utils/testData'
  28. import { dealDictObjData } from '@/utils/position'
  29. import { getJobAdvertisedSearch } from '@/api/position';
  30. import { ref, reactive } from 'vue'
  31. import { onPullDownRefresh } from '@dcloudio/uni-app';
  32. const swiperAdList = ref(swiperAdListTest)
  33. const filterList = ref([
  34. // { label: '城市', dictType: 'areaTreeData', mode: 'multiSelector' },
  35. // { label: '行业', dictType: 'industryTreeData', mode: 'multiSelector' },
  36. { label: '求职类型', dictType: 'menduner_job_type' },
  37. { label: '薪资待遇', dictType: 'menduner_pay_scope' },
  38. { label: '工作经验', dictType: 'menduner_exp_type' },
  39. ])
  40. //
  41. const positionListData = ref([])
  42. const noMore = ref(false)
  43. const query = reactive({ pageSize: 10, pageNo: 1, content: '' })
  44. //
  45. const getData = async () => {
  46. console.log('getData->query', query)
  47. const res = await getJobAdvertisedSearch(query)
  48. const list = res?.data?.list || []
  49. // const list = positionList
  50. if (list?.length) {
  51. list.forEach(e => {
  52. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  53. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  54. })
  55. positionListData.value = positionListData.value.concat(list)
  56. }
  57. if (list?.length < query.pageSize) noMore.value = true
  58. // console.log('列表', positionListData.value)
  59. }
  60. getData()
  61. const onSearch = () => {
  62. query.pageNo = 1
  63. noMore.value = false
  64. positionListData.value = []
  65. getData()
  66. }
  67. const loadingMore = () => { // 加载更多
  68. query.pageNo++
  69. getData()
  70. }
  71. const refresh = () => { // 下拉刷新
  72. onSearch(searchContent.value)
  73. }
  74. //下拉刷新
  75. onPullDownRefresh(() => { // 下拉刷新
  76. // debugger
  77. onSearch(searchContent.value)
  78. })
  79. </script>
  80. <style scoped lang="scss">
  81. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  82. .pb-10 { padding-bottom: 10px; }
  83. .pb-20 { padding-bottom: 20px; }
  84. .px-10 { padding-left: 10px; padding-right: 10px; }
  85. .mb-10 { margin-bottom: 10px; }
  86. .box {
  87. height: 100vh;
  88. overflow: hidden;
  89. }
  90. .scrollBox{
  91. height: 100%;
  92. }
  93. </style>