position.vue 8.0 KB

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