position.vue 7.7 KB

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