positionClassification.vue 8.0 KB

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