positionClassification.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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 style="position: relative;">
  7. <!-- 招聘会企业下的职位列表 -->
  8. <template v-if="query?.enterpriseId">
  9. <view class="enterpriseName" :style="`color: ${entNameColor}`">{{ entName }}</view>
  10. <view class="stick ss-p-y-30" :style="`background-color: ${backgroundColor}`">
  11. <!-- 搜索条 -->
  12. <view style="position: relative;">
  13. <uni-search-bar
  14. v-model="query.keyword"
  15. placeholder="输入关键字"
  16. cancelButton="none"
  17. :focus="false"
  18. bgColor="#fff"
  19. @confirm="onSearch($event.value)"
  20. @clear="query.keyword = ''; onSearch()"
  21. >
  22. </uni-search-bar>
  23. <button class="search-btn" @tap.stop="onSearch">搜索</button>
  24. </view>
  25. </view>
  26. </template>
  27. <!-- 招聘会职位列表 -->
  28. <template v-else>
  29. <SwiperAd v-if="swiperAdList.length && !query.enterpriseId" :list="swiperAdList" margin="0" borderRadius="0"></SwiperAd>
  30. <view class="stick ss-p-y-30" :style="`background-color: ${backgroundColor}`">
  31. <view style="position: relative;">
  32. <uni-search-bar
  33. v-model="query.keyword"
  34. placeholder="输入关键字"
  35. cancelButton="none"
  36. :focus="false"
  37. bgColor="#fff"
  38. @confirm="onSearch($event.value)"
  39. @clear="query.keyword = ''; onSearch()"
  40. >
  41. </uni-search-bar>
  42. <button class="search-btn" @tap.stop="onSearch">搜索</button>
  43. </view>
  44. <!-- 横向分类页签 -->
  45. <scroll-view v-if="tabList?.length && !query.enterpriseId" scroll-x="true" class="scroll-container">
  46. <view
  47. class="scroll-item"
  48. :style="`margin-left: ${index ? '24px' : ''};`"
  49. v-for="(val, index) in tabList" :key="index+val"
  50. @tap="handClickTab(index)"
  51. >
  52. <view>
  53. <view class="text">{{ val.title }}</view>
  54. <view v-if="index === tabIndex" class="choose" style="background-color: #fff;"></view>
  55. <view v-else class="choose" style="background-color: #ffffff00;"></view>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. </view>
  60. </template>
  61. <view v-if="listData?.length" class="listDataBox">
  62. <PositionList
  63. :list="listData"
  64. :noMore="false"
  65. :jobFairId="query.jobFairId"
  66. :showUpdateTime="false"
  67. :noDataTextColor="textColor"
  68. @entClick="entClick"
  69. ></PositionList>
  70. <uni-load-more :status="more" :color="textColor" />
  71. </view>
  72. <view v-else class="nodata-img-parent">
  73. <uni-load-more class="ss-m-t-50" :color="textColor" status="noMore" :content-text="{'contentnomore': loading ? '加载中. . .' : tabList?.length ? '暂无数据,请切换类型查看~': '暂无数据'}" />
  74. </view>
  75. <!-- 招聘会分享按钮 -->
  76. <view v-if="showShareBtn" class="shareButtonBox" @tap="handleShare">
  77. <uni-icons type="redo-filled" size="30" color="#00B760" />
  78. </view>
  79. </view>
  80. </scroll-view>
  81. </view>
  82. </template>
  83. <script setup>
  84. import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  85. import { ref, reactive, computed } from 'vue'
  86. import { dealDictObjData } from '@/utils/position'
  87. import { getJobFairEntJobPage, getJobFair } from '@/api/jobFair'
  88. import PositionList from '@/components/PositionList'
  89. import SwiperAd from '@/components/SwiperAd'
  90. import { getShareQueryById } from '@/api/jobFair.js'
  91. const loading = ref(true)
  92. const more = ref('more')
  93. const listData = ref([])
  94. const query = reactive({
  95. pageSize: 20,
  96. pageNo: 1,
  97. keyword: '',
  98. jobFairId: undefined,
  99. })
  100. const entName = ref('')
  101. const showShareBtn = ref(false)
  102. onLoad(async (options) => {
  103. // 海报二维码分享
  104. if (options.scene) {
  105. const scene = decodeURIComponent(options.scene)
  106. console.log(scene, 'scene')
  107. const key = scene.split('=')[1]
  108. if (!key) return
  109. const res = await getShareQueryById({key})
  110. console.log(res, 'result')
  111. options.jobFairId = res?.data?.jobFairId
  112. options.enterpriseId = res?.data?.enterpriseId
  113. options.backgroundColor = res?.data?.backgroundColor
  114. options.entName = res?.data?.entName
  115. }
  116. if (options?.jobFairId) {
  117. query.jobFairId = options.jobFairId
  118. if (options.enterpriseId) {
  119. query.enterpriseId = options.enterpriseId
  120. entName.value = options.entName
  121. getEntShareImg()
  122. getEntPositionList()
  123. } else {
  124. getJobFairDetail()
  125. }
  126. }
  127. if (options.backgroundColor) backgroundColor.value = options.backgroundColor
  128. // 转发朋友
  129. onShareAppMessage(() => {
  130. if (!options?.enterpriseId && !jobFairTitle.value) setTimeout(() => {}, 1000)
  131. let path = `/pagesB/jobFair/positionClassification?jobFairId=${options.jobFairId}`
  132. if (options?.enterpriseId) path += `&enterpriseId=${options.enterpriseId}&entName=${options.entName}`
  133. return {
  134. title: options?.enterpriseId ? options?.entName || '门墩儿 专注顶尖招聘' : jobFairTitle.value,
  135. path
  136. }
  137. })
  138. // 转发朋圈
  139. onShareTimeline(() => {
  140. if (!query.enterpriseId && !jobFairTitle.value) setTimeout(() => {}, 1000)
  141. let path = `/pagesB/jobFair/positionClassification?jobFairId=${options.jobFairId}`
  142. if (options?.enterpriseId) path += `&enterpriseId=${options.enterpriseId}&entName=${options.entName}`
  143. return {
  144. title: query.enterpriseId ? entName.value || '门墩儿 专注顶尖招聘' : jobFairTitle.value,
  145. path
  146. }
  147. })
  148. })
  149. // 招聘会详情
  150. const tabIndex = ref(-1)
  151. const tabList = ref([])
  152. const swiperAdList = ref([])
  153. const backgroundColor = ref('#fff')
  154. const jobFairTitle = ref('')
  155. const textColor = computed(() => {
  156. return backgroundColor.value === '#fff' ? '#777' : '#fff'
  157. })
  158. const entNameColor = computed(() => {
  159. return backgroundColor.value === '#fff' ? '#00B760' : '#fff'
  160. })
  161. const getJobFairDetail = async () => {
  162. if (!query.jobFairId) return
  163. const { data } = await getJobFair(query.jobFairId)
  164. // 类型 -1为不传tag参数
  165. tabList.value = data?.tag || []
  166. handClickTab(tabList.value?.length ? 0 : -1)
  167. // 轮播图
  168. if (data?.headImg?.length) {
  169. swiperAdList.value = data.headImg
  170. }
  171. // 背景色
  172. if (data?.backgroundColour) {
  173. backgroundColor.value = data.backgroundColour || '#fff'
  174. }
  175. if (data?.title) {
  176. jobFairTitle.value = data.title
  177. }
  178. showShareBtn.value = Boolean(data?.shareImg)
  179. }
  180. const getEntShareImg = async () => {
  181. if (!query.jobFairId) return
  182. const { data } = await getJobFair(query.jobFairId)
  183. showShareBtn.value = Boolean(data?.contentImg)
  184. backgroundColor.value = data.backgroundColour || '#fff'
  185. }
  186. // 切换类型
  187. const handClickTab = (index) => {
  188. tabIndex.value = index
  189. query.pageNo = 1
  190. listData.value = []
  191. getEntPositionList()
  192. }
  193. const onSearch = () => {
  194. query.pageNo = 1
  195. listData.value = []
  196. getEntPositionList()
  197. }
  198. const getEntPositionList = async () => {
  199. if (!query.jobFairId) {
  200. uni.showToast({ title: '获取企业岗位失败,请重试!', icon: 'none', duration: 2000 })
  201. return
  202. }
  203. try {
  204. const params = { ...query }
  205. // tab对应的职位类型id列表
  206. const idList = tabIndex.value !== -1 ? tabList.value[tabIndex.value]?.value : []
  207. idList?.length && idList.forEach((value, index) => { params[`positionId[${index}]`] = value })
  208. //
  209. const res = await getJobFairEntJobPage(params)
  210. const list = res?.data?.list || []
  211. list.forEach(e => {
  212. e.job = dealDictObjData({}, e)
  213. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  214. })
  215. listData.value = listData.value.concat(list)
  216. loading.value = false
  217. if (listData.value?.length === +res?.data?.total) {
  218. more.value = 'noMore'
  219. return
  220. }
  221. } catch (error) {
  222. query.pageNo--
  223. more.value = 'more'
  224. }
  225. }
  226. const scrollTop = ref(0)
  227. const old = ref({
  228. scrollTop: 0
  229. })
  230. const onScroll = (e) =>{
  231. old.value.scrollTop = e.detail.scrollTop
  232. }
  233. // 加载更多
  234. const loadingMore = () => {
  235. more.value = 'loading'
  236. query.pageNo++
  237. getEntPositionList()
  238. }
  239. // const goBack = () => {
  240. // uni.navigateTo({
  241. // url: '/pagesB/jobFair/index'
  242. // })
  243. // }
  244. const entClick = (info) => {
  245. // 点击企业信息跳转企业职位列表(招聘会内)。如果已经在了则不跳转
  246. if (info?.enterpriseId && !query.enterpriseId) {
  247. const url = `/pagesB/jobFair/positionClassification?jobFairId=${query.jobFairId }&enterpriseId=${info.enterpriseId}&entName=${info.anotherName}`
  248. uni.navigateTo({ url })
  249. }
  250. }
  251. const handleShare = () => {
  252. // 分享招聘会
  253. let url = `/pagesB/jobFair/${query.enterpriseId ? 'jobFairEntShare' : 'jobFairShare'}?jobFairId=${query.jobFairId}`
  254. // 分享招聘会企业
  255. if (query.enterpriseId) url = url + `&enterpriseId=${query.enterpriseId}`
  256. uni.navigateTo({ url })
  257. }
  258. // 转发
  259. const getShareParams = async () => {
  260. const shareParams = {
  261. title: '门墩儿-招聘会',
  262. path: `/pagesB/jobFair/positionClassification?jobFairId=${query.jobFairId}`,
  263. }
  264. try {
  265. if (query.enterpriseId) {
  266. shareParams.title = entName.value || shareParams.title
  267. shareParams.path = shareParams.path + `&enterpriseId=${query.enterpriseId}&entName=${entName.value}`
  268. } else {
  269. if (!jobFairTitle.value) await getJobFairDetail() // 尝试异步获取
  270. if (jobFairTitle.value) shareParams.title = jobFairTitle.value
  271. }
  272. return shareParams
  273. } catch (error) {
  274. // 返回默认值
  275. return shareParams
  276. }
  277. }
  278. </script>
  279. <style scoped lang="scss">
  280. .stick {
  281. z-index: 1;
  282. position: sticky;
  283. top: 0;
  284. }
  285. .shareButtonBox {
  286. z-index: 1;
  287. position: absolute;
  288. right: 20px;
  289. top: 16px;
  290. border-radius: 8px;
  291. padding: 7px 9px;
  292. background-color: #fff;
  293. }
  294. .box {
  295. height: 100vh;
  296. overflow: hidden;
  297. // padding-bottom: 120rpx;
  298. box-sizing: border-box;
  299. display: flex;
  300. flex-direction: column;
  301. }
  302. .listDataBox {
  303. // padding: 1px 0 120rpx;
  304. padding-bottom: 120rpx;
  305. margin: 0 5rpx;
  306. }
  307. .scrollBox{
  308. flex: 1;
  309. height: 0 !important;
  310. padding-bottom: 24rpx;
  311. box-sizing: border-box;
  312. }
  313. // :deep(.uni-load-more__text) {
  314. // color: #fff !important;
  315. // }
  316. :deep(.uni-card) {
  317. padding: 0 !important;
  318. .uni-card__content {
  319. padding: 0 !important;
  320. }
  321. }
  322. .scroll-container {
  323. width: calc(100vw - 20px);
  324. padding: 0 20rpx;
  325. white-space: nowrap; /* 确保子元素在一行内排列 */
  326. .scroll-item {
  327. display: inline-block; /* 子元素内联块显示 */
  328. color: #fff;
  329. font-size: 17px;
  330. font-weight: 500;
  331. .text {
  332. padding: 20px 2px 0;
  333. }
  334. .choose {
  335. width: 28px;
  336. height: 2px;
  337. border-radius: 8px;
  338. margin: 8px auto;
  339. }
  340. }
  341. }
  342. .enterpriseName {
  343. color: #fff;
  344. font-size: 18px;
  345. font-weight: bold;
  346. line-height: 28px;
  347. padding: 20px 80px 20px 30px;
  348. position: relative;
  349. &::before {
  350. display: block;
  351. content: '';
  352. width: 6px;
  353. height: 30px;
  354. background-color: #fff;
  355. position: absolute;
  356. top: 20px;
  357. left: 12px;
  358. border-radius: 2px;
  359. }
  360. }
  361. :deep(.uni-searchbar) {
  362. // background-color: #fff !important;
  363. padding: 0;
  364. margin: 0 10px;
  365. border-radius: 5px;
  366. }
  367. :deep(.uni-searchbar__box) {
  368. width: calc(100% - 100px);
  369. height: 40px !important;
  370. // border: 1px solid #00B760;
  371. padding-right: 20px;
  372. flex: none;
  373. background-color: #fff;
  374. }
  375. .search-btn {
  376. position: absolute;
  377. right: 13px;
  378. top: 3px;
  379. width: 106px;
  380. height: 34px;
  381. line-height: 34px;
  382. font-size: 16px;
  383. // margin: 4px 4px 4px 0;
  384. background-color: #00B760;
  385. color: #fff;
  386. border-radius: 5px;
  387. z-index: 9;
  388. }
  389. </style>