jobFair.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <payPopup ref="payRef" :amount="FenYuanTransform(itemData?.admissionPrice || 0)" @paySuccess="paySuccess"></payPopup>
  16. </layout-page>
  17. </template>
  18. <script setup>
  19. import layoutPage from '@/layout'
  20. import { ref, watch } from 'vue'
  21. import { onShow } from '@dcloudio/uni-app'
  22. import { getAccessToken } from '@/utils/request'
  23. import { showAuthModal } from '@/hooks/useModal'
  24. import { getJobFairList, checkJobFairPermission } from '@/api/jobFair'
  25. import { timesTampChange } from '@/utils/date'
  26. import { userStore } from '@/store/user'
  27. import payPopup from '@/components/payPopup'
  28. import { FenYuanTransform } from '@/utils'
  29. const useUserStore = userStore()
  30. const items = ref([])
  31. // 获得招聘会列表
  32. const getList = async () => {
  33. const res = await getJobFairList()
  34. items.value = res?.data || []
  35. }
  36. watch(() => useUserStore.refreshToken, () => {
  37. if (!useUserStore.refreshToken) return items.value = []
  38. getList()
  39. })
  40. onShow(() => {
  41. // 设置自定义tabbar选中值
  42. const currentPage = getCurrentPages()[0] // 获取当前页面实例
  43. const currentTabBar = currentPage?.getTabBar?.()
  44. // 设置当前tab页的下标index
  45. currentTabBar?.setData({ selected: 3 })
  46. if (!getAccessToken()) return showAuthModal()
  47. getList()
  48. })
  49. //跳转招聘会详情
  50. const payRef = ref()
  51. const itemData = ref({})
  52. const handleToJobFairEnterprises = async (val) => {
  53. itemData.value = val
  54. if (!val?.id) {
  55. uni.showToast({ title: '资源获取失败,请稍后重试', icon: 'none' })
  56. }
  57. uni.showLoading({ title: '加载中' })
  58. try {
  59. const { data } = await checkJobFairPermission(val.id)
  60. uni.hideLoading()
  61. if (data) {
  62. uni.navigateTo({
  63. url: '/pagesB/jobFair/details?id=' + val.id
  64. })
  65. }
  66. } catch (error) {
  67. uni.hideLoading()
  68. // 权限被禁用
  69. if (error?.code === 1100056008) {
  70. uni.showToast({ title: error.msg, icon: 'none', duration: 2000 })
  71. return
  72. }
  73. // 没有权限参加招聘会,购买门票
  74. if (error?.code === 1100056005) {
  75. // 没有设置门票金额则提示无权限参加
  76. if (!val?.admissionPrice || val?.admissionPrice <= 0) {
  77. uni.showToast({ title: error.msg, icon: 'none', duration: 2000 })
  78. return
  79. }
  80. // 设置门票金额则提示购买门票
  81. uni.showToast({ title: '您暂时无法参加该招聘会,请先购买门票', icon: 'none', duration: 2000 })
  82. payRef.value && payRef.value.handleOpen({ spuId: val?.id || '', spuName: val?.title || '', price: val.admissionPrice, type: 5 })
  83. }
  84. }
  85. }
  86. // 支付成功
  87. const paySuccess = () => {
  88. handleToJobFairEnterprises(itemData.value)
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. </style>