position.vue 7.7 KB

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