positionClassification.vue 9.3 KB

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