details.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="bottom-sticky">
  20. <view class="bottom-content">
  21. <button class="btnStyle bgButtons ss-m-l-15" type="primary" plain="true" @tap.stop="handleToShare">我的分享海报</button>
  22. <button class="buttons btnStyle" type="primary" @tap.stop="handleJoinJobFair">职位加入</button>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup>
  28. import { ref } from 'vue'
  29. import { onLoad, onShow } from '@dcloudio/uni-app'
  30. import { getJobFair, getJobFairPosition } from '@/api/jobFair.js'
  31. import { getJobAdvertisedList } from '@/api/new/position'
  32. import { dealDictArrayData } from '@/utils/position.js'
  33. import JobItem from './jobItem.vue'
  34. const id = ref(null)
  35. const tab = ref(0)
  36. const controlList = ['招聘中', '已关闭']
  37. // 获取招聘会信息
  38. const jobFairInfo = ref({})
  39. const getJobFairInfo = async () => {
  40. const { data } = await getJobFair(id.value)
  41. if (!data) return
  42. jobFairInfo.value = data || {}
  43. }
  44. // 招聘中职位
  45. const jobFairPosition = ref([])
  46. const getJobList = async () => {
  47. try {
  48. uni.showLoading({ title: '加载中' })
  49. const { data } = await getJobFairPosition(id.value)
  50. if (!data || !data.length) {
  51. jobFairPosition.value = []
  52. return
  53. }
  54. jobFairPosition.value = dealDictArrayData([], data)
  55. } finally {
  56. uni.hideLoading()
  57. }
  58. }
  59. // 已关闭职位
  60. const more = ref('more')
  61. const pageTotal = ref(0)
  62. const pageInfo = ref({
  63. pageSize: 10,
  64. pageNo: 1
  65. })
  66. const getProgressJobList = async () => {
  67. if (pageInfo.value.pageNo < 1) return
  68. if (pageInfo.value.pageNo === 1) jobFairPosition.value = []
  69. try {
  70. more.value = 'loading'
  71. const res = await getJobAdvertisedList({ ...pageInfo.value, status: '1', jobFairId: id.value, hire: false })
  72. const list = res?.data?.list?.length ? res.data.list : []
  73. pageTotal.value = res.data.total-0
  74. if (!list?.length) {
  75. more.value = 'noMore'
  76. return
  77. }
  78. jobFairPosition.value.push(...dealDictArrayData([], list))
  79. more.value = 'more'
  80. if (jobFairPosition.value.length === pageTotal.value) {
  81. more.value = 'noMore'
  82. return
  83. }
  84. } catch (error) {
  85. pageInfo.value.pageNo--
  86. more.value = 'more'
  87. }
  88. }
  89. // 加载更多
  90. const loadingMore = () => {
  91. // 招聘中职位列表不需要加载更多,属于一次性拿回全部
  92. if (tab.value === 0) return
  93. if (more.value === 'noMore') return
  94. more.value = 'loading'
  95. pageInfo.value.pageNo++
  96. getProgressJobList()
  97. }
  98. const tabChange = (e) => {
  99. tab.value = e.currentIndex
  100. jobFairPosition.value = []
  101. if (tab.value === 0) return getJobList()
  102. pageInfo.value.pageNo = 1
  103. getProgressJobList()
  104. }
  105. onLoad((options) => {
  106. id.value = options.id
  107. if (!id.value) {
  108. uni.showToast({
  109. title: '缺少招聘会id',
  110. icon: 'none'
  111. })
  112. setTimeout(() => {
  113. uni.navigateBack({ delta: 1 })
  114. }, 1000)
  115. return
  116. }
  117. getJobFairInfo()
  118. getJobList()
  119. })
  120. onShow(() => {
  121. if (id.value) {
  122. jobFairPosition.value = []
  123. if (tab.value) {
  124. pageInfo.value.pageNo = 1
  125. getProgressJobList()
  126. return
  127. }
  128. getJobList()
  129. }
  130. })
  131. // 加入招聘会
  132. const handleJoinJobFair = () => {
  133. uni.navigateTo({
  134. url: '/pagesB/jobFair/join?jobFairId=' + id.value
  135. })
  136. }
  137. // 我的分享海报
  138. const handleToShare = () => {
  139. uni.navigateTo({
  140. url: '/pagesB/jobFair/jobFairEntShare?jobFairId=' + id.value
  141. })
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .title {
  146. font-size: 18px;
  147. color: #fff;
  148. }
  149. .title-line {
  150. width: 7px;
  151. height: 18px;
  152. background-color: #fff;
  153. margin-right: 10px;
  154. border-radius: 6px;
  155. margin-top: 3px;
  156. }
  157. .bottom-content {
  158. display: flex;
  159. justify-content: space-evenly;
  160. align-items: center;
  161. width: 100%;
  162. margin: 20rpx 0;
  163. .btnStyle {
  164. flex: 1;
  165. margin-right: 20rpx;
  166. border-radius: 50rpx;
  167. }
  168. .bgButtons {
  169. border: 2rpx solid #00B760;
  170. color: #00B760;
  171. }
  172. &-tool {
  173. width: 160rpx;
  174. display: flex;
  175. justify-content: center;
  176. flex-direction: column;
  177. align-items: center;
  178. }
  179. }
  180. .box {
  181. height: 100vh;
  182. overflow: hidden;
  183. box-sizing: border-box;
  184. display: flex;
  185. flex-direction: column;
  186. }
  187. .scrollBox{
  188. flex: 1;
  189. height: 0 !important;
  190. padding-bottom: 100rpx;
  191. box-sizing: border-box;
  192. }
  193. </style>