positionClassification.vue 9.2 KB

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