position.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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" :list="positionListData" :noMore="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 } from 'vue'
  41. import PositionList from '@/components/PositionList'
  42. import { dealDictArrayData } from '@/utils/position'
  43. import { getJobAdvertisedList } from '@/api/new/position'
  44. import { onShow } from '@dcloudio/uni-app'
  45. const tab = ref(2)
  46. const tabList = [
  47. { label: '待发布', value: 0, status: 99 },
  48. { label: '招聘中', value: 1, status: 0 },
  49. { label: '已关闭', value: 2, status: 1 },
  50. { label: '到期职位', value: 3 }
  51. ]
  52. const controlList = tabList.map(e => e.label)
  53. const tabChange = (e) => {
  54. tab.value = e.currentIndex
  55. query.value.pageNo = 1
  56. getData()
  57. }
  58. const total = ref(0)
  59. const positionListData = ref([])
  60. const query = ref({
  61. pageSize: 5,
  62. pageNo: 1,
  63. name: '',
  64. })
  65. const more = ref('more')
  66. const getData = async () => {
  67. if (query.value.pageNo < 1) return
  68. if (query.value.pageNo === 1) positionListData.value = []
  69. try {
  70. more.value = 'loading'
  71. if (tab.value !== 3) {
  72. query.value.status = tabList[tab.value].status
  73. query.value.hasExpiredData = false
  74. } else {
  75. query.value.hasExpiredData = true
  76. delete query.value.status
  77. }
  78. const res = await getJobAdvertisedList(query.value)
  79. const list = res?.data?.list?.length ? res.data.list : []
  80. total.value = res.data.total-0
  81. if (!list?.length) {
  82. more.value = 'noMore'
  83. return
  84. }
  85. // positionListData.value.concat(dealDictArrayData([], list))
  86. positionListData.value.push(...dealDictArrayData([], list))
  87. console.log('positionListData.value:', 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. more.value = 'loading'
  113. query.value.pageNo++
  114. getData()
  115. }
  116. const handleClick = () => {
  117. let url = ''
  118. if (url) {
  119. uni.navigateTo({ url })
  120. }
  121. }
  122. </script>
  123. <style scoped lang="scss">
  124. .stick {
  125. z-index: 1;
  126. position: sticky;
  127. top: 0;
  128. }
  129. .stickFilter {
  130. z-index: 1;
  131. position: sticky;
  132. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  133. top: 110rpx;
  134. }
  135. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  136. .pb-10 {
  137. padding-bottom: 10px;
  138. }
  139. .pb-20 { padding-bottom: 20px; }
  140. .px-5 { padding-left: 5px; padding-right: 5px; }
  141. .px-10 { padding-left: 10px; padding-right: 10px; }
  142. .mx-10 { margin-left: 10px; margin-right: 10px }
  143. .mx-20 { margin-left: 20px; margin-right: 20px; }
  144. .mb-10 { margin-bottom: 10px; }
  145. .box {
  146. height: 100vh;
  147. overflow: hidden;
  148. padding-bottom: 120rpx;
  149. box-sizing: border-box;
  150. display: flex;
  151. flex-direction: column;
  152. }
  153. .scrollBox{
  154. flex: 1;
  155. height: 0 !important;
  156. padding-bottom: 24rpx;
  157. box-sizing: border-box;
  158. }
  159. .stickBtn{
  160. text-align: center;
  161. width: calc(50% - 2px);
  162. height: 24px;
  163. line-height: 24px;
  164. margin: 8px 0;
  165. color: grey;
  166. font-size: 13px;
  167. }
  168. .newPositionBtn{
  169. color: #00B760;
  170. border-left: 1px solid #c3c3c3;
  171. }
  172. .actColor{
  173. color: #00B760;
  174. }
  175. // :deep(.uni-searchbar) {
  176. // padding: 10px 30rpx;
  177. // }
  178. </style>