position.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <layout-page>
  3. <view class="box defaultBgc">
  4. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  5. <view>
  6. <view class="white-bgc stick">
  7. <uni-search-bar
  8. v-model="query.content"
  9. radius="8"
  10. placeholder="请输入关键字"
  11. cancelButton="none"
  12. :focus="false"
  13. @confirm="onSearch($event.value)"
  14. @clear="query.content = ''; onSearch()"
  15. />
  16. </view>
  17. <SwiperAd :list="swiperAdList"></SwiperAd>
  18. <view class="white-bgc px-10 mb-10 stickFilter">
  19. <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
  20. </view>
  21. <PositionList :list="positionListData" :noMore="false"></PositionList>
  22. <uni-load-more :status="more" />
  23. </view>
  24. </scroll-view>
  25. <AdvertisePop @login="showAuthModal()"></AdvertisePop>
  26. </view>
  27. </layout-page>
  28. </template>
  29. <script setup>
  30. import SwiperAd from '@/components/SwiperAd'
  31. import FilterList from '@/components/FilterList'
  32. import PositionList from '@/components/PositionList'
  33. import AdvertisePop from '@/components/Advertisement'
  34. import { dealDictObjData } from '@/utils/position'
  35. import { getJobAdvertisedSearch } from '@/api/position'
  36. import { showAuthModal } from '@/hooks/useModal'
  37. import { onShow } from '@dcloudio/uni-app'
  38. import layoutPage from '@/layout'
  39. import { ref, reactive } from 'vue'
  40. // 设置自定义tabbar选中值
  41. onShow(() => {
  42. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  43. const currentTabBar = currentPage?.getTabBar?.();
  44. // 设置当前tab页的下标index
  45. currentTabBar?.setData({ selected: 0 });
  46. })
  47. const more = ref('more')
  48. const swiperAdList = [
  49. 'https://minio.citupro.com/dev/menduner/miniProgram/banner1.gif',
  50. 'https://minio.citupro.com/dev/menduner/miniProgram/banner2.jpg',
  51. 'https://minio.citupro.com/dev/menduner/miniProgram/banner3.jpg',
  52. ]
  53. const filterList = ref([
  54. { label: '城市', dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
  55. { label: '行业', dictType: 'industryTreeData',key: 'industryIds', map: { text: 'nameCn', value: 'id' } },
  56. { label: '求职类型', dictType: 'menduner_job_type', key: 'jobType' },
  57. { label: '薪资待遇', dictType: 'menduner_pay_scope', key: 'payScope' },
  58. { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  59. ])
  60. //
  61. const positionListData = ref([])
  62. const query = reactive({
  63. pageSize: 20,
  64. pageNo: 1,
  65. content: '',
  66. areaIds: [],
  67. industryIds: [],
  68. jobType: [],
  69. payScope: [],
  70. expType: []
  71. })
  72. //
  73. const getData = async () => {
  74. try {
  75. const res = await getJobAdvertisedSearch(query)
  76. const list = res?.data?.list || []
  77. positionListData.value.push(...list.map(e => {
  78. if (!e) {
  79. return e
  80. }
  81. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  82. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  83. return e
  84. }))
  85. if (positionListData.value.length === +res.data.total) {
  86. more.value = 'noMore'
  87. return
  88. }
  89. } catch (error) {
  90. query.pageNo--
  91. more.value = 'more'
  92. }
  93. }
  94. getData()
  95. const handleSearch = (key, value) => {
  96. query[key] = value ? [value] : []
  97. onSearch()
  98. }
  99. const onSearch = () => {
  100. query.pageNo = 1
  101. positionListData.value = []
  102. getData()
  103. }
  104. const loadingMore = () => { // 加载更多
  105. more.value = 'loading'
  106. query.pageNo++
  107. getData()
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .stick {
  112. z-index: 1;
  113. position: sticky;
  114. top: 0;
  115. }
  116. .stickFilter {
  117. z-index: 1;
  118. position: sticky;
  119. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  120. top: 100rpx;
  121. }
  122. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  123. .pb-10 {
  124. padding-bottom: 10px;
  125. }
  126. .pb-20 { padding-bottom: 20px; }
  127. .px-5 { padding-left: 5px; padding-right: 5px; }
  128. .px-10 { padding-left: 10px; padding-right: 10px; }
  129. .mx-10 { margin-left: 10px; margin-right: 10px }
  130. .mx-20 { margin-left: 20px; margin-right: 20px; }
  131. .mb-10 { margin-bottom: 10px; }
  132. .box {
  133. height: 100vh;
  134. overflow: hidden;
  135. padding-bottom: 120rpx;
  136. // box-sizing: border-box;
  137. // padding-bottom: 160rpx;
  138. box-sizing: border-box;
  139. display: flex;
  140. flex-direction: column;
  141. }
  142. .scrollBox{
  143. // height: 100%;
  144. flex: 1;
  145. height: 0 !important;
  146. padding-bottom: 24rpx;
  147. box-sizing: border-box;
  148. // padding-bottom: 160rpx;
  149. }
  150. </style>