This commit is contained in:
FengHui
2026-04-22 20:53:29 +08:00
parent 56437a88ea
commit 708f135ec3
3 changed files with 101 additions and 90 deletions

View File

@@ -304,8 +304,14 @@
:value="list"
>
<view v-for="(job, index) in list" :key="index" :slot="`slot${index}`">
<view class="item btn-feel" v-if="!job.recommend">
<view class="falls-card" :class="{ 'disabled-card': Number(job.jobStatus) === 1 }" @click="nextDetail(job)">
<view class="item" v-if="!job.recommend">
<view
class="falls-card"
:class="{
'disabled-card': Number(job.isPublish) === 0
}"
@click="Number(job.isPublish) === 1 ? nextDetail(job) : null"
>
<view class="falls-card-pay">
<view class="fl_1 falls-card-title">{{ job.jobTitle }}</view>
<view class="fr_1 pay-text">
@@ -357,10 +363,13 @@
<view class="fr-1" v-if="job.regionName">
地区{{ job.regionName }}
</view>
</view>
<!-- 未通过审核状态显示 -->
<view class="unpublished-badge" v-if="Number(job.isPublish) === 0">
未通过审核
</view>
<!-- 招聘者显示上下架开关 -->
<view class="falls-card-actions" v-if="isRecruiter">
<view class="falls-card-actions" v-if="isRecruiter && Number(job.isPublish) === 1">
<view class="job-status-switch" @click.stop="toggleJobStatus(job)">
<view class="switch-track" :class="{ 'active': Number(job.jobStatus) === 0 }">
<view class="switch-thumb" :class="{ 'active': Number(job.jobStatus) === 0 }"></view>
@@ -401,8 +410,14 @@
:value="list"
>
<template v-slot:default="job">
<view class="item btn-feel" v-if="!job.recommend">
<view class="falls-card" :class="{ 'disabled-card': Number(job.jobStatus) === 1 }" @click="nextDetail(job)">
<view class="item" v-if="!job.recommend">
<view
class="falls-card"
:class="{
'disabled-card': (Number(job.jobStatus) === 1 || Number(job.isPublish) === 0) && currentUserType !== 0
}"
@click="Number(job.isPublish) === 1 ? nextDetail(job) : null"
>
<view class="falls-card-pay">
<view class="fl_1 falls-card-title">{{ job.jobTitle }}</view>
<view class="fr_1 pay-text">
@@ -450,10 +465,13 @@
<view class="fr-1" v-if="job.regionName">
地区{{ job.regionName }}
</view>
</view>
<!-- 未通过审核状态显示 -->
<view class="unpublished-badge" v-if="Number(job.isPublish) === 0">
未通过审核
</view>
<!-- 招聘者显示上下架开关 -->
<view class="falls-card-actions" v-if="isRecruiter">
<view class="falls-card-actions" v-if="isRecruiter && Number(job.isPublish) === 1">
<view class="job-status-switch" @click.stop="toggleJobStatus(job)">
<view class="switch-track" :class="{ 'active': Number(job.jobStatus) === 0 }">
<view class="switch-thumb" :class="{ 'active': Number(job.jobStatus) === 0 }"></view>
@@ -578,6 +596,15 @@ const shouldShowCompanyCard = computed(() => {
return companyInfo.name && companyInfo.name.trim() !== '';
});
// 计算当前用户类型
const currentUserType = computed(() => {
// 优先从store获取如果为空则从缓存获取
const storeIsCompanyUser = userInfo.value?.isCompanyUser;
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const cachedIsCompanyUser = cachedUserInfo.isCompanyUser;
return storeIsCompanyUser !== undefined ? Number(storeIsCompanyUser) : Number(cachedIsCompanyUser);
});
// 计算是否显示企业用户内容
const shouldShowCompanyContent = computed(() => {
// 未登录时不显示企业内容
@@ -1065,7 +1092,7 @@ function clearfindJob(job) {
}
function nextDetail(job) {
navTo(`/packageA/pages/post/post?jobId=${encodeURIComponent(job.jobId)}`);
navTo(`/packageA/pages/post/post?encryptJobId=${encodeURIComponent(job.encryptJobId)}`);
}
function navToService(serviceType) {
@@ -1216,7 +1243,6 @@ function getJobRecommend(type = 'add') {
sessionId: useUserStore().seesionId,
...pageState.search,
...conditionSearch.value,
isPublish: 1,
};
// 当选中零工市场(4)或疆外(3)时order参数传递0
if (pageState.search.order === 3 || pageState.search.order === 4) {
@@ -1231,9 +1257,11 @@ function getJobRecommend(type = 'add') {
// 只有企业用户(isCompanyUser=0)才添加current字段
if (userType === 0) {
params.current = pageNull.value;
// 企业用户不传递isPublish字段
} else {
// 求职者只显示已上架的岗位jobStatus=0
// 求职者只显示已上架且通过审核的岗位jobStatus=0, isPublish=1
params.jobStatus = 0;
params.isPublish = 1;
}
let comd = { recommend: true, jobCategory: '', tip: '确认你的兴趣,为您推荐更多合适的岗位' };
$api.createRequest('/app/job/recommend', params).then((resData) => {
@@ -1315,9 +1343,10 @@ function getJobList(type = 'add') {
const cachedIsCompanyUser = cachedUserInfo.isCompanyUser;
const userType = storeIsCompanyUser !== undefined ? Number(storeIsCompanyUser) : Number(cachedIsCompanyUser);
// 如果不是企业用户(求职者),只显示已上架的岗位
// 如果不是企业用户(求职者),只显示已上架且通过审核的岗位
if (userType !== 0) {
params.jobStatus = 0;
params.isPublish = 1;
}
$api.createRequest('/app/job/list', params).then((resData) => {
@@ -1344,7 +1373,7 @@ function getJobList(type = 'add') {
}
// 上架岗位
const jobUp = (jobId) => {
const jobUp = (encryptJobId) => {
if (!checkLogin()) return;
uni.showLoading({
@@ -1352,7 +1381,7 @@ const jobUp = (jobId) => {
mask: true
});
$api.createRequest(`/app/job/jobUp/${jobId}`, {}, 'PUT', true).then((res) => {
$api.createRequest(`/app/job/jobUp/${encryptJobId}`, {}, 'PUT', true).then((res) => {
uni.hideLoading();
$api.msg('上架成功');
// 刷新数据
@@ -1369,7 +1398,7 @@ const jobUp = (jobId) => {
};
// 下架岗位
const jobDown = (jobId) => {
const jobDown = (encryptJobId) => {
if (!checkLogin()) return;
uni.showLoading({
@@ -1377,7 +1406,7 @@ const jobDown = (jobId) => {
mask: true
});
$api.createRequest(`/app/job/jobDown/${jobId}`, {}, 'PUT', true).then((res) => {
$api.createRequest(`/app/job/jobDown/${encryptJobId}`, {}, 'PUT', true).then((res) => {
uni.hideLoading();
$api.msg('下架成功');
// 刷新数据
@@ -1404,14 +1433,14 @@ const toggleJobStatus = (job) => {
// 根据当前状态决定调用哪个接口
const isCurrentlyUp = Number(job.jobStatus) === 0; // 0: 已上架, 1: 已下架
const apiUrl = isCurrentlyUp ? `/app/job/jobDown/${job.jobId}` : `/app/job/jobUp/${job.jobId}`;
const apiUrl = isCurrentlyUp ? `/app/job/jobDown/${job.encryptJobId}` : `/app/job/jobUp/${job.encryptJobId}`;
$api.createRequest(apiUrl, {}, 'PUT', true).then((res) => {
uni.hideLoading();
$api.msg(isCurrentlyUp ? '下架成功' : '上架成功');
// 更新本地数据状态,避免立即刷新整个列表
const jobIndex = list.value.findIndex(item => item.jobId === job.jobId);
const jobIndex = list.value.findIndex(item => item.encryptJobId === job.encryptJobId);
if (jobIndex !== -1) {
// 更新状态
list.value[jobIndex].jobStatus = isCurrentlyUp ? 1 : 0;
@@ -2133,6 +2162,17 @@ defineExpose({ loadData });
margin: 4rpx 4rpx 0 0
height: 26rpx
width: 26rpx
// 未通过审核状态样式
.unpublished-badge
position: absolute
top: 0
right: 0
background-color: #FF4D4F
color: #FFFFFF
font-size: 20rpx
padding: 6rpx 12rpx
border-bottom-left-radius: 16rpx
z-index: 10
// 推荐卡片
.recommend-card::before
position: absolute