position.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. radius="8"
  7. placeholder="请输入关键字"
  8. cancelButton="none"
  9. :focus="false"
  10. @confirm="onSearch($event.value)"
  11. />
  12. </view>
  13. <view class="white-bgc px-10 pb-10 mb-10">
  14. <SwiperAd :list="swiperAdList"></SwiperAd>
  15. <!-- <FilterList :list="filterList" idValue="label"></FilterList> -->
  16. </view>
  17. <PositionList class="pb-10" :list="positionListData" :noMore="noMore"></PositionList>
  18. </scroll-view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import SwiperAd from '@/components/SwiperAd'
  23. // import SearchBar from '@/components/SearchBar'
  24. // import FilterList from '@/components/FilterList'
  25. import PositionList from '@/components/PositionList'
  26. import { swiperAdListTest, positionList } from '@/utils/testData'
  27. import { dealDictObjData } from '@/utils/position'
  28. import { getJobAdvertisedSearch } from '@/api/position';
  29. import { ref, reactive } from 'vue'
  30. import { onPullDownRefresh } from '@dcloudio/uni-app';
  31. let searchContent = ''
  32. const swiperAdList = ref(swiperAdListTest)
  33. const filterList = ref([
  34. { label: '行业' },
  35. { label: '城市' },
  36. { label: '工作性质' },
  37. { label: '月薪范围' },
  38. { label: '工作经验' },
  39. ])
  40. //
  41. const positionListData = ref([])
  42. const noMore = ref(false)
  43. const query = reactive({ pageSize: 10, pageNo: 1 })
  44. //
  45. const getData = async () => {
  46. query.content = searchContent
  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 = (name) => {
  62. query.pageNo = 1
  63. noMore.value = false
  64. searchContent = name
  65. positionListData.value = []
  66. getData(name)
  67. }
  68. const loadingMore = () => { // 加载更多
  69. query.pageNo++
  70. getData()
  71. }
  72. const refresh = () => { // 下拉刷新
  73. onSearch(searchContent)
  74. }
  75. //下拉刷新
  76. onPullDownRefresh(() => { // 下拉刷新
  77. // debugger
  78. onSearch(searchContent)
  79. })
  80. </script>
  81. <style scoped lang="scss">
  82. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  83. .pb-10 { padding-bottom: 10px; }
  84. .pb-20 { padding-bottom: 20px; }
  85. .px-10 { padding-left: 10px; padding-right: 10px; }
  86. .mb-10 { margin-bottom: 10px; }
  87. .box {
  88. height: calc(100vh - 110px);
  89. overflow: hidden;
  90. }
  91. .scrollBox{
  92. height: 100%;
  93. }
  94. </style>