jobFair.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!-- 招聘会 -->
  2. <template>
  3. <view>
  4. <Navbar title="招聘会" />
  5. <view class="box defaultBgc" :style="{'padding-top': navbarHeight + 'px', 'min-height': `calc(100vh - ${(navbarHeight + 100)}px)`}" style="padding-bottom: 100px;">
  6. <view v-if="items.length">
  7. <view class="commonBackground"></view>
  8. <scroll-view class="scrollBox" :scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  9. <view v-for="val in items" :key="val.id" @tap="handleToJobFairEnterprises(val)" class="list-item defaultBgc default-border">
  10. <image v-if="val?.previewImg" class="ss-m-t-10" :src="val.previewImg" mode="widthFix" style="width: 100%; height: auto; border-radius: 6px;"></image>
  11. <view class="ss-m-t-20 MiSans-Normal">活动主题:{{ val.title }}</view>
  12. <view class="ss-m-t-20 MiSans-Normal">
  13. 活动状态:
  14. <text class="font-weight-bold" :class="[`color-${checkActivityTime(val.startTime, val.endTime)?.color}`]">
  15. {{ checkActivityTime(val.startTime, val.endTime)?.desc }}
  16. </text>
  17. </view>
  18. <view class="ss-m-t-20 MiSans-Normal">活动时间:{{ timesTampChange(val.startTime, 'Y-M-D') }}至{{ timesTampChange(val.endTime, 'Y-M-D') }}</view>
  19. <button class="ss-m-t-20 ss-m-b-10 MiSans-Medium" style="background-color: #00B760; color: #fff;" type="primary">查看详情</button>
  20. </view>
  21. <uni-load-more :status="more" />
  22. </scroll-view>
  23. </view>
  24. <view v-else>
  25. <view class="commonBackground"></view>
  26. <view class="nodata-img-parent" :style="{'height': `calc(100vh - ${(navbarHeight + 100)}px)`}">
  27. <image src="https://minio.menduner.com/dev/bb43df1dc91945e05ee93da76e49b34f87b0d10203eb76c20e2d4999a13b9a0a.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script setup>
  34. import { onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  35. import { ref } from 'vue'
  36. import { getJobFairList } from '@/api/jobFair'
  37. import { timesTampChange } from '@/utils/date'
  38. import Navbar from '@/components/Navbar'
  39. const navbarHeight = ref(uni.getStorageSync('navbarHeight'))
  40. const items = ref([])
  41. const total = ref(0)
  42. const query = ref({
  43. pageNo: 1,
  44. pageSize: 10,
  45. status: '0'
  46. })
  47. const more = ref('more')
  48. // 获得招聘会列表
  49. const getList = async () => {
  50. if (query.value.pageNo < 1) return
  51. if (query.value.pageNo === 1) items.value = []
  52. try {
  53. more.value = 'loading'
  54. uni.showLoading({ title: '加载中...' })
  55. const res = await getJobFairList(query.value)
  56. const list = res?.data?.list || []
  57. if (!list?.length) {
  58. more.value = 'noMore'
  59. return
  60. }
  61. items.value = items.value.concat(...list)
  62. total.value = res.data.total
  63. more.value = 'more'
  64. if (items.value.length === +total.value) {
  65. more.value = 'noMore'
  66. return
  67. }
  68. } catch (error) {
  69. query.value.pageNo--
  70. more.value = 'more'
  71. } finally {
  72. uni.hideLoading()
  73. }
  74. }
  75. // 加载更多
  76. const loadingMore = () => {
  77. if (total.value <= 0) return
  78. if (more.value === 'noMore') return
  79. more.value = 'loading'
  80. query.value.pageNo++
  81. getList()
  82. }
  83. function checkActivityTime(startTimeStamp, endTimeStamp) {
  84. // 获取当前时间
  85. const now = new Date()
  86. const currentTime = now.getTime()
  87. // 处理开始时间:设置为当天的 00:00:00
  88. const startDate = new Date(startTimeStamp)
  89. const startOfDay = new Date(
  90. startDate.getFullYear(),
  91. startDate.getMonth(),
  92. startDate.getDate(),
  93. 0, 0, 0, 0
  94. )
  95. const adjustedStartTime = startOfDay.getTime()
  96. // 处理结束时间:设置为当天的 23:59:59
  97. const endDate = new Date(endTimeStamp)
  98. const endOfDay = new Date(
  99. endDate.getFullYear(),
  100. endDate.getMonth(),
  101. endDate.getDate(),
  102. 23, 59, 59, 999
  103. )
  104. const adjustedEndTime = endOfDay.getTime()
  105. // 判断时间关系
  106. if (currentTime < adjustedStartTime) {
  107. return {
  108. canJoin: false,
  109. desc: '待开始',
  110. message: '该招聘会尚未开始,无法查看详情',
  111. color: 'warning'
  112. }
  113. } else if (currentTime > adjustedEndTime) {
  114. return {
  115. canJoin: false,
  116. desc: '已结束',
  117. message: '该招聘会已结束,无法查看详情',
  118. color: 'error'
  119. }
  120. } else {
  121. return {
  122. canJoin: true,
  123. color: 'primary',
  124. desc: '进行中'
  125. }
  126. }
  127. }
  128. //招聘会
  129. const handleToJobFairEnterprises = (val) => {
  130. if (!val?.id) {
  131. uni.showToast({ title: '暂无详情!', icon: 'none' })
  132. }
  133. const obj = checkActivityTime(val.startTime, val.endTime)
  134. // 不可参加的,弹出提示语
  135. if (!obj.canJoin) return uni.showToast({ title: obj.message, icon: 'none', duration: 2000 })
  136. let url = `/pagesB/jobFair/${Number(val?.category) ? 'positionClassification': 'enterprisesClassification'}?jobFairId=${val.id}`
  137. uni.navigateTo({url})
  138. }
  139. const getShareParams = () => {
  140. return {
  141. title: '门墩儿-招聘会',
  142. path: '/pages/index/jobFair',
  143. }
  144. }
  145. // 设置自定义tabbar选中值
  146. onShow(() => {
  147. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  148. const currentTabBar = currentPage?.getTabBar?.();
  149. // 设置当前tab页的下标index
  150. currentTabBar?.setData({ selected: 3 });
  151. getList()
  152. })
  153. // 转发朋友
  154. onShareAppMessage(() => {
  155. return getShareParams()
  156. })
  157. // 转发朋圈
  158. onShareTimeline(() => {
  159. return getShareParams()
  160. })
  161. </script>
  162. <style lang="scss" scoped>
  163. .scrollBox {
  164. height: 100vh;
  165. box-sizing: border-box;
  166. }
  167. .list-item {
  168. margin: 0 30rpx 30rpx 30rpx;
  169. border-radius: 20rpx;
  170. padding: 30rpx;
  171. position: relative;
  172. box-shadow: 1px 2px 12px rgba(0, 0, 0, 0.17);
  173. view {
  174. font-size: 28rpx;
  175. color: #666;
  176. }
  177. }
  178. </style>