position.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="box defaultBgc">
  3. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  4. <view class="white-bgc">
  5. <uni-search-bar
  6. v-model="query.content"
  7. radius="8"
  8. placeholder="请输入关键字"
  9. cancelButton="none"
  10. :focus="false"
  11. @confirm="onSearch($event.value)"
  12. @clear="query.content = ''; onSearch()"
  13. />
  14. </view>
  15. <view class="white-bgc px-10 mb-10">
  16. <SwiperAd :list="swiperAdList"></SwiperAd>
  17. <view class="px-5">
  18. <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
  19. </view>
  20. </view>
  21. <PositionList class="pb-10" :list="positionListData" :noMore="noMore"></PositionList>
  22. </scroll-view>
  23. </view>
  24. </template>
  25. <script setup>
  26. import SwiperAd from '@/components/SwiperAd'
  27. import FilterList from '@/components/FilterList'
  28. import PositionList from '@/components/PositionList'
  29. import { swiperAdListTest } from '@/utils/testData'
  30. import { dealDictObjData } from '@/utils/position'
  31. import { getJobAdvertisedSearch } from '@/api/position';
  32. import { onShow } from '@dcloudio/uni-app'
  33. import { ref, reactive } from 'vue'
  34. // 设置自定义tabbar选中值
  35. onShow(() => {
  36. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  37. const currentTabBar = currentPage?.getTabBar?.();
  38. // 设置当前tab页的下标index
  39. currentTabBar?.setData({ selected: 0 });
  40. })
  41. const swiperAdList = ref(swiperAdListTest)
  42. const filterList = ref([
  43. { label: '城市', dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
  44. { label: '行业', dictType: 'industryTreeData',key: 'industryIds', map: { text: 'nameCn', value: 'id' } },
  45. { label: '求职类型', dictType: 'menduner_job_type', key: 'jobType' },
  46. { label: '薪资待遇', dictType: 'menduner_pay_scope', key: 'payType' },
  47. { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  48. ])
  49. //
  50. const positionListData = ref([])
  51. const noMore = ref(false)
  52. const query = reactive({
  53. pageSize: 10,
  54. pageNo: 1,
  55. content: '',
  56. areaIds: [],
  57. industryIds: [],
  58. jobType: [],
  59. payType: [],
  60. expType: []
  61. })
  62. //
  63. const getData = async () => {
  64. // console.log('query', query)
  65. const res = await getJobAdvertisedSearch(query)
  66. const list = res?.data?.list || []
  67. if (list?.length) {
  68. list.forEach(e => {
  69. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  70. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  71. })
  72. positionListData.value = positionListData.value.concat(list)
  73. }
  74. if (list?.length < query.pageSize) noMore.value = true
  75. }
  76. getData()
  77. const handleSearch = (key, value) => {
  78. query[key] = value ? [value] : []
  79. onSearch()
  80. }
  81. const onSearch = () => {
  82. query.pageNo = 1
  83. noMore.value = false
  84. positionListData.value = []
  85. getData()
  86. }
  87. const loadingMore = () => { // 加载更多
  88. query.pageNo++
  89. getData()
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  94. .pb-10 { padding-bottom: 10px; }
  95. .pb-20 { padding-bottom: 20px; }
  96. .px-5 { padding-left: 5px; padding-right: 5px; }
  97. .px-10 { padding-left: 10px; padding-right: 10px; }
  98. .mx-10 { margin-left: 10px; margin-right: 10px }
  99. .mx-20 { margin-left: 20px; margin-right: 20px; }
  100. .mb-10 { margin-bottom: 10px; }
  101. .box {
  102. height: 100vh;
  103. overflow: hidden;
  104. }
  105. .scrollBox{
  106. height: 100%;
  107. }
  108. </style>