jobFair.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <layout-page>
  3. <view style="padding-bottom: 30px; ">
  4. <view v-if="items.length">
  5. <uni-card v-for="val in items" :key="val.id" @tap="handleToJobFairEnterprises(val)">
  6. <image v-if="val?.previewImg" class="ss-m-t-10" :src="val.previewImg" mode="widthFix" style="width: 100%; height: auto; border-radius: 6px;"></image>
  7. <view class="ss-m-t-20">活动时间:{{ timesTampChange(val.startTime, 'Y-M-D') }}至{{ timesTampChange(val.endTime, 'Y-M-D') }}</view>
  8. <button class="ss-m-t-20 ss-m-b-10" style="background-color: #00B760; color: #fff;" type="primary">立即加入</button>
  9. </uni-card>
  10. </view>
  11. <view v-else class="nodata-img-parent">
  12. <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
  13. </view>
  14. </view>
  15. </layout-page>
  16. </template>
  17. <script setup>
  18. import layoutPage from '@/layout'
  19. import { ref, watch } from 'vue'
  20. import { onShow } from '@dcloudio/uni-app'
  21. import { getAccessToken } from '@/utils/request'
  22. import { showAuthModal } from '@/hooks/useModal'
  23. import { getJobFairList, checkJobFairPermission } from '@/api/jobFair'
  24. import { timesTampChange } from '@/utils/date'
  25. import { userStore } from '@/store/user'
  26. const useUserStore = userStore()
  27. const items = ref([])
  28. // 获得招聘会列表
  29. const getList = async () => {
  30. const res = await getJobFairList()
  31. items.value = res?.data || []
  32. }
  33. watch(() => useUserStore.refreshToken, () => {
  34. if (!useUserStore.refreshToken) return items.value = []
  35. getList()
  36. })
  37. onShow(() => {
  38. // 设置自定义tabbar选中值
  39. const currentPage = getCurrentPages()[0] // 获取当前页面实例
  40. const currentTabBar = currentPage?.getTabBar?.()
  41. // 设置当前tab页的下标index
  42. currentTabBar?.setData({ selected: 3 })
  43. if (!getAccessToken()) return showAuthModal()
  44. getList()
  45. })
  46. //跳转招聘会详情
  47. const handleToJobFairEnterprises = async (val) => {
  48. if (!val?.id) {
  49. uni.showToast({ title: '资源获取失败,请稍后重试', icon: 'none' })
  50. }
  51. try {
  52. const { data } = await checkJobFairPermission(val.id)
  53. if (data) {
  54. uni.navigateTo({
  55. url: '/pagesB/jobFair/details?id=' + val.id
  56. })
  57. }
  58. } catch (error) {
  59. // 权限被禁用
  60. if (error?.code === 1100056008) {
  61. uni.showToast({ title: error.msg, icon: 'none', duration: 2000 })
  62. return
  63. }
  64. // 没有权限参加招聘会,购买门票
  65. if (error?.code === 1100056005) {
  66. // 没有设置门票金额则提示无权限参加
  67. if (!val?.admissionPrice || val?.admissionPrice <= 0) {
  68. uni.showToast({ title: error.msg, icon: 'none', duration: 2000 })
  69. return
  70. }
  71. // 设置门票金额则提示购买门票
  72. uni.showToast({ title: '您暂时无法参加该招聘会,请先购买门票', icon: 'none', duration: 2000 })
  73. }
  74. }
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. </style>