position.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. import { onPullDownRefresh } from '@dcloudio/uni-app';
  30. let searchContent = ''
  31. const swiperAdList = ref(swiperAdListTest)
  32. const filterList = ref([
  33. { label: '行业' },
  34. { label: '城市' },
  35. { label: '工作性质' },
  36. { label: '月薪范围' },
  37. { label: '工作经验' },
  38. ])
  39. //
  40. const positionListData = ref([])
  41. const noMore = ref(false)
  42. const query = reactive({ pageSize: 8, pageNo: 1 })
  43. //
  44. const getData = async () => {
  45. query.content = searchContent
  46. const res = await getJobAdvertisedSearch(query)
  47. const list = res?.data?.list || []
  48. if (list?.length) {
  49. list.forEach(e => {
  50. e.active = false
  51. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  52. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  53. })
  54. positionListData.value = positionListData.value.concat(list)
  55. }
  56. if (list?.length < query.pageSize) noMore.value = true
  57. console.log('列表', positionListData.value)
  58. }
  59. getData()
  60. const onSearch = (name) => {
  61. query.pageNo = 1
  62. noMore.value = false
  63. searchContent = name
  64. positionListData.value = []
  65. getData(name)
  66. }
  67. const loadingMore = () => { // 加载更多
  68. query.pageNo++
  69. getData()
  70. }
  71. const refresh = () => { // 下拉刷新
  72. onSearch(searchContent)
  73. }
  74. //下拉刷新
  75. onPullDownRefresh(() => { // 下拉刷新
  76. // debugger
  77. onSearch(searchContent)
  78. })
  79. </script>
  80. <style scoped lang="scss">
  81. .pb-10 { padding-bottom: 10px; }
  82. .pb-20 { padding-bottom: 20px; }
  83. .box {
  84. height: calc(100vh - 110px);
  85. overflow: hidden;
  86. .block{
  87. margin-bottom: 10px;
  88. padding: 0 10px;
  89. background-color: #fff;
  90. }
  91. }
  92. .scrollBox{
  93. height: 100%;
  94. }
  95. </style>