positionClassification.vue 7.4 KB

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