positionClassification.vue 7.5 KB

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