positionClassification.vue 10 KB

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