position.vue 7.0 KB

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