positionClassification.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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>
  6. <!-- 轮播图 -->
  7. <SwiperAd v-if="swiperAdList.length" :list="swiperAdList" margin="0" borderRadius="0" @click="handleToDetails"></SwiperAd>
  8. <view class="stick" :style="`background-color: ${backgroundColor}`">
  9. <!-- tab页签 -->
  10. <scroll-view v-if="tabList?.length" scroll-x="true" class="scroll-container">
  11. <view
  12. class="scroll-item"
  13. :style="`margin-left: ${index ? '24px' : ''};`"
  14. v-for="(val, index) in tabList" :key="index+val"
  15. @tap="handClickTab(index)"
  16. >
  17. <view>
  18. <view class="text">{{ val.title }}</view>
  19. <view v-if="index === tabIndex" class="choose" style="background-color: #fff;"></view>
  20. <view v-else class="choose" style="background-color: #ffffff00;"></view>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. <view v-if="entName" class="enterpriseName" :style="`color: ${entNameColor}`">{{ entName }}</view>
  25. </view>
  26. <view v-if="listData?.length" class="listDataBox">
  27. <PositionList
  28. :list="listData"
  29. :noMore="false"
  30. :jobFairId="query.jobFairId"
  31. :showUpdateTime="false"
  32. :noDataTextColor="textColor"
  33. ></PositionList>
  34. <uni-load-more :status="more" :color="textColor" />
  35. </view>
  36. <view v-else class="nodata-img-parent">
  37. <!-- <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image> -->
  38. <uni-load-more class="ss-m-t-50" :color="textColor" status="noMore" :content-text="{'contentnomore': '暂无数据,请切换类型查看~'}" />
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. </template>
  44. <script setup>
  45. import { onLoad } from '@dcloudio/uni-app'
  46. import { ref, reactive, computed } from 'vue'
  47. import { dealDictObjData } from '@/utils/position'
  48. import { getJobFairEntJobPage, getJobFair } from '@/api/jobFair'
  49. import PositionList from '@/components/PositionList'
  50. import SwiperAd from '@/components/SwiperAd'
  51. const more = ref('more')
  52. const listData = ref([])
  53. const query = reactive({
  54. pageSize: 20,
  55. pageNo: 1,
  56. jobFairId: undefined,
  57. })
  58. const entName = ref('')
  59. onLoad(async (options) => {
  60. entName.value = options.entName
  61. if (options?.jobFairId) {
  62. query.jobFairId = options.jobFairId
  63. if (options.enterpriseId) query.enterpriseId = options.enterpriseId
  64. if (query.enterpriseId) getData()
  65. else getJobFairDetail()
  66. }
  67. if (options.backgroundColor) backgroundColor.value = options.backgroundColor
  68. })
  69. // 招聘会详情
  70. const tabIndex = ref(-1)
  71. const tabList = ref([])
  72. const swiperAdList = ref([])
  73. const backgroundColor = ref('#fff')
  74. const textColor = computed(() => {
  75. return backgroundColor.value === '#fff' ? '#777' : '#fff'
  76. })
  77. const entNameColor = computed(() => {
  78. return backgroundColor.value === '#fff' ? '#00897B' : '#fff'
  79. })
  80. const getJobFairDetail = async () => {
  81. if (!query.jobFairId) return
  82. const { data } = await getJobFair(query.jobFairId)
  83. // tab
  84. if (data?.tag?.length) {
  85. tabList.value = data.tag
  86. tabIndex.value = 0
  87. }
  88. // 轮播图
  89. if (data?.headImg?.length) {
  90. swiperAdList.value = data.headImg
  91. }
  92. // 背景色
  93. if (data?.backgroundColour) {
  94. backgroundColor.value = data.backgroundColour || '#fff'
  95. }
  96. getData()
  97. }
  98. // 切换类型
  99. const handClickTab = (index) => {
  100. tabIndex.value = index
  101. query.pageNo = 1
  102. listData.value = []
  103. getData()
  104. }
  105. const getData = async () => {
  106. if (!query.jobFairId) {
  107. uni.showToast({ title: '获取企业岗位失败,请重试!', icon: 'none', duration: 2000 })
  108. return
  109. }
  110. try {
  111. const params = { ...query }
  112. const positionIdValue = tabIndex.value !== -1 ? tabList.value[tabIndex.value]?.value : []
  113. positionIdValue?.length && positionIdValue.forEach((value, index) => {
  114. params[`positionId[${index}]`] = value
  115. })
  116. const res = await getJobFairEntJobPage(params)
  117. const list = res?.data?.list || []
  118. list.forEach(e => {
  119. e.job = dealDictObjData({}, e)
  120. e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
  121. })
  122. listData.value = listData.value.concat(list)
  123. if (listData.value?.length === +res?.data?.total) {
  124. more.value = 'noMore'
  125. return
  126. }
  127. } catch (error) {
  128. query.pageNo--
  129. more.value = 'more'
  130. }
  131. }
  132. const scrollTop = ref(0)
  133. const old = ref({
  134. scrollTop: 0
  135. })
  136. const onScroll = (e) =>{
  137. old.value.scrollTop = e.detail.scrollTop
  138. }
  139. // 加载更多
  140. const loadingMore = () => {
  141. more.value = 'loading'
  142. query.pageNo++
  143. getData()
  144. }
  145. // const goBack = () => {
  146. // uni.navigateTo({
  147. // url: '/pagesB/jobFair/index'
  148. // })
  149. // }
  150. </script>
  151. <style scoped lang="scss">
  152. .stick {
  153. z-index: 1;
  154. position: sticky;
  155. top: 0;
  156. }
  157. .box {
  158. height: 100vh;
  159. overflow: hidden;
  160. // padding-bottom: 120rpx;
  161. box-sizing: border-box;
  162. display: flex;
  163. flex-direction: column;
  164. }
  165. .listDataBox {
  166. // padding: 1px 0 120rpx;
  167. padding-bottom: 120rpx;
  168. margin: 0 5rpx;
  169. }
  170. .scrollBox{
  171. flex: 1;
  172. height: 0 !important;
  173. padding-bottom: 24rpx;
  174. box-sizing: border-box;
  175. }
  176. // :deep(.uni-load-more__text) {
  177. // color: #fff !important;
  178. // }
  179. :deep(.uni-card) {
  180. padding: 0 !important;
  181. .uni-card__content {
  182. padding: 0 !important;
  183. }
  184. }
  185. .scroll-container {
  186. width: calc(100vw - 20px);
  187. padding: 0 20rpx;
  188. white-space: nowrap; /* 确保子元素在一行内排列 */
  189. .scroll-item {
  190. display: inline-block; /* 子元素内联块显示 */
  191. color: #fff;
  192. font-size: 17px;
  193. font-weight: 500;
  194. .text {
  195. padding: 20px 2px 0;
  196. }
  197. .choose {
  198. width: 28px;
  199. height: 2px;
  200. border-radius: 8px;
  201. margin: 8px auto;
  202. }
  203. }
  204. }
  205. .enterpriseName {
  206. position: relative;
  207. padding: 18px 30rpx;
  208. padding-left: 39px;
  209. height: 24px;
  210. line-height: 24px;
  211. color: #fff;
  212. font-size: 18px;
  213. font-weight: bold;
  214. &::before {
  215. display: block;
  216. content: '';
  217. width: 4px;
  218. height: 24px;
  219. background-color: #fff;
  220. position: absolute;
  221. top: 20px;
  222. left: 25px;
  223. border-radius: 2px;
  224. }
  225. }
  226. </style>