enterprisesClassification.vue 10 KB

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