position.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: 8, 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.active = false
  50. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  51. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  52. })
  53. positionListData.value = positionListData.value.concat(list)
  54. }
  55. if (list?.length < query.pageSize) noMore.value = true
  56. console.log('列表', positionListData.value)
  57. }
  58. getData()
  59. const onSearch = (name) => {
  60. query.pageNo = 1
  61. noMore.value = false
  62. searchContent = name
  63. positionListData.value = []
  64. getData(name)
  65. }
  66. const loadingMore = () => { // 加载更多
  67. query.pageNo++
  68. getData()
  69. }
  70. const refresh = () => { // 下拉刷新
  71. onSearch(searchContent)
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .pb-10 { padding-bottom: 10px; }
  76. .pb-20 { padding-bottom: 20px; }
  77. .box {
  78. height: calc(100vh - 110px);
  79. overflow: hidden;
  80. .block{
  81. margin-bottom: 10px;
  82. padding: 0 10px;
  83. background-color: #fff;
  84. }
  85. }
  86. .scrollBox{
  87. height: 100%;
  88. }
  89. </style>