position.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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" :jobNum="publishJobCount" :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. jobFairId: 0,
  87. name: '',
  88. })
  89. const more = ref('more')
  90. const getData = async () => {
  91. if (query.value.pageNo < 1) return
  92. if (query.value.pageNo === 1) positionListData.value = []
  93. try {
  94. more.value = 'loading'
  95. // if (tab.value !== 3) {
  96. query.value.status = tabList[tab.value].status
  97. // query.value.hasExpiredData = false
  98. // } else {
  99. // query.value.hasExpiredData = true
  100. // delete query.value.status
  101. // }
  102. const res = await getJobAdvertisedList(query.value)
  103. const list = res?.data?.list?.length ? res.data.list : []
  104. total.value = res.data.total-0
  105. if (!list?.length) {
  106. more.value = 'noMore'
  107. return
  108. }
  109. positionListData.value.push(...dealDictArrayData([], list))
  110. more.value = 'more'
  111. if (positionListData.value.length === total.value) {
  112. more.value = 'noMore'
  113. return
  114. }
  115. } catch (error) {
  116. query.value.pageNo--
  117. more.value = 'more'
  118. }
  119. }
  120. // 设置自定义tabbar选中值
  121. onShow(() => {
  122. const currentPage = getCurrentPages()[0] // 获取当前页面实例
  123. const currentTabBar = currentPage?.getTabBar?.()
  124. // 设置当前tab页的下标index
  125. currentTabBar?.setData({ selected: 1 })
  126. init()
  127. // 延迟查询可发布职位数量
  128. setTimeout(() => {
  129. getPublishJobCount()
  130. }, 1000)
  131. })
  132. const publishJobCount = ref(0)
  133. const getPublishJobCount = async () => {
  134. const info = await useUserStore.getUserInfos()
  135. console.log('info:', info)
  136. publishJobCount.value = info?.entitlement?.publishJobCount - 0 || 0
  137. }
  138. const init = () => {
  139. query.value.pageNo = 1
  140. getData()
  141. }
  142. const onSearch = () => {
  143. query.value.pageNo = 1
  144. getData()
  145. }
  146. // 加载更多
  147. const loadingMore = () => {
  148. if (more.value === 'noMore') return
  149. more.value = 'loading'
  150. query.value.pageNo++
  151. getData()
  152. }
  153. // reset: 刷新列表
  154. const refresh = async ({ reset = false }) => {
  155. if (reset) query.value.pageNo = 1
  156. getData()
  157. }
  158. const handleClickAdd = () => {
  159. if (!getAccessToken()) {
  160. uni.showToast({
  161. title: '请先登录',
  162. icon: 'none'
  163. })
  164. showAuthModal()
  165. return
  166. }
  167. uni.navigateTo({ url: '/pagesB/positionAdd/index' })
  168. }
  169. </script>
  170. <style scoped lang="scss">
  171. .stick {
  172. z-index: 1;
  173. position: sticky;
  174. top: 0;
  175. }
  176. .stickFilter {
  177. z-index: 1;
  178. position: sticky;
  179. box-shadow: 0px 10rpx 12rpx 0px rgba(195, 195, 195, .25);
  180. top: 110rpx;
  181. }
  182. .px-0 { padding-left: 0 !important; padding-right: 0 !important; }
  183. .pb-10 {
  184. padding-bottom: 10px;
  185. }
  186. .pb-20 { padding-bottom: 20px; }
  187. .px-5 { padding-left: 5px; padding-right: 5px; }
  188. .px-10 { padding-left: 10px; padding-right: 10px; }
  189. .mx-10 { margin-left: 10px; margin-right: 10px }
  190. .mx-20 { margin-left: 20px; margin-right: 20px; }
  191. .mb-10 { margin-bottom: 10px; }
  192. .box {
  193. height: 100vh;
  194. overflow: hidden;
  195. box-sizing: border-box;
  196. display: flex;
  197. flex-direction: column;
  198. }
  199. .scrollBox{
  200. flex: 1;
  201. height: 0 !important;
  202. padding-bottom: 24rpx;
  203. box-sizing: border-box;
  204. }
  205. .stickBtn{
  206. text-align: center;
  207. width: calc(50% - 2px);
  208. height: 24px;
  209. line-height: 24px;
  210. margin: 8px 0;
  211. color: grey;
  212. font-size: 13px;
  213. }
  214. .newPositionBtn{
  215. color: #00B760;
  216. border-left: 1px solid #c3c3c3;
  217. }
  218. .actColor{
  219. color: #00B760;
  220. }
  221. .addBtn{
  222. position: fixed;
  223. margin-bottom: 20px;
  224. right: 35rpx;
  225. // left: 50%;
  226. // transform: translateX(-50%);
  227. bottom: calc(env(safe-area-inset-bottom) + 60px);
  228. width: 70px;
  229. .addBox {
  230. position: relative;
  231. .icon {
  232. font-size: 42px;
  233. color: #fff;
  234. background-color: #00B760;
  235. width: 50px;
  236. height: 50px;
  237. line-height: 46px;
  238. text-align: center;
  239. border-radius: 50%;
  240. margin: 0 auto;
  241. box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  242. }
  243. .text {
  244. position: absolute;
  245. top: 42px;
  246. font-size: 12px;
  247. color: #00B760;
  248. background-color: #ffffffc9;
  249. text-align: center;
  250. padding: 2px 4px;
  251. margin: 0 auto;
  252. border-radius: 6px;
  253. box-shadow: 0 36px 6px rgba(0, 0, 0, 0.1);
  254. }
  255. }
  256. }
  257. .publishJobCountBox {
  258. font-size: 12px;
  259. margin-left: 30rpx;
  260. color: #666;
  261. padding-bottom: 10px;
  262. .color-primary {
  263. font-weight: bold;
  264. }
  265. }
  266. </style>