position.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="box defaultBgc">
  3. <uni-segmented-control :current="current" :values="controlList" @clickItem="handleChange" styleType="text" activeColor="#00B760" style="background-color: #fff"></uni-segmented-control>
  4. <scroll-view class="scrollBox" :scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  5. <view>
  6. <!-- -->
  7. <view class="white-bgc stick ss-p-t-20" style="border-radius: 5px;">
  8. <view class="defaultBgc d-flex ss-m-x-20">
  9. <view class="stickBtn" @click="handleClick(0)">待发布(<text class="ss-m-x-2">{{ unpublished }}</text>)</view>
  10. <view class="stickBtn newPositionBtn" @click="handleClick(1)">发布新职位</view>
  11. </view>
  12. <!-- 搜索条 -->
  13. <uni-search-bar
  14. v-model="query.content"
  15. radius="5"
  16. placeholder="输入关键字"
  17. cancelButton="none"
  18. :focus="false"
  19. @confirm="onSearch"
  20. ></uni-search-bar>
  21. </view>
  22. <view v-if="noData" class="d-flex flex-column align-center justify-center" style="height: 80vh;">
  23. <view class="nodata-img-parent">
  24. <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
  25. </view>
  26. <view class="color-999">暂无职位</view>
  27. <view class="f-horizon-center">
  28. <button type="primary" size="default" class="ss-m-t-50" style="width: 60vw;" @click="fabClick">发布新职位</button>
  29. </view>
  30. </view>
  31. <view v-else>
  32. <PositionList v-if="positionListData?.length || more !== 'loading'" :list="positionListData" :noMore="false" :showJobFairEntrance="false"></PositionList>
  33. <uni-load-more :status="more" />
  34. </view>
  35. </view>
  36. </scroll-view>
  37. </view>
  38. </template>
  39. <script setup>
  40. import { ref, reactive } from 'vue'
  41. import PositionList from '@/components/PositionList'
  42. import { dealDictObjData } from '@/utils/position'
  43. import { getJobAdvertisedSearch } from '@/api/position'
  44. import { onShow } from '@dcloudio/uni-app'
  45. const more = ref('more')
  46. const noData = ref(false)
  47. const unpublished = ref(0)
  48. const positionListData = ref([])
  49. const query = reactive({
  50. pageSize: 20,
  51. pageNo: 1,
  52. })
  53. const getData = async () => {
  54. if (query.pageNo === 1) positionListData.value = []
  55. if (query.pageNo <= 0) return
  56. try {
  57. more.value = 'loading'
  58. const res = await getJobAdvertisedSearch(query)
  59. const list = res?.data?.list || []
  60. if (!list?.length) {
  61. more.value = 'noMore'
  62. return
  63. }
  64. positionListData.value.push(...list.map(e => {
  65. if (!e) {
  66. return e
  67. }
  68. e.job = { ...e.job, ...dealDictObjData({}, e.job) }
  69. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  70. return e
  71. }))
  72. if (positionListData.value.length === +res.data.total) {
  73. more.value = 'noMore'
  74. return
  75. }
  76. } catch (error) {
  77. query.pageNo--
  78. more.value = 'more'
  79. } finally {
  80. if (!positionListData.value?.length) {
  81. noData.value = true
  82. }
  83. }
  84. }
  85. const current = ref(0)
  86. const controlList = ['招聘中', '已关闭']
  87. const handleChange = (e) => {
  88. current.value = e.currentIndex
  89. }
  90. // 设置自定义tabbar选中值
  91. onShow(() => {
  92. const currentPage = getCurrentPages()[0] // 获取当前页面实例
  93. const currentTabBar = currentPage?.getTabBar?.()
  94. // 设置当前tab页的下标index
  95. currentTabBar?.setData({ selected: 1 })
  96. getData()
  97. })
  98. const onSearch = () => {
  99. query.pageNo = 1
  100. positionListData.value = []
  101. getData()
  102. }
  103. // 加载更多
  104. const loadingMore = () => {
  105. more.value = 'loading'
  106. query.pageNo++
  107. getData()
  108. }
  109. const handleClick = (type) => {
  110. let url = type ? '' : ''
  111. if (!type && !unpublished.value) return
  112. //
  113. if (url) {
  114. uni.navigateTo({ url })
  115. }
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .stick {
  120. z-index: 1;
  121. position: sticky;
  122. top: 0;
  123. }
  124. .stickFilter {
  125. z-index: 1;
  126. position: sticky;
  127. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  128. top: 110rpx;
  129. }
  130. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  131. .pb-10 {
  132. padding-bottom: 10px;
  133. }
  134. .pb-20 { padding-bottom: 20px; }
  135. .px-5 { padding-left: 5px; padding-right: 5px; }
  136. .px-10 { padding-left: 10px; padding-right: 10px; }
  137. .mx-10 { margin-left: 10px; margin-right: 10px }
  138. .mx-20 { margin-left: 20px; margin-right: 20px; }
  139. .mb-10 { margin-bottom: 10px; }
  140. .box {
  141. height: 100vh;
  142. overflow: hidden;
  143. padding-bottom: 120rpx;
  144. box-sizing: border-box;
  145. display: flex;
  146. flex-direction: column;
  147. }
  148. .scrollBox{
  149. flex: 1;
  150. height: 0 !important;
  151. padding-bottom: 24rpx;
  152. box-sizing: border-box;
  153. }
  154. .stickBtn{
  155. text-align: center;
  156. width: calc(50% - 2px);
  157. height: 24px;
  158. line-height: 24px;
  159. margin: 8px 0;
  160. color: grey;
  161. font-size: 13px;
  162. }
  163. .newPositionBtn{
  164. color: #00B760;
  165. border-left: 1px solid #c3c3c3;
  166. }
  167. // :deep(.uni-searchbar) {
  168. // padding: 10px 30rpx;
  169. // }
  170. </style>