positionClassification.vue 10.0 KB

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