positionClassification.vue 12 KB

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