positionClassification.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <!-- 招聘会职位列表 / 招聘会内的企业下-职位列表 -->
  2. <!-- 没有企业ID的就是招聘会下的职位列表。存在企业ID的就是招聘会企业下的职位列表。 -->
  3. <template>
  4. <view class="box" :style="`background-color: ${backgroundColor}`">
  5. <scroll-view class="scrollBox" :scroll-y="true" :scroll-top="scrollTop" @scrolltolower="loadingMore" @scroll="onScroll" style="position:relative;">
  6. <view>
  7. <!-- 轮播图 -->
  8. <SwiperAd v-if="swiperAdList.length" :list="swiperAdList" margin="0" borderRadius="0" @click="handleToDetails"></SwiperAd>
  9. <view class="stick" :style="`background-color: ${backgroundColor}`">
  10. <!-- tab页签 -->
  11. <scroll-view v-if="tabList?.length" scroll-x="true" class="scroll-container">
  12. <view
  13. class="scroll-item"
  14. :style="`margin-left: ${index ? '24px' : ''};`"
  15. v-for="(val, index) in tabList" :key="index+val"
  16. @tap="handClickTab(index)"
  17. >
  18. <view>
  19. <view class="text">{{ val.title }}</view>
  20. <view v-if="index === tabIndex" class="choose" style="background-color: #fff;"></view>
  21. <view v-else class="choose" style="background-color: #ffffff00;"></view>
  22. </view>
  23. </view>
  24. </scroll-view>
  25. <!-- entName 企业》企业内职位列表 -->
  26. <view v-if="entName" class="enterpriseName" :style="`color: ${entNameColor}`">{{ entName }}</view>
  27. </view>
  28. <view v-if="listData?.length" class="listDataBox">
  29. <PositionList
  30. :list="listData"
  31. :noMore="false"
  32. :jobFairId="query.jobFairId"
  33. :showUpdateTime="false"
  34. :noDataTextColor="textColor"
  35. ></PositionList>
  36. <uni-load-more :status="more" :color="textColor" />
  37. </view>
  38. <view v-else class="nodata-img-parent">
  39. <uni-load-more class="ss-m-t-50" :color="textColor" status="noMore" :content-text="{'contentnomore': '暂无数据,请切换类型查看~'}" />
  40. </view>
  41. </view>
  42. </scroll-view>
  43. <view v-if="showShareBtn" class="shareButtonBox" @tap="handleShare">
  44. <uni-icons type="redo-filled" size="20" color="#fff" />
  45. </view>
  46. </view>
  47. </template>
  48. <script setup>
  49. import { onLoad } from '@dcloudio/uni-app'
  50. import { ref, reactive, computed } from 'vue'
  51. import { dealDictObjData } from '@/utils/position'
  52. import { getJobFairEntJobPage, getJobFair } from '@/api/jobFair'
  53. import PositionList from '@/components/PositionList'
  54. import SwiperAd from '@/components/SwiperAd'
  55. const more = ref('more')
  56. const showShareBtn = ref(false)
  57. const listData = ref([])
  58. const query = reactive({
  59. pageSize: 20,
  60. pageNo: 1,
  61. jobFairId: undefined,
  62. })
  63. const entName = ref('')
  64. onLoad(async (options) => {
  65. if (options?.jobFairId) {
  66. query.jobFairId = options.jobFairId
  67. if (options.enterpriseId) {
  68. query.enterpriseId = options.enterpriseId
  69. entName.value = options.entName
  70. getEntPositionList()
  71. } else {
  72. getJobFairDetail()
  73. }
  74. }
  75. if (options.backgroundColor) backgroundColor.value = options.backgroundColor
  76. })
  77. // 招聘会详情
  78. const tabIndex = ref(-1)
  79. const tabList = ref([])
  80. const swiperAdList = ref([])
  81. const backgroundColor = ref('#fff')
  82. const textColor = computed(() => {
  83. return backgroundColor.value === '#fff' ? '#777' : '#fff'
  84. })
  85. const entNameColor = computed(() => {
  86. return backgroundColor.value === '#fff' ? '#00B760' : '#fff'
  87. })
  88. const getJobFairDetail = async () => {
  89. if (!query.jobFairId) return
  90. const { data } = await getJobFair(query.jobFairId)
  91. // tab
  92. if (data?.tag?.length) {
  93. tabList.value = data.tag
  94. tabIndex.value = 0
  95. }
  96. // 轮播图
  97. if (data?.headImg?.length) {
  98. swiperAdList.value = data.headImg
  99. }
  100. // 背景色
  101. if (data?.backgroundColour) {
  102. backgroundColor.value = data.backgroundColour || '#fff'
  103. }
  104. showShareBtn.value= true
  105. getEntPositionList()
  106. }
  107. // 切换类型
  108. const handClickTab = (index) => {
  109. tabIndex.value = index
  110. query.pageNo = 1
  111. listData.value = []
  112. getEntPositionList()
  113. }
  114. const getEntPositionList = async () => {
  115. if (!query.jobFairId) {
  116. uni.showToast({ title: '获取企业岗位失败,请重试!', icon: 'none', duration: 2000 })
  117. return
  118. }
  119. try {
  120. const params = { ...query }
  121. const positionIdValue = tabIndex.value !== -1 ? tabList.value[tabIndex.value]?.value : []
  122. positionIdValue?.length && positionIdValue.forEach((value, index) => {
  123. params[`positionId[${index}]`] = value
  124. })
  125. const res = await getJobFairEntJobPage(params)
  126. const list = res?.data?.list || []
  127. list.forEach(e => {
  128. e.job = dealDictObjData({}, e)
  129. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  130. })
  131. listData.value = listData.value.concat(list)
  132. // showShareBtn.value = true
  133. if (listData.value?.length === +res?.data?.total) {
  134. more.value = 'noMore'
  135. return
  136. }
  137. } catch (error) {
  138. query.pageNo--
  139. more.value = 'more'
  140. }
  141. }
  142. const scrollTop = ref(0)
  143. const old = ref({
  144. scrollTop: 0
  145. })
  146. const onScroll = (e) =>{
  147. old.value.scrollTop = e.detail.scrollTop
  148. }
  149. // 加载更多
  150. const loadingMore = () => {
  151. more.value = 'loading'
  152. query.pageNo++
  153. getEntPositionList()
  154. }
  155. // const goBack = () => {
  156. // uni.navigateTo({
  157. // url: '/pagesB/jobFair/index'
  158. // })
  159. // }
  160. const handleShare = () => {
  161. // 分享招聘会
  162. let url = `/pagesB/jobFair/${query.enterpriseId ? 'jobFairEntShare' : 'jobFairShare'}?jobFairId=${query.jobFairId}`
  163. // 分享招聘会-企业
  164. if (query.enterpriseId) url = url + `&enterpriseId=${query.enterpriseId}`
  165. //
  166. uni.navigateTo({ url })
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .stick {
  171. z-index: 1;
  172. position: sticky;
  173. top: 0;
  174. }
  175. .shareButtonBox {
  176. z-index: 1;
  177. position: fixed;
  178. right: 20px;
  179. top: 16px;
  180. border-radius: 50%;
  181. padding: 8px;
  182. background-color: #00B760;
  183. }
  184. .box {
  185. height: 100vh;
  186. overflow: hidden;
  187. // padding-bottom: 120rpx;
  188. box-sizing: border-box;
  189. display: flex;
  190. flex-direction: column;
  191. }
  192. .listDataBox {
  193. // padding: 1px 0 120rpx;
  194. padding-bottom: 120rpx;
  195. margin: 0 5rpx;
  196. }
  197. .scrollBox{
  198. flex: 1;
  199. height: 0 !important;
  200. padding-bottom: 24rpx;
  201. box-sizing: border-box;
  202. }
  203. // :deep(.uni-load-more__text) {
  204. // color: #fff !important;
  205. // }
  206. :deep(.uni-card) {
  207. padding: 0 !important;
  208. .uni-card__content {
  209. padding: 0 !important;
  210. }
  211. }
  212. .scroll-container {
  213. width: calc(100vw - 20px);
  214. padding: 0 20rpx;
  215. white-space: nowrap; /* 确保子元素在一行内排列 */
  216. .scroll-item {
  217. display: inline-block; /* 子元素内联块显示 */
  218. color: #fff;
  219. font-size: 17px;
  220. font-weight: 500;
  221. .text {
  222. padding: 20px 2px 0;
  223. }
  224. .choose {
  225. width: 28px;
  226. height: 2px;
  227. border-radius: 8px;
  228. margin: 8px auto;
  229. }
  230. }
  231. }
  232. .enterpriseName {
  233. position: relative;
  234. padding: 18px 30rpx;
  235. padding-left: 39px;
  236. height: 24px;
  237. line-height: 24px;
  238. color: #fff;
  239. font-size: 18px;
  240. font-weight: bold;
  241. &::before {
  242. display: block;
  243. content: '';
  244. width: 4px;
  245. height: 24px;
  246. background-color: #fff;
  247. position: absolute;
  248. top: 20px;
  249. left: 25px;
  250. border-radius: 2px;
  251. }
  252. }
  253. </style>