position.vue 5.5 KB

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