details.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="box" :style="`background-color: ${jobFairInfo?.backgroundColour}`">
  3. <view class="d-flex" style="padding: 15px 15px 0 15px;">
  4. <view class="title-line"></view>
  5. <rich-text class="title" :nodes="jobFairInfo?.title?.replace(/<\/?p[^>]*>/gi, '')"></rich-text>
  6. </view>
  7. <uni-segmented-control :current="tab" :values="controlList" @clickItem="tabChange" styleType="text" activeColor="#00B760" />
  8. <scroll-view class="scrollBox" :scroll-y="true" style="position:relative;" @scrolltolower="loadingMore">
  9. <JobItem
  10. v-if="jobFairPosition?.length"
  11. :list="jobFairPosition"
  12. :jobFairId="id"
  13. :tab="tab"
  14. :jobFairName="jobFairInfo?.title?.replace(/<\/?p[^>]*>/gi, '')"
  15. @refresh="tabChange({ currentIndex: tab })"
  16. />
  17. <uni-load-more v-else status="noMore" />
  18. </scroll-view>
  19. <view class="addBtn" @tap="handleClickAdd">
  20. <view class="addBox">
  21. <view class="icon">+</view>
  22. <view class="text">发布新职位</view>
  23. </view>
  24. </view>
  25. <view class="bottom-sticky">
  26. <view class="bottom-content">
  27. <button class="btnStyle bgButtons ss-m-l-15" type="primary" plain="true" @tap.stop="handleToShare">我的分享海报</button>
  28. <button class="buttons btnStyle" type="primary" @tap.stop="handleJoinJobFair">克隆已有职位发布</button>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script setup>
  34. import { ref } from 'vue'
  35. import { onLoad, onShow } from '@dcloudio/uni-app'
  36. import { getJobFair, getJobFairPosition } from '@/api/jobFair.js'
  37. import { getJobAdvertisedList } from '@/api/new/position'
  38. import { dealDictArrayData } from '@/utils/position.js'
  39. import JobItem from './jobItem.vue'
  40. import { getAccessToken } from '@/utils/request'
  41. import { showAuthModal } from '@/hooks/useModal'
  42. const id = ref(null)
  43. const tab = ref(0)
  44. const controlList = ['招聘中', '已关闭']
  45. // 获取招聘会信息
  46. const jobFairInfo = ref({})
  47. const getJobFairInfo = async () => {
  48. const { data } = await getJobFair(id.value)
  49. if (!data) return
  50. jobFairInfo.value = data || {}
  51. }
  52. // 招聘中职位
  53. const jobFairPosition = ref([])
  54. const getJobList = async () => {
  55. try {
  56. uni.showLoading({ title: '加载中' })
  57. const { data } = await getJobFairPosition(id.value)
  58. if (!data || !data.length) {
  59. jobFairPosition.value = []
  60. return
  61. }
  62. jobFairPosition.value = dealDictArrayData([], data)
  63. } finally {
  64. uni.hideLoading()
  65. }
  66. }
  67. // 已关闭职位
  68. const more = ref('more')
  69. const pageTotal = ref(0)
  70. const pageInfo = ref({
  71. pageSize: 10,
  72. pageNo: 1
  73. })
  74. const getProgressJobList = async () => {
  75. if (pageInfo.value.pageNo < 1) return
  76. if (pageInfo.value.pageNo === 1) jobFairPosition.value = []
  77. try {
  78. more.value = 'loading'
  79. const res = await getJobAdvertisedList({ ...pageInfo.value, status: '1', jobFairId: id.value, hire: false })
  80. const list = res?.data?.list?.length ? res.data.list : []
  81. pageTotal.value = res.data.total-0
  82. if (!list?.length) {
  83. more.value = 'noMore'
  84. return
  85. }
  86. jobFairPosition.value.push(...dealDictArrayData([], list))
  87. more.value = 'more'
  88. if (jobFairPosition.value.length === pageTotal.value) {
  89. more.value = 'noMore'
  90. return
  91. }
  92. } catch (error) {
  93. pageInfo.value.pageNo--
  94. more.value = 'more'
  95. }
  96. }
  97. // 加载更多
  98. const loadingMore = () => {
  99. // 招聘中职位列表不需要加载更多,属于一次性拿回全部
  100. if (tab.value === 0) return
  101. if (more.value === 'noMore') return
  102. more.value = 'loading'
  103. pageInfo.value.pageNo++
  104. getProgressJobList()
  105. }
  106. const tabChange = (e) => {
  107. tab.value = e.currentIndex
  108. jobFairPosition.value = []
  109. if (tab.value === 0) return getJobList()
  110. pageInfo.value.pageNo = 1
  111. getProgressJobList()
  112. }
  113. // 职位新增
  114. const handleClickAdd = () => {
  115. if (!getAccessToken()) {
  116. uni.showToast({
  117. title: '请先登录',
  118. icon: 'none'
  119. })
  120. showAuthModal()
  121. return
  122. }
  123. uni.navigateTo({ url: '/pagesB/jobFair/addJob?jobFairId=' + id.value })
  124. }
  125. onLoad((options) => {
  126. id.value = options.id
  127. if (!id.value) {
  128. uni.showToast({
  129. title: '缺少招聘会id',
  130. icon: 'none'
  131. })
  132. setTimeout(() => {
  133. uni.navigateBack({ delta: 1 })
  134. }, 1000)
  135. return
  136. }
  137. getJobFairInfo()
  138. getJobList()
  139. })
  140. onShow(() => {
  141. if (id.value) {
  142. jobFairPosition.value = []
  143. if (tab.value) {
  144. pageInfo.value.pageNo = 1
  145. getProgressJobList()
  146. return
  147. }
  148. getJobList()
  149. }
  150. })
  151. // 加入招聘会
  152. const handleJoinJobFair = () => {
  153. uni.navigateTo({
  154. url: '/pagesB/jobFair/join?jobFairId=' + id.value
  155. })
  156. }
  157. // 我的分享海报
  158. const handleToShare = () => {
  159. uni.navigateTo({
  160. url: '/pagesB/jobFair/jobFairEntShare?jobFairId=' + id.value
  161. })
  162. }
  163. </script>
  164. <style scoped lang="scss">
  165. .title {
  166. font-size: 18px;
  167. color: #fff;
  168. }
  169. .title-line {
  170. width: 7px;
  171. height: 18px;
  172. background-color: #fff;
  173. margin-right: 10px;
  174. border-radius: 6px;
  175. margin-top: 3px;
  176. }
  177. .bottom-content {
  178. display: flex;
  179. justify-content: space-evenly;
  180. align-items: center;
  181. width: 100%;
  182. margin: 20rpx 0;
  183. .btnStyle {
  184. flex: 1;
  185. margin-right: 20rpx;
  186. border-radius: 50rpx;
  187. }
  188. .bgButtons {
  189. border: 2rpx solid #00B760;
  190. color: #00B760;
  191. }
  192. &-tool {
  193. width: 160rpx;
  194. display: flex;
  195. justify-content: center;
  196. flex-direction: column;
  197. align-items: center;
  198. }
  199. }
  200. .box {
  201. height: 100vh;
  202. overflow: hidden;
  203. box-sizing: border-box;
  204. display: flex;
  205. flex-direction: column;
  206. }
  207. .scrollBox{
  208. flex: 1;
  209. height: 0 !important;
  210. padding-bottom: 100rpx;
  211. box-sizing: border-box;
  212. }
  213. .addBtn{
  214. position: fixed;
  215. margin-bottom: 20px;
  216. right: 35rpx;
  217. bottom: calc(env(safe-area-inset-bottom) + 60px);
  218. width: 70px;
  219. .addBox {
  220. position: relative;
  221. .icon {
  222. font-size: 42px;
  223. color: #fff;
  224. background-color: #00B760;
  225. width: 50px;
  226. height: 50px;
  227. line-height: 46px;
  228. text-align: center;
  229. border-radius: 50%;
  230. margin: 0 auto;
  231. box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  232. }
  233. .text {
  234. position: absolute;
  235. top: 42px;
  236. font-size: 12px;
  237. color: #00B760;
  238. background-color: #ffffffc9;
  239. text-align: center;
  240. padding: 2px 4px;
  241. margin: 0 auto;
  242. border-radius: 6px;
  243. // box-shadow: 0 36px 6px rgba(0, 0, 0, 0.1);
  244. }
  245. }
  246. }
  247. </style>