positionClassification.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. import { getShareQueryById } from '@/api/jobFair.js'
  56. const more = ref('more')
  57. const showShareBtn = ref(false)
  58. const listData = ref([])
  59. const query = reactive({
  60. pageSize: 20,
  61. pageNo: 1,
  62. jobFairId: undefined,
  63. })
  64. const entName = ref('')
  65. let obj = {}
  66. onLoad(async (options) => {
  67. // 网站二维码分享
  68. if (options?.scene) {
  69. const key = decodeURIComponent(options?.scene).split('=')[1]
  70. const result = await getShareQueryById({ key })
  71. obj = result.data
  72. }
  73. if (options?.jobFairId || obj?.jobFairId) {
  74. query.jobFairId = options?.jobFairId || obj?.jobFairId
  75. if (options?.enterpriseId || obj?.enterpriseId) {
  76. query.enterpriseId = options?.enterpriseId || obj?.enterpriseId
  77. entName.value = options?.entName || obj?.entName
  78. getEntPositionList()
  79. } else {
  80. getJobFairDetail()
  81. }
  82. }
  83. if (options.backgroundColor || obj?.backgroundColor) backgroundColor.value = options.backgroundColor || obj?.backgroundColor
  84. })
  85. // 招聘会详情
  86. const tabIndex = ref(-1)
  87. const tabList = ref([])
  88. const swiperAdList = ref([])
  89. const backgroundColor = ref('#fff')
  90. const textColor = computed(() => {
  91. return backgroundColor.value === '#fff' ? '#777' : '#fff'
  92. })
  93. const entNameColor = computed(() => {
  94. return backgroundColor.value === '#fff' ? '#00B760' : '#fff'
  95. })
  96. const getJobFairDetail = async () => {
  97. if (!query.jobFairId) return
  98. const { data } = await getJobFair(query.jobFairId)
  99. // tab
  100. if (data?.tag?.length) {
  101. tabList.value = data.tag
  102. tabIndex.value = 0
  103. }
  104. // 轮播图
  105. if (data?.headImg?.length) {
  106. swiperAdList.value = data.headImg
  107. }
  108. // 背景色
  109. if (data?.backgroundColour) {
  110. backgroundColor.value = data.backgroundColour || '#fff'
  111. }
  112. showShareBtn.value= true
  113. getEntPositionList()
  114. }
  115. // 切换类型
  116. const handClickTab = (index) => {
  117. tabIndex.value = index
  118. query.pageNo = 1
  119. listData.value = []
  120. getEntPositionList()
  121. }
  122. const getEntPositionList = async () => {
  123. if (!query.jobFairId) {
  124. uni.showToast({ title: '获取企业岗位失败,请重试!', icon: 'none', duration: 2000 })
  125. return
  126. }
  127. try {
  128. const params = { ...query }
  129. const positionIdValue = tabIndex.value !== -1 ? tabList.value[tabIndex.value]?.value : []
  130. positionIdValue?.length && positionIdValue.forEach((value, index) => {
  131. params[`positionId[${index}]`] = value
  132. })
  133. const res = await getJobFairEntJobPage(params)
  134. const list = res?.data?.list || []
  135. list.forEach(e => {
  136. e.job = dealDictObjData({}, e)
  137. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  138. })
  139. listData.value = listData.value.concat(list)
  140. // showShareBtn.value = true
  141. if (listData.value?.length === +res?.data?.total) {
  142. more.value = 'noMore'
  143. return
  144. }
  145. } catch (error) {
  146. query.pageNo--
  147. more.value = 'more'
  148. }
  149. }
  150. const scrollTop = ref(0)
  151. const old = ref({
  152. scrollTop: 0
  153. })
  154. const onScroll = (e) =>{
  155. old.value.scrollTop = e.detail.scrollTop
  156. }
  157. // 加载更多
  158. const loadingMore = () => {
  159. more.value = 'loading'
  160. query.pageNo++
  161. getEntPositionList()
  162. }
  163. // const goBack = () => {
  164. // uni.navigateTo({
  165. // url: '/pagesB/jobFair/index'
  166. // })
  167. // }
  168. const handleShare = () => {
  169. // 分享招聘会
  170. let url = `/pagesB/jobFair/${query.enterpriseId ? 'jobFairEntShare' : 'jobFairShare'}?jobFairId=${query.jobFairId}`
  171. // 分享招聘会-企业
  172. if (query.enterpriseId) url = url + `&enterpriseId=${query.enterpriseId}`
  173. //
  174. uni.navigateTo({ url })
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. .stick {
  179. z-index: 1;
  180. position: sticky;
  181. top: 0;
  182. }
  183. .shareButtonBox {
  184. z-index: 1;
  185. position: fixed;
  186. right: 20px;
  187. top: 16px;
  188. border-radius: 50%;
  189. padding: 8px;
  190. background-color: #00B760;
  191. }
  192. .box {
  193. height: 100vh;
  194. overflow: hidden;
  195. // padding-bottom: 120rpx;
  196. box-sizing: border-box;
  197. display: flex;
  198. flex-direction: column;
  199. }
  200. .listDataBox {
  201. // padding: 1px 0 120rpx;
  202. padding-bottom: 120rpx;
  203. margin: 0 5rpx;
  204. }
  205. .scrollBox{
  206. flex: 1;
  207. height: 0 !important;
  208. padding-bottom: 24rpx;
  209. box-sizing: border-box;
  210. }
  211. // :deep(.uni-load-more__text) {
  212. // color: #fff !important;
  213. // }
  214. :deep(.uni-card) {
  215. padding: 0 !important;
  216. .uni-card__content {
  217. padding: 0 !important;
  218. }
  219. }
  220. .scroll-container {
  221. width: calc(100vw - 20px);
  222. padding: 0 20rpx;
  223. white-space: nowrap; /* 确保子元素在一行内排列 */
  224. .scroll-item {
  225. display: inline-block; /* 子元素内联块显示 */
  226. color: #fff;
  227. font-size: 17px;
  228. font-weight: 500;
  229. .text {
  230. padding: 20px 2px 0;
  231. }
  232. .choose {
  233. width: 28px;
  234. height: 2px;
  235. border-radius: 8px;
  236. margin: 8px auto;
  237. }
  238. }
  239. }
  240. .enterpriseName {
  241. position: relative;
  242. padding: 18px 30rpx;
  243. padding-left: 39px;
  244. height: 24px;
  245. line-height: 24px;
  246. color: #fff;
  247. font-size: 18px;
  248. font-weight: bold;
  249. &::before {
  250. display: block;
  251. content: '';
  252. width: 4px;
  253. height: 24px;
  254. background-color: #fff;
  255. position: absolute;
  256. top: 20px;
  257. left: 25px;
  258. border-radius: 2px;
  259. }
  260. }
  261. </style>