position.vue 8.0 KB

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