position.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view>
  3. <Navbar></Navbar>
  4. <layout-page>
  5. <view class="box defaultBgc">
  6. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  7. <view>
  8. <SwiperAd :list="swiperAdList"></SwiperAd>
  9. <!-- 五宫格菜单 -->
  10. <view class="white-bgc ss-p-t-10">
  11. <uni-grid :column="5" @change="handleGrid" :showBorder="false">
  12. <uni-grid-item v-for="(val, index) in gridList" :index="index" :key="index">
  13. <view class="d-flex align-center flex-column justify-center" style="width: 100%; height: 100%; border: none;">
  14. <image :src="val.icon" style="width: 40px; height: 40px;"></image>
  15. <text class="text color-666 font-size-14 ss-m-t-10">{{ val.label }}</text>
  16. </view>
  17. </uni-grid-item>
  18. </uni-grid>
  19. </view>
  20. <!-- 搜索条 -->
  21. <view class="white-bgc stick ss-p-t-10">
  22. <view style="position: relative;">
  23. <uni-search-bar
  24. v-model="query.content"
  25. placeholder="请输入职位/公司关键字"
  26. cancelButton="none"
  27. :focus="false"
  28. bgColor="#fff"
  29. @confirm="onSearch($event.value)"
  30. @clear="query.content = ''; onSearch()"
  31. >
  32. </uni-search-bar>
  33. <button class="search-btn" @tap.stop="onSearch">搜索</button>
  34. </view>
  35. </view>
  36. <view class="white-bgc px-10 stickFilter">
  37. <FilterList :list="filterList" idValue="label" @change="handleSearch"></FilterList>
  38. </view>
  39. <PositionList :list="positionListData" :noMore="false"></PositionList>
  40. <uni-load-more :status="more" />
  41. </view>
  42. </scroll-view>
  43. <AdvertisePop @login="showAuthModal()"></AdvertisePop>
  44. </view>
  45. </layout-page>
  46. </view>
  47. </template>
  48. <script setup>
  49. import { ref, reactive } from 'vue'
  50. import SwiperAd from '@/components/SwiperAd'
  51. import FilterList from '@/components/FilterList'
  52. import PositionList from '@/components/PositionList'
  53. import AdvertisePop from '@/components/Advertisement'
  54. import { dealDictObjData } from '@/utils/position'
  55. import { getJobAdvertisedSearch } from '@/api/position'
  56. import { showAuthModal } from '@/hooks/useModal'
  57. import { onShow } from '@dcloudio/uni-app'
  58. import layoutPage from '@/layout'
  59. import Navbar from '@/components/Navbar'
  60. // 设置自定义tabbar选中值
  61. onShow(() => {
  62. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  63. const currentTabBar = currentPage?.getTabBar?.();
  64. // 设置当前tab页的下标index
  65. currentTabBar?.setData({ selected: 0 });
  66. })
  67. const more = ref('more')
  68. const swiperAdList = [
  69. 'https://minio.citupro.com/dev/menduner/miniProgram/banner1.gif',
  70. 'https://minio.citupro.com/dev/menduner/miniProgram/banner2.jpg',
  71. 'https://minio.citupro.com/dev/menduner/miniProgram/banner3.jpg',
  72. 'https://minio.citupro.com/dev/menduner/miniProgram/banner4.jpg'
  73. ]
  74. const filterList = ref([
  75. { label: '城市', dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
  76. { label: '行业', dictType: 'industryTreeData',key: 'industryIds', map: { text: 'nameCn', value: 'id' } },
  77. { label: '求职类型', dictType: 'menduner_job_type', key: 'jobType' },
  78. { label: '薪资待遇', dictType: 'menduner_pay_scope', key: 'payScope' },
  79. // { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  80. ])
  81. const gridList = [
  82. { label: '优选集团', icon: '/static/svg/jituan.svg', path: '' },
  83. { label: '精选企业', icon: '/static/svg/qiye.svg', path: '' },
  84. { label: '门墩儿猎头', icon: '/static/svg/lietou.svg', path: '' },
  85. { label: '早报资讯', icon: '/static/svg/zixun.svg', specifications: 50, path: '' },
  86. { label: '联系我们', icon: '/static/svg/kefu.svg', path: '' }
  87. ]
  88. const handleGrid = (e) => {
  89. uni.showToast({
  90. icon: 'none',
  91. title: '建设中...,敬请期待'
  92. })
  93. }
  94. //
  95. const positionListData = ref([])
  96. const query = reactive({
  97. pageSize: 20,
  98. pageNo: 1,
  99. content: '',
  100. areaIds: [],
  101. industryIds: [],
  102. jobType: [],
  103. payScope: [],
  104. expType: []
  105. })
  106. //
  107. const getData = async () => {
  108. try {
  109. const res = await getJobAdvertisedSearch(query)
  110. const list = res?.data?.list || []
  111. positionListData.value.push(...list.map(e => {
  112. if (!e) {
  113. return e
  114. }
  115. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  116. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  117. return e
  118. }))
  119. if (positionListData.value.length === +res.data.total) {
  120. more.value = 'noMore'
  121. return
  122. }
  123. } catch (error) {
  124. query.pageNo--
  125. more.value = 'more'
  126. }
  127. }
  128. getData()
  129. const handleSearch = (key, value) => {
  130. query[key] = value ? [value] : []
  131. onSearch()
  132. }
  133. const onSearch = () => {
  134. query.pageNo = 1
  135. positionListData.value = []
  136. getData()
  137. }
  138. const loadingMore = () => { // 加载更多
  139. more.value = 'loading'
  140. query.pageNo++
  141. getData()
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .stick {
  146. z-index: 1;
  147. position: sticky;
  148. top: 0;
  149. }
  150. .stickFilter {
  151. z-index: 1;
  152. position: sticky;
  153. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  154. top: 100rpx;
  155. }
  156. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  157. .pb-10 {
  158. padding-bottom: 10px;
  159. }
  160. .pb-20 { padding-bottom: 20px; }
  161. .px-5 { padding-left: 5px; padding-right: 5px; }
  162. .px-10 { padding-left: 10px; padding-right: 10px; }
  163. .mx-10 { margin-left: 10px; margin-right: 10px }
  164. .mx-20 { margin-left: 20px; margin-right: 20px; }
  165. .mb-10 { margin-bottom: 10px; }
  166. .box {
  167. height: 100vh;
  168. overflow: hidden;
  169. padding-bottom: 120rpx;
  170. box-sizing: border-box;
  171. display: flex;
  172. flex-direction: column;
  173. }
  174. .scrollBox{
  175. flex: 1;
  176. height: 0 !important;
  177. padding-bottom: 24rpx;
  178. box-sizing: border-box;
  179. }
  180. :deep(.uni-searchbar__box) {
  181. width: calc(100% - 105px);
  182. height: 40px !important;
  183. border: 1px solid #00897B;
  184. padding-right: 20px;
  185. flex: none;
  186. }
  187. .search-btn {
  188. position: absolute;
  189. right: 11px;
  190. top: 10px;
  191. width: 110px;
  192. height: 40px;
  193. font-size: 16px;
  194. background-color: #00897B;
  195. color: #fff;
  196. border-radius: 0 5px 5px 0;
  197. z-index: 9;
  198. }
  199. </style>