position.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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, onLoad } from '@dcloudio/uni-app'
  58. import layoutPage from '@/layout'
  59. import Navbar from '@/components/Navbar'
  60. import { getRewardEventList } from '@/utils/eventList'
  61. // 设置自定义tabbar选中值
  62. onShow(() => {
  63. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  64. const currentTabBar = currentPage?.getTabBar?.();
  65. // 设置当前tab页的下标index
  66. currentTabBar?.setData({ selected: 0 });
  67. })
  68. onLoad(() => {
  69. if (!uni.getStorageSync('token')) getRewardEventList()
  70. })
  71. const more = ref('more')
  72. const swiperAdList = [
  73. 'https://minio.citupro.com/dev/menduner/miniProgram/banner1.gif',
  74. 'https://minio.citupro.com/dev/menduner/miniProgram/banner2.jpg',
  75. 'https://minio.citupro.com/dev/menduner/miniProgram/banner3.jpg',
  76. 'https://minio.citupro.com/dev/menduner/miniProgram/banner4.jpg'
  77. ]
  78. const filterList = ref([
  79. { label: '城市', dictType: 'areaTreeData', key: 'areaIds', map: { text: 'name', value: 'id' } },
  80. { label: '行业', dictType: 'industryTreeData',key: 'industryIds', map: { text: 'nameCn', value: 'id' } },
  81. { label: '求职类型', dictType: 'menduner_job_type', key: 'jobType' },
  82. { label: '薪资待遇', dictType: 'menduner_pay_scope', key: 'payScope' },
  83. // { label: '工作经验', dictType: 'menduner_exp_type', key: 'expType' },
  84. ])
  85. const gridList = [
  86. { label: '优选集团', icon: '/static/svg/jituan.svg', path: '' },
  87. { label: '精选企业', icon: '/static/svg/qiye.svg', path: '' },
  88. { label: '门墩儿猎头', icon: '/static/svg/lietou.svg', path: '' },
  89. { label: '早报资讯', icon: '/static/svg/zixun.svg', specifications: 50, path: '' },
  90. { label: '联系我们', icon: '/static/svg/kefu.svg', path: '' }
  91. ]
  92. const handleGrid = (e) => {
  93. uni.showToast({
  94. icon: 'none',
  95. title: '请前往网页版门墩儿查看'
  96. })
  97. }
  98. //
  99. const positionListData = ref([])
  100. const query = reactive({
  101. pageSize: 20,
  102. pageNo: 1,
  103. content: '',
  104. areaIds: [],
  105. industryIds: [],
  106. jobType: [],
  107. payScope: [],
  108. expType: []
  109. })
  110. //
  111. const getData = async () => {
  112. try {
  113. const res = await getJobAdvertisedSearch(query)
  114. const list = res?.data?.list || []
  115. positionListData.value.push(...list.map(e => {
  116. if (!e) {
  117. return e
  118. }
  119. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  120. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  121. return e
  122. }))
  123. if (positionListData.value.length === +res.data.total) {
  124. more.value = 'noMore'
  125. return
  126. }
  127. } catch (error) {
  128. query.pageNo--
  129. more.value = 'more'
  130. }
  131. }
  132. getData()
  133. const handleSearch = (key, value) => {
  134. query[key] = value ? [value] : []
  135. onSearch()
  136. }
  137. const onSearch = () => {
  138. query.pageNo = 1
  139. positionListData.value = []
  140. getData()
  141. }
  142. const loadingMore = () => { // 加载更多
  143. more.value = 'loading'
  144. query.pageNo++
  145. getData()
  146. }
  147. </script>
  148. <style scoped lang="scss">
  149. .stick {
  150. z-index: 1;
  151. position: sticky;
  152. top: 0;
  153. }
  154. .stickFilter {
  155. z-index: 1;
  156. position: sticky;
  157. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  158. top: 100rpx;
  159. }
  160. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  161. .pb-10 {
  162. padding-bottom: 10px;
  163. }
  164. .pb-20 { padding-bottom: 20px; }
  165. .px-5 { padding-left: 5px; padding-right: 5px; }
  166. .px-10 { padding-left: 10px; padding-right: 10px; }
  167. .mx-10 { margin-left: 10px; margin-right: 10px }
  168. .mx-20 { margin-left: 20px; margin-right: 20px; }
  169. .mb-10 { margin-bottom: 10px; }
  170. .box {
  171. height: 100vh;
  172. overflow: hidden;
  173. padding-bottom: 120rpx;
  174. box-sizing: border-box;
  175. display: flex;
  176. flex-direction: column;
  177. }
  178. .scrollBox{
  179. flex: 1;
  180. height: 0 !important;
  181. padding-bottom: 24rpx;
  182. box-sizing: border-box;
  183. }
  184. :deep(.uni-searchbar__box) {
  185. width: calc(100% - 105px);
  186. height: 40px !important;
  187. border: 1px solid #00897B;
  188. padding-right: 20px;
  189. flex: none;
  190. }
  191. .search-btn {
  192. position: absolute;
  193. right: 11px;
  194. top: 10px;
  195. width: 110px;
  196. height: 40px;
  197. font-size: 16px;
  198. background-color: #00897B;
  199. color: #fff;
  200. border-radius: 0 5px 5px 0;
  201. z-index: 9;
  202. }
  203. </style>