jobFair.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 (more.value === 'noMore') return
  78. more.value = 'loading'
  79. query.value.pageNo++
  80. getList()
  81. }
  82. function checkActivityTime(startTimeStamp, endTimeStamp) {
  83. // 获取当前时间
  84. const now = new Date()
  85. const currentTime = now.getTime()
  86. // 处理开始时间:设置为当天的 00:00:00
  87. const startDate = new Date(startTimeStamp)
  88. const startOfDay = new Date(
  89. startDate.getFullYear(),
  90. startDate.getMonth(),
  91. startDate.getDate(),
  92. 0, 0, 0, 0
  93. )
  94. const adjustedStartTime = startOfDay.getTime()
  95. // 处理结束时间:设置为当天的 23:59:59
  96. const endDate = new Date(endTimeStamp)
  97. const endOfDay = new Date(
  98. endDate.getFullYear(),
  99. endDate.getMonth(),
  100. endDate.getDate(),
  101. 23, 59, 59, 999
  102. )
  103. const adjustedEndTime = endOfDay.getTime()
  104. // 判断时间关系
  105. if (currentTime < adjustedStartTime) {
  106. return {
  107. canJoin: false,
  108. desc: '待开始',
  109. message: '该招聘会尚未开始,无法查看详情',
  110. color: 'warning'
  111. }
  112. } else if (currentTime > adjustedEndTime) {
  113. return {
  114. canJoin: false,
  115. desc: '已结束',
  116. message: '该招聘会已结束,无法查看详情',
  117. color: 'error'
  118. }
  119. } else {
  120. return {
  121. canJoin: true,
  122. color: 'primary',
  123. desc: '进行中'
  124. }
  125. }
  126. }
  127. //招聘会
  128. const handleToJobFairEnterprises = (val) => {
  129. if (!val?.id) {
  130. uni.showToast({ title: '暂无详情!', icon: 'none' })
  131. }
  132. const obj = checkActivityTime(val.startTime, val.endTime)
  133. // 不可参加的,弹出提示语
  134. if (!obj.canJoin) return uni.showToast({ title: obj.message, icon: 'none', duration: 2000 })
  135. let url = `/pagesB/jobFair/${Number(val?.category) ? 'positionClassification': 'enterprisesClassification'}?jobFairId=${val.id}`
  136. uni.navigateTo({url})
  137. }
  138. const getShareParams = () => {
  139. return {
  140. title: '门墩儿-招聘会',
  141. path: '/pages/index/jobFair',
  142. }
  143. }
  144. // 设置自定义tabbar选中值
  145. onShow(() => {
  146. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  147. const currentTabBar = currentPage?.getTabBar?.();
  148. // 设置当前tab页的下标index
  149. currentTabBar?.setData({ selected: 3 });
  150. getList()
  151. })
  152. // 转发朋友
  153. onShareAppMessage(() => {
  154. return getShareParams()
  155. })
  156. // 转发朋圈
  157. onShareTimeline(() => {
  158. return getShareParams()
  159. })
  160. </script>
  161. <style lang="scss" scoped>
  162. .scrollBox {
  163. height: 100vh;
  164. box-sizing: border-box;
  165. }
  166. .list-item {
  167. margin: 0 30rpx 30rpx 30rpx;
  168. border-radius: 20rpx;
  169. padding: 30rpx;
  170. position: relative;
  171. box-shadow: 1px 2px 12px rgba(0, 0, 0, 0.17);
  172. view {
  173. font-size: 28rpx;
  174. color: #666;
  175. }
  176. }
  177. </style>