position.vue 7.5 KB

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