position.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="box defaultBgc">
  3. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" @refresherrefresh="refresh" style="position:relative;">
  4. <uni-search-bar
  5. class="ss-flex-1 white-bgc"
  6. radius="8"
  7. placeholder="请输入关键字"
  8. cancelButton="none"
  9. :focus="false"
  10. @confirm="onSearch($event.value)"
  11. />
  12. <view class="block">
  13. <SwiperAd class="pb-20" :list="swiperAdList"></SwiperAd>
  14. <FilterList class="pb-10" :list="filterList" idValue="label"></FilterList>
  15. </view>
  16. <PositionList class="pb-10" :list="positionListData" :noMore="noMore"></PositionList>
  17. </scroll-view>
  18. </view>
  19. </template>
  20. <script setup>
  21. import SwiperAd from '@/components/SwiperAd'
  22. // import SearchBar from '@/components/SearchBar'
  23. import FilterList from '@/components/FilterList'
  24. import PositionList from '@/components/PositionList'
  25. import { positionList, swiperAdListTest } from '@/utils/testData'
  26. import { dealDictObjData } from '@/utils/position'
  27. import { getJobAdvertisedSearch } from '@/api/position';
  28. import { ref, reactive } from 'vue'
  29. let searchContent = ''
  30. const swiperAdList = ref(swiperAdListTest)
  31. const filterList = ref([
  32. { label: '行业' },
  33. { label: '城市' },
  34. { label: '工作性质' },
  35. { label: '月薪范围' },
  36. { label: '工作经验' },
  37. ])
  38. //
  39. const positionListData = ref([])
  40. const noMore = ref(false)
  41. const query = reactive({ pageSize: 10, pageNo: 1 })
  42. //
  43. const getData = async () => {
  44. query.content = searchContent
  45. const res = await getJobAdvertisedSearch(query)
  46. const list = res?.data?.list || []
  47. if (list?.length) {
  48. list.forEach(e => {
  49. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  50. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  51. })
  52. positionListData.value = positionListData.value.concat(list)
  53. }
  54. if (list?.length < query.pageSize) noMore.value = true
  55. console.log('列表', positionListData.value)
  56. }
  57. getData()
  58. const onSearch = (name) => {
  59. query.pageNo = 1
  60. noMore.value = false
  61. searchContent = name
  62. positionListData.value = []
  63. getData(name)
  64. }
  65. const loadingMore = () => { // 加载更多
  66. query.pageNo++
  67. getData()
  68. }
  69. const refresh = () => { // 下拉刷新
  70. onSearch(searchContent)
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. .pb-10 { padding-bottom: 10px; }
  75. .pb-20 { padding-bottom: 20px; }
  76. .box {
  77. height: calc(100vh - 110px);
  78. overflow: hidden;
  79. .block{
  80. margin-bottom: 10px;
  81. padding: 0 10px;
  82. background-color: #fff;
  83. }
  84. }
  85. .scrollBox{
  86. height: 100%;
  87. }
  88. </style>