position.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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="publishJobCount" 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'
  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. })
  127. const init = () => {
  128. query.value.pageNo = 1
  129. getData()
  130. }
  131. const onSearch = () => {
  132. query.value.pageNo = 1
  133. getData()
  134. }
  135. // 加载更多
  136. const loadingMore = () => {
  137. if (more.value === 'noMore') return
  138. more.value = 'loading'
  139. query.value.pageNo++
  140. getData()
  141. }
  142. // reset: 刷新列表 updatePublishJobCount: 更新可发布职位数量
  143. const refresh = async ({ reset = false, updatePublishJobCount = false }) => {
  144. if (reset) query.value.pageNo = 1
  145. getData()
  146. // if (updatePublishJobCount) {
  147. // userInfo.value = await useUserStore.getUserInfos()
  148. // }
  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/index' })
  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>