position.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. name: '',
  65. })
  66. const more = ref('more')
  67. const getData = async () => {
  68. if (query.value.pageNo < 1) return
  69. if (query.value.pageNo === 1) positionListData.value = []
  70. try {
  71. more.value = 'loading'
  72. if (tab.value !== 3) {
  73. query.value.status = tabList[tab.value].status
  74. query.value.hasExpiredData = false
  75. } else {
  76. query.value.hasExpiredData = true
  77. delete query.value.status
  78. }
  79. const res = await getJobAdvertisedList(query.value)
  80. const list = res?.data?.list?.length ? res.data.list : []
  81. total.value = res.data.total-0
  82. if (!list?.length) {
  83. more.value = 'noMore'
  84. return
  85. }
  86. positionListData.value.push(...dealDictArrayData([], list))
  87. // console.log('positionListData:', positionListData.value)
  88. more.value = 'more'
  89. if (positionListData.value.length === total.value) {
  90. more.value = 'noMore'
  91. return
  92. }
  93. } catch (error) {
  94. query.value.pageNo--
  95. more.value = 'more'
  96. }
  97. }
  98. getData()
  99. // 设置自定义tabbar选中值
  100. onShow(() => {
  101. const currentPage = getCurrentPages()[0] // 获取当前页面实例
  102. const currentTabBar = currentPage?.getTabBar?.()
  103. // 设置当前tab页的下标index
  104. currentTabBar?.setData({ selected: 1 })
  105. })
  106. const onSearch = () => {
  107. query.value.pageNo = 1
  108. getData()
  109. }
  110. // 加载更多
  111. const loadingMore = () => {
  112. if (more.value === 'noMore') return
  113. more.value = 'loading'
  114. query.value.pageNo++
  115. getData()
  116. }
  117. const refresh = (reset = false) => {
  118. if (reset) query.value.pageNo = 1
  119. getData()
  120. }
  121. const handleClick = () => {
  122. let url = ''
  123. if (url) {
  124. uni.navigateTo({ url })
  125. }
  126. }
  127. </script>
  128. <style scoped lang="scss">
  129. .stick {
  130. z-index: 1;
  131. position: sticky;
  132. top: 0;
  133. }
  134. .stickFilter {
  135. z-index: 1;
  136. position: sticky;
  137. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  138. top: 110rpx;
  139. }
  140. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  141. .pb-10 {
  142. padding-bottom: 10px;
  143. }
  144. .pb-20 { padding-bottom: 20px; }
  145. .px-5 { padding-left: 5px; padding-right: 5px; }
  146. .px-10 { padding-left: 10px; padding-right: 10px; }
  147. .mx-10 { margin-left: 10px; margin-right: 10px }
  148. .mx-20 { margin-left: 20px; margin-right: 20px; }
  149. .mb-10 { margin-bottom: 10px; }
  150. .box {
  151. height: 100vh;
  152. overflow: hidden;
  153. box-sizing: border-box;
  154. display: flex;
  155. flex-direction: column;
  156. }
  157. .scrollBox{
  158. flex: 1;
  159. height: 0 !important;
  160. padding-bottom: 24rpx;
  161. box-sizing: border-box;
  162. }
  163. .stickBtn{
  164. text-align: center;
  165. width: calc(50% - 2px);
  166. height: 24px;
  167. line-height: 24px;
  168. margin: 8px 0;
  169. color: grey;
  170. font-size: 13px;
  171. }
  172. .newPositionBtn{
  173. color: #00B760;
  174. border-left: 1px solid #c3c3c3;
  175. }
  176. .actColor{
  177. color: #00B760;
  178. }
  179. // :deep(.uni-searchbar) {
  180. // padding: 10px 30rpx;
  181. // }
  182. </style>