position.vue 2.8 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. <view class="block pb-10">
  5. <uni-search-bar
  6. class="px-0"
  7. radius="8"
  8. placeholder="请输入关键字"
  9. cancelButton="none"
  10. :focus="false"
  11. @confirm="onSearch($event.value)"
  12. />
  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 { 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: 10, 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.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. //下拉刷新
  74. onPullDownRefresh(() => { // 下拉刷新
  75. // debugger
  76. onSearch(searchContent)
  77. })
  78. </script>
  79. <style scoped lang="scss">
  80. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  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 30rpx;
  89. background-color: #fff;
  90. }
  91. }
  92. .scrollBox{
  93. height: 100%;
  94. }
  95. </style>