positionClassification.vue 9.1 KB

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