岗位发布开发
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
>
|
||||
<image :src="currentItem == item.id ? item.selectedIconPath : item.iconPath"></image>
|
||||
</view>
|
||||
<view class="badge" v-if="item.badge">{{ item.badge }}</view>
|
||||
<view class="badge" v-if="item.badge && item.badge > 0">{{ item.badge }}</view>
|
||||
<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
|
||||
<text>{{ item.text }}</text>
|
||||
</view>
|
||||
@@ -19,7 +19,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { ref, onMounted, computed, watch, nextTick } from 'vue';
|
||||
import { useReadMsg } from '@/stores/useReadMsg';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useUserStore from '@/stores/useUserStore';
|
||||
@@ -36,35 +36,60 @@ const readMsg = useReadMsg();
|
||||
const { userInfo } = storeToRefs(useUserStore());
|
||||
const currentItem = ref(0);
|
||||
|
||||
// 根据用户类型生成不同的导航栏配置
|
||||
const tabbarList = computed(() => {
|
||||
// 监听用户类型变化,重新生成tabbar配置
|
||||
watch(() => userInfo.value?.isCompanyUser, (newIsCompanyUser, oldIsCompanyUser) => {
|
||||
console.log('midell-box用户类型变化监听:', { newIsCompanyUser, oldIsCompanyUser, userInfo: userInfo.value });
|
||||
if (newIsCompanyUser !== oldIsCompanyUser) {
|
||||
console.log('用户类型发生变化,重新生成tabbar:', newIsCompanyUser);
|
||||
// tabbarList是computed,会自动重新计算
|
||||
// 强制触发响应式更新
|
||||
nextTick(() => {
|
||||
console.log('tabbar配置已更新:', tabbarList.value);
|
||||
});
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
// 监听用户信息变化(包括登录状态)
|
||||
watch(() => userInfo.value, (newUserInfo, oldUserInfo) => {
|
||||
console.log('midell-box用户信息变化监听:', { newUserInfo, oldUserInfo });
|
||||
if (newUserInfo !== oldUserInfo) {
|
||||
console.log('用户信息发生变化,重新生成tabbar');
|
||||
// 强制触发响应式更新
|
||||
nextTick(() => {
|
||||
console.log('tabbar配置已更新:', tabbarList.value);
|
||||
});
|
||||
}
|
||||
}, { immediate: true, deep: true });
|
||||
|
||||
// 生成tabbar配置的函数
|
||||
const generateTabbarList = () => {
|
||||
const baseItems = [
|
||||
{
|
||||
id: 0,
|
||||
text: '首页',
|
||||
text: '职位2',
|
||||
path: '/pages/index/index',
|
||||
iconPath: '../../static/tabbar/calendar.png',
|
||||
selectedIconPath: '../../static/tabbar/calendared.png',
|
||||
centerItem: false,
|
||||
badge: readMsg.badges[0].count,
|
||||
badge: readMsg.badges[0]?.count || 0,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
text: '',
|
||||
text: 'AI+',
|
||||
path: '/pages/chat/chat',
|
||||
iconPath: '../../static/tabbar/logo3.png',
|
||||
selectedIconPath: '../../static/tabbar/logo3.png',
|
||||
centerItem: true,
|
||||
badge: readMsg.badges[2].count,
|
||||
badge: readMsg.badges[2]?.count || 0,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
text: '消息',
|
||||
text: '消息2',
|
||||
path: '/pages/msglog/msglog',
|
||||
iconPath: '../../static/tabbar/chat4.png',
|
||||
selectedIconPath: '../../static/tabbar/chat4ed.png',
|
||||
centerItem: false,
|
||||
badge: readMsg.badges[3].count,
|
||||
badge: readMsg.badges[3]?.count || 0,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
@@ -73,12 +98,12 @@ const tabbarList = computed(() => {
|
||||
iconPath: '../../static/tabbar/mine.png',
|
||||
selectedIconPath: '../../static/tabbar/mined.png',
|
||||
centerItem: false,
|
||||
badge: readMsg.badges[4].count,
|
||||
badge: readMsg.badges[4]?.count || 0,
|
||||
},
|
||||
];
|
||||
|
||||
// 根据用户类型添加不同的导航项
|
||||
const userType = userInfo.value?.userType || 0;
|
||||
// 根据用户类型添加不同的导航项,未登录时默认为求职者
|
||||
const userType = userInfo.value?.isCompanyUser !== undefined ? userInfo.value.isCompanyUser : 1;
|
||||
|
||||
if (userType === 0) {
|
||||
// 企业用户:显示发布岗位,隐藏招聘会
|
||||
@@ -86,13 +111,13 @@ const tabbarList = computed(() => {
|
||||
id: 1,
|
||||
text: '发布岗位',
|
||||
path: '/pages/job/publishJob',
|
||||
iconPath: '../../static/tabbar/publish-job.svg',
|
||||
selectedIconPath: '../../static/tabbar/publish-job-selected.svg',
|
||||
iconPath: '../../static/tabbar/post.png',
|
||||
selectedIconPath: '../../static/tabbar/posted.png',
|
||||
centerItem: false,
|
||||
badge: 0,
|
||||
});
|
||||
} else {
|
||||
// 普通用户、网格员、政府人员:显示招聘会
|
||||
// 求职者用户(包括未登录状态):显示招聘会
|
||||
baseItems.splice(1, 0, {
|
||||
id: 1,
|
||||
text: '招聘会',
|
||||
@@ -100,11 +125,16 @@ const tabbarList = computed(() => {
|
||||
iconPath: '../../static/tabbar/post.png',
|
||||
selectedIconPath: '../../static/tabbar/posted.png',
|
||||
centerItem: false,
|
||||
badge: readMsg.badges[1].count,
|
||||
badge: readMsg.badges[1]?.count || 0,
|
||||
});
|
||||
}
|
||||
|
||||
return baseItems;
|
||||
};
|
||||
|
||||
// 根据用户类型生成不同的导航栏配置
|
||||
const tabbarList = computed(() => {
|
||||
return generateTabbarList();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user