123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <template>
- <layout-page>
- <view style="padding-bottom: 30px; ">
- <view v-if="items.length">
- <uni-card v-for="val in items" :key="val.id" @tap="handleToJobFairEnterprises(val)">
- <image v-if="val?.previewImg" class="ss-m-t-10" :src="val.previewImg" mode="widthFix" style="width: 100%; height: auto; border-radius: 6px;"></image>
- <view class="ss-m-t-20">活动时间:{{ timesTampChange(val.startTime, 'Y-M-D') }}至{{ timesTampChange(val.endTime, 'Y-M-D') }}</view>
- <button class="ss-m-t-20 ss-m-b-10" style="background-color: #00B760; color: #fff;" type="primary">立即加入</button>
- </uni-card>
- </view>
- <view v-else class="nodata-img-parent">
- <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
- </view>
- </view>
- </layout-page>
- </template>
- <script setup>
- import layoutPage from '@/layout'
- import { ref, watch } from 'vue'
- import { onShow } from '@dcloudio/uni-app'
- import { getAccessToken } from '@/utils/request'
- import { showAuthModal } from '@/hooks/useModal'
- import { getJobFairList, checkJobFairPermission } from '@/api/jobFair'
- import { timesTampChange } from '@/utils/date'
- import { userStore } from '@/store/user'
- const useUserStore = userStore()
- const items = ref([])
- // 获得招聘会列表
- const getList = async () => {
- const res = await getJobFairList()
- items.value = res?.data || []
- }
- watch(() => useUserStore.refreshToken, () => {
- if (!useUserStore.refreshToken) return items.value = []
- getList()
- })
- onShow(() => {
- // 设置自定义tabbar选中值
- const currentPage = getCurrentPages()[0] // 获取当前页面实例
- const currentTabBar = currentPage?.getTabBar?.()
- // 设置当前tab页的下标index
- currentTabBar?.setData({ selected: 3 })
- if (!getAccessToken()) return showAuthModal()
- getList()
- })
- //跳转招聘会详情
- const handleToJobFairEnterprises = async (val) => {
- if (!val?.id) {
- uni.showToast({ title: '资源获取失败,请稍后重试', icon: 'none' })
- }
- try {
- const { data } = await checkJobFairPermission(val.id)
- if (data) {
- uni.navigateTo({
- url: '/pagesB/jobFair/details?id=' + val.id
- })
- }
- } catch (error) {
- // 权限被禁用
- if (error?.code === 1100056008) {
- uni.showToast({ title: error.msg, icon: 'none', duration: 2000 })
- return
- }
- // 没有权限参加招聘会,购买门票
- if (error?.code === 1100056005) {
- // 没有设置门票金额则提示无权限参加
- if (!val?.admissionPrice || val?.admissionPrice <= 0) {
- uni.showToast({ title: error.msg, icon: 'none', duration: 2000 })
- return
- }
- // 设置门票金额则提示购买门票
- uni.showToast({ title: '您暂时无法参加该招聘会,请先购买门票', icon: 'none', duration: 2000 })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- </style>
|