position.vue 7.3 KB

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