positionClassification.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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}`">{{ formatName(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">{{ formatName(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. import { formatName } from '@/utils/getText'
  92. import { decodeURIComponentSafe } from '@/utils/index.js'
  93. import { getEnterpriseDetails } from '@/api/user'
  94. const loading = ref(true)
  95. const more = ref('more')
  96. const listData = ref([])
  97. const query = reactive({
  98. pageSize: 20,
  99. pageNo: 1,
  100. keyword: '',
  101. jobFairId: undefined,
  102. })
  103. const entName = ref('')
  104. const showShareBtn = ref(false)
  105. onLoad(async (options) => {
  106. if (options.scene) { // 海报二维码分享
  107. const scene = decodeURIComponent(options.scene)
  108. console.log(scene, 'scene')
  109. const key = scene.split('=')[1]
  110. if (!key) return
  111. const res = await getShareQueryById({key})
  112. console.log(res, 'result')
  113. options.jobFairId = res?.data?.jobFairId
  114. options.enterpriseId = res?.data?.enterpriseId
  115. options.backgroundColor = res?.data?.backgroundColor
  116. entName.value = formatName(res?.data?.entName)
  117. }
  118. if (options?.jobFairId) {
  119. query.jobFairId = options.jobFairId
  120. if (options.enterpriseId) {
  121. query.enterpriseId = options.enterpriseId
  122. getShareImg()
  123. getEntPositionList()
  124. await getEnterpriseInfo()
  125. } else {
  126. getJobFairDetail()
  127. }
  128. }
  129. if (options.backgroundColor) backgroundColor.value = decodeURIComponentSafe(options.backgroundColor)
  130. // 转发朋友
  131. onShareAppMessage(() => {
  132. if (!options?.enterpriseId && !jobFairTitle.value) setTimeout(() => {}, 1000)
  133. let path = `/pagesB/jobFair/positionClassification?jobFairId=${options.jobFairId}`
  134. if (options?.enterpriseId) path += `&enterpriseId=${options.enterpriseId}`
  135. return {
  136. title: options?.enterpriseId ? entName.value || '门墩儿 专注顶尖招聘' : jobFairTitle.value,
  137. path
  138. }
  139. })
  140. // 转发朋圈
  141. onShareTimeline(() => {
  142. if (!query.enterpriseId && !jobFairTitle.value) setTimeout(() => {}, 1000)
  143. let path = `/pagesB/jobFair/positionClassification?jobFairId=${options.jobFairId}`
  144. if (options?.enterpriseId) path += `&enterpriseId=${options.enterpriseId}`
  145. return {
  146. title: query.enterpriseId ? entName.value || '门墩儿 专注顶尖招聘' : jobFairTitle.value,
  147. path
  148. }
  149. })
  150. })
  151. // 招聘会详情
  152. const tabIndex = ref(-1)
  153. const tabList = ref([])
  154. const swiperAdList = ref([])
  155. const backgroundColor = ref('#fff')
  156. const jobFairTitle = ref('')
  157. const textColor = computed(() => {
  158. return backgroundColor.value === '#fff' ? '#777' : '#fff'
  159. })
  160. const entNameColor = computed(() => {
  161. return backgroundColor.value === '#fff' ? '#00B760' : '#fff'
  162. })
  163. const getJobFairDetail = async () => {
  164. if (!query.jobFairId) return
  165. const { data } = await getJobFair(query.jobFairId)
  166. // 类型 -1为不传tag参数
  167. tabList.value = data?.tag || []
  168. handClickTab(tabList.value?.length ? 0 : -1)
  169. // 轮播图
  170. if (data?.headImg?.length) {
  171. swiperAdList.value = data.headImg
  172. }
  173. // 背景色
  174. if (data?.backgroundColour) {
  175. backgroundColor.value = data.backgroundColour || '#fff'
  176. }
  177. if (data?.title) {
  178. jobFairTitle.value = data.title
  179. }
  180. showShareBtn.value = Boolean(data?.shareImg)
  181. }
  182. const getShareImg = async () => {
  183. if (!query.jobFairId) return
  184. const { data } = await getJobFair(query.jobFairId)
  185. showShareBtn.value = Boolean(data?.contentImg)
  186. backgroundColor.value = data.backgroundColour || '#fff'
  187. }
  188. const getEnterpriseInfo = async () => {
  189. if (!query.enterpriseId) return
  190. const { data } = await getEnterpriseDetails(query.enterpriseId)
  191. entName.value = formatName(data?.enterprise?.anotherName || data?.enterprise?.name)
  192. }
  193. // 切换类型
  194. const handClickTab = (index) => {
  195. tabIndex.value = index
  196. query.pageNo = 1
  197. listData.value = []
  198. getEntPositionList()
  199. }
  200. const onSearch = () => {
  201. query.pageNo = 1
  202. listData.value = []
  203. getEntPositionList()
  204. }
  205. const getEntPositionList = async () => {
  206. if (!query.jobFairId) {
  207. uni.showToast({ title: '获取企业岗位失败,请重试!', icon: 'none', duration: 2000 })
  208. return
  209. }
  210. try {
  211. const params = { ...query }
  212. // tab对应的职位类型id列表
  213. const idList = tabIndex.value !== -1 ? tabList.value[tabIndex.value]?.content : []
  214. idList?.length && idList.forEach((value, index) => { params[`positionId[${index}]`] = value.value })
  215. //
  216. const res = await getJobFairEntJobPage(params)
  217. const list = res?.data?.list || []
  218. list.forEach(e => {
  219. e.job = dealDictObjData({}, e)
  220. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  221. })
  222. listData.value = listData.value.concat(list)
  223. loading.value = false
  224. if (listData.value?.length === +res?.data?.total) {
  225. more.value = 'noMore'
  226. return
  227. }
  228. } catch (error) {
  229. query.pageNo--
  230. more.value = 'more'
  231. }
  232. }
  233. const scrollTop = ref(0)
  234. const old = ref({
  235. scrollTop: 0
  236. })
  237. const onScroll = (e) =>{
  238. old.value.scrollTop = e.detail.scrollTop
  239. }
  240. // 加载更多
  241. const loadingMore = () => {
  242. more.value = 'loading'
  243. query.pageNo++
  244. getEntPositionList()
  245. }
  246. const entClick = (info) => {
  247. // 点击企业信息跳转企业职位列表(招聘会内)。如果已经在了则不跳转
  248. if (info?.enterpriseId && !query.enterpriseId) {
  249. const url = `/pagesB/jobFair/positionClassification?jobFairId=${query.jobFairId }&enterpriseId=${info.enterpriseId}&entName=${info.anotherName}`
  250. uni.navigateTo({ url })
  251. }
  252. }
  253. const handleShare = () => {
  254. // 分享招聘会
  255. let url = `/pagesB/jobFair/${query.enterpriseId ? 'jobFairEntShare' : 'jobFairShare'}?jobFairId=${query.jobFairId}`
  256. // 分享招聘会企业
  257. if (query.enterpriseId) url = url + `&enterpriseId=${query.enterpriseId}`
  258. uni.navigateTo({ url })
  259. }
  260. </script>
  261. <style scoped lang="scss">
  262. .stick {
  263. z-index: 1;
  264. position: sticky;
  265. top: 0;
  266. }
  267. .shareButtonBox {
  268. z-index: 1;
  269. position: absolute;
  270. right: 20px;
  271. top: 16px;
  272. border-radius: 8px;
  273. padding: 7px 9px;
  274. background-color: #fff;
  275. }
  276. .box {
  277. height: 100vh;
  278. overflow: hidden;
  279. // padding-bottom: 120rpx;
  280. box-sizing: border-box;
  281. display: flex;
  282. flex-direction: column;
  283. }
  284. .listDataBox {
  285. // padding: 1px 0 120rpx;
  286. padding-bottom: 120rpx;
  287. margin: 0 5rpx;
  288. }
  289. .scrollBox{
  290. flex: 1;
  291. height: 0 !important;
  292. padding-bottom: 24rpx;
  293. box-sizing: border-box;
  294. }
  295. // :deep(.uni-load-more__text) {
  296. // color: #fff !important;
  297. // }
  298. :deep(.uni-card) {
  299. padding: 0 !important;
  300. .uni-card__content {
  301. padding: 0 !important;
  302. }
  303. }
  304. .scroll-container {
  305. width: calc(100vw - 20px);
  306. padding: 0 20rpx;
  307. white-space: nowrap; /* 确保子元素在一行内排列 */
  308. .scroll-item {
  309. display: inline-block; /* 子元素内联块显示 */
  310. color: #fff;
  311. font-size: 17px;
  312. font-weight: 500;
  313. .text {
  314. padding: 20px 2px 0;
  315. }
  316. .choose {
  317. width: 28px;
  318. height: 2px;
  319. border-radius: 8px;
  320. margin: 8px auto;
  321. }
  322. }
  323. }
  324. .enterpriseName {
  325. color: #fff;
  326. font-size: 18px;
  327. font-weight: bold;
  328. line-height: 28px;
  329. padding: 20px 80px 20px 30px;
  330. position: relative;
  331. &::before {
  332. display: block;
  333. content: '';
  334. width: 6px;
  335. height: 30px;
  336. background-color: #fff;
  337. position: absolute;
  338. top: 20px;
  339. left: 12px;
  340. border-radius: 2px;
  341. }
  342. }
  343. :deep(.uni-searchbar) {
  344. // background-color: #fff !important;
  345. padding: 0;
  346. margin: 0 10px;
  347. border-radius: 5px;
  348. }
  349. :deep(.uni-searchbar__box) {
  350. width: calc(100% - 100px);
  351. height: 40px !important;
  352. // border: 1px solid #00B760;
  353. padding-right: 20px;
  354. flex: none;
  355. background-color: #fff;
  356. }
  357. .search-btn {
  358. position: absolute;
  359. right: 13px;
  360. top: 3px;
  361. width: 106px;
  362. height: 34px;
  363. line-height: 34px;
  364. font-size: 16px;
  365. // margin: 4px 4px 4px 0;
  366. background-color: #00B760;
  367. color: #fff;
  368. border-radius: 5px;
  369. z-index: 9;
  370. }
  371. </style>