position.vue 7.0 KB

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