position.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <layout-page @loginSucceeded="init">
  3. <view class="box defaultBgc">
  4. <uni-segmented-control :current="tab" :values="controlList" @clickItem="tabChange" styleType="text" activeColor="#00B760" style="background-color: #fff"></uni-segmented-control>
  5. <scroll-view class="scrollBox" :scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  6. <view>
  7. <!-- -->
  8. <view class="white-bgc stick ss-p-t-20" style="border-radius: 5px;">
  9. <!-- <view class="defaultBgc d-flex ss-m-x-20">
  10. <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>
  11. <view class="stickBtn newPositionBtn" @tap="">发布新职位</view>
  12. </view> -->
  13. <!-- 搜索条 -->
  14. <uni-search-bar
  15. v-model="query.name"
  16. radius="5"
  17. placeholder="输入关键字"
  18. cancelButton="none"
  19. :focus="false"
  20. @confirm="onSearch"
  21. ></uni-search-bar>
  22. </view>
  23. <view v-if="!positionListData?.length && more !== 'loading'" class="d-flex flex-column align-center justify-center ss-m-t-30">
  24. <view class="nodata-img-parent">
  25. <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
  26. </view>
  27. <view class="color-999">暂无职位</view>
  28. <view class="f-horizon-center">
  29. <button type="primary" size="default" class="ss-m-t-50" style="width: 60vw;" @click="handleClickAdd">发布新职位</button>
  30. </view>
  31. </view>
  32. <view v-else>
  33. <PositionList v-if="positionListData?.length" :tab="tab" :payable="true" :list="positionListData" :noMore="false" @refresh="refresh"></PositionList>
  34. <uni-load-more :status="more" />
  35. <view style="padding-bottom: 20vh;"></view>
  36. <view class="addBtn" @tap="handleClickAdd">
  37. <view class="addBox">
  38. <view class="icon">+</view>
  39. <view class="text">发布新职位</view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </layout-page>
  47. </template>
  48. <script setup>
  49. import { ref } from 'vue'
  50. import layoutPage from '@/layout'
  51. import PositionList from '@/components/PositionList'
  52. import { dealDictArrayData } from '@/utils/position'
  53. import { getJobAdvertisedList } from '@/api/new/position'
  54. import { onShow } from '@dcloudio/uni-app'
  55. import { getAccessToken } from '@/utils/request'
  56. import { showAuthModal } from '@/hooks/useModal'
  57. const tab = ref(2)
  58. const tabList = [
  59. { label: '待发布', value: 0, status: 99 },
  60. { label: '招聘中', value: 1, status: 0 },
  61. { label: '已关闭', value: 2, status: 1 },
  62. { label: '到期职位', value: 3 }
  63. ]
  64. const controlList = tabList.map(e => e.label)
  65. const tabChange = (e) => {
  66. tab.value = e.currentIndex
  67. query.value.pageNo = 1
  68. getData()
  69. }
  70. const total = ref(0)
  71. const positionListData = ref([])
  72. const query = ref({
  73. pageSize: 5,
  74. pageNo: 1,
  75. hire: false,
  76. name: '',
  77. })
  78. const more = ref('more')
  79. const getData = async () => {
  80. if (query.value.pageNo < 1) return
  81. if (query.value.pageNo === 1) positionListData.value = []
  82. try {
  83. more.value = 'loading'
  84. if (tab.value !== 3) {
  85. query.value.status = tabList[tab.value].status
  86. query.value.hasExpiredData = false
  87. } else {
  88. query.value.hasExpiredData = true
  89. delete query.value.status
  90. }
  91. const res = await getJobAdvertisedList(query.value)
  92. const list = res?.data?.list?.length ? res.data.list : []
  93. total.value = res.data.total-0
  94. if (!list?.length) {
  95. more.value = 'noMore'
  96. return
  97. }
  98. positionListData.value.push(...dealDictArrayData([], list))
  99. // console.log('positionListData:', positionListData.value)
  100. more.value = 'more'
  101. if (positionListData.value.length === total.value) {
  102. more.value = 'noMore'
  103. return
  104. }
  105. } catch (error) {
  106. query.value.pageNo--
  107. more.value = 'more'
  108. }
  109. }
  110. // 设置自定义tabbar选中值
  111. onShow(() => {
  112. console.log('onShow:', 789)
  113. const currentPage = getCurrentPages()[0] // 获取当前页面实例
  114. const currentTabBar = currentPage?.getTabBar?.()
  115. // 设置当前tab页的下标index
  116. currentTabBar?.setData({ selected: 1 })
  117. init()
  118. })
  119. const init = () => {
  120. console.log('123456:', 'init')
  121. query.value.pageNo = 1
  122. getData()
  123. }
  124. const onSearch = () => {
  125. query.value.pageNo = 1
  126. getData()
  127. }
  128. // 加载更多
  129. const loadingMore = () => {
  130. if (more.value === 'noMore') return
  131. more.value = 'loading'
  132. query.value.pageNo++
  133. getData()
  134. }
  135. const refresh = (reset = false) => {
  136. if (reset) query.value.pageNo = 1
  137. getData()
  138. }
  139. const handleClickAdd = () => {
  140. if (!getAccessToken()) {
  141. uni.showToast({
  142. title: '请先登录',
  143. icon: 'none'
  144. })
  145. showAuthModal()
  146. return
  147. }
  148. uni.navigateTo({ url: '/pagesB/positionAdd/index' })
  149. }
  150. </script>
  151. <style scoped lang="scss">
  152. .stick {
  153. z-index: 1;
  154. position: sticky;
  155. top: 0;
  156. }
  157. .stickFilter {
  158. z-index: 1;
  159. position: sticky;
  160. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  161. top: 110rpx;
  162. }
  163. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  164. .pb-10 {
  165. padding-bottom: 10px;
  166. }
  167. .pb-20 { padding-bottom: 20px; }
  168. .px-5 { padding-left: 5px; padding-right: 5px; }
  169. .px-10 { padding-left: 10px; padding-right: 10px; }
  170. .mx-10 { margin-left: 10px; margin-right: 10px }
  171. .mx-20 { margin-left: 20px; margin-right: 20px; }
  172. .mb-10 { margin-bottom: 10px; }
  173. .box {
  174. height: 100vh;
  175. overflow: hidden;
  176. box-sizing: border-box;
  177. display: flex;
  178. flex-direction: column;
  179. }
  180. .scrollBox{
  181. flex: 1;
  182. height: 0 !important;
  183. padding-bottom: 24rpx;
  184. box-sizing: border-box;
  185. }
  186. .stickBtn{
  187. text-align: center;
  188. width: calc(50% - 2px);
  189. height: 24px;
  190. line-height: 24px;
  191. margin: 8px 0;
  192. color: grey;
  193. font-size: 13px;
  194. }
  195. .newPositionBtn{
  196. color: #00B760;
  197. border-left: 1px solid #c3c3c3;
  198. }
  199. .actColor{
  200. color: #00B760;
  201. }
  202. .addBtn{
  203. position: fixed;
  204. margin-bottom: 20px;
  205. right: 35rpx;
  206. // left: 50%;
  207. // transform: translateX(-50%);
  208. bottom: calc(env(safe-area-inset-bottom) + 60px);
  209. width: 70px;
  210. .addBox {
  211. position: relative;
  212. .icon {
  213. font-size: 42px;
  214. color: #fff;
  215. background-color: #00B760;
  216. width: 50px;
  217. height: 50px;
  218. line-height: 46px;
  219. text-align: center;
  220. border-radius: 50%;
  221. margin: 0 auto;
  222. box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  223. }
  224. .text {
  225. position: absolute;
  226. top: 42px;
  227. font-size: 12px;
  228. color: #00B760;
  229. background-color: #ffffffc9;
  230. text-align: center;
  231. padding: 2px 4px;
  232. margin: 0 auto;
  233. border-radius: 6px;
  234. box-shadow: 0 36px 6px rgba(0, 0, 0, 0.1);
  235. }
  236. }
  237. }
  238. </style>