positionClassification.vue 10 KB

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